update example scripts to SessionOpenMode

This commit is contained in:
c-holtermann
2020-06-12 12:24:05 +02:00
parent b073dbc5c3
commit ee77b713c2
11 changed files with 46 additions and 25 deletions

View File

@@ -64,6 +64,7 @@ try:
from gnucash.gnucash_business import Customer, Employee, Vendor, Job, \
Address, Invoice, Entry, TaxTable, TaxTableEntry, GNC_AMT_TYPE_PERCENT, \
GNC_DISC_PRETAX
from gnucash import SessionOpenMode
import locale
except ImportError as import_error:
print("Problem importing modules.")
@@ -236,7 +237,12 @@ def main(argv=None):
# Try to open the given input
try:
session = gnucash.Session(input_url,ignore_lock=ignore_lock)
session = gnucash.Session(
input_url,
SessionOpenMode.SESSION_READ_ONLY
if ignore_lock
else SessionOpenMode.SESSION_NORMAL_OPEN,
)
except Exception as exception:
print("Problem opening input.")
print(exception)