Skip to content

Commit

Permalink
Merge pull request #174 from cgat-developers/JS-sqlalchemy
Browse files Browse the repository at this point in the history
sqlalchemy 2.0 fix
  • Loading branch information
snsansom authored Mar 28, 2024
2 parents ca95104 + 64503d2 commit e033b36
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cgatcore/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def executewait(dbhandle, statement, regex_error="locked",
while 1:
try:
cc = dbhandle.execute(statement)
except AttributeError:
with dbhandle.begin() as conn:
cc = conn.execute(sqlalchemy.text(statement))
except Exception as msg:
if retries == 0:
raise
Expand Down
2 changes: 1 addition & 1 deletion cgatcore/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def convert_value(self, opt, value):
# they could be accessed as self.action and self.dest?
def take_action(self, action, dest, opt, value, values, parser):

if action == "append" and type(value) == list:
if action == "append" and isinstance(value, list):
values.ensure_value(dest, []).extend(value)
else:
optparse.Option.take_action(
Expand Down
2 changes: 1 addition & 1 deletion cgatcore/iotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ def write_table(outfile, table, columns=None, fillvalue=""):
'''

if type(table) == dict:
if isinstance(table, dict):
if columns is None:
columns = list(table.keys())
outfile.write("\t".join(columns) + "\n")
Expand Down
2 changes: 1 addition & 1 deletion cgatcore/pipeline/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from cgatcore.pipeline.parameters import input_validation, get_params, get_parameters
from cgatcore.experiment import get_header, MultiLineFormatter
from cgatcore.pipeline.utils import get_caller, get_caller_locals, is_test
from cgatcore.pipeline.execution import execute, start_session,\
from cgatcore.pipeline.execution import execute, start_session, \
close_session


Expand Down
2 changes: 1 addition & 1 deletion cgatcore/pipeline/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def as_list(value):
list
'''
if type(value) == str:
if isinstance(value, str):
try:
values = [x.strip() for x in value.strip().split(",")]
except AttributeError:
Expand Down

0 comments on commit e033b36

Please sign in to comment.