Skip to content

Commit

Permalink
remove terrible conddb contraption
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Mar 30, 2020
1 parent ca150f3 commit 9be2666
Showing 1 changed file with 0 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,41 +198,6 @@ def cppboolstring(string, name):
"""
return pythonboolstring(string, name).lower()

def conddb(*args):
"""
Wrapper for conddb, so that you can run
conddb("--db", "myfile.db", "listTags"),
like from the command line, without explicitly
dealing with all the functions in CondCore/Utilities.
getcommandoutput2(conddb ...) doesn't work, it imports
the wrong sqlalchemy in CondCore/Utilities/python/conddblib.py
"""
from tempfile import NamedTemporaryFile

with open(getCommandOutput2("which conddb").strip()) as f:
conddb = f.read()

def sysexit(number):
if number != 0:
raise AllInOneError("conddb exited with status {}".format(number))
namespace = {"sysexit": sysexit, "conddboutput": ""}

conddb = conddb.replace("sys.exit", "sysexit")

bkpargv = sys.argv
sys.argv[1:] = args
bkpstdout = sys.stdout
with NamedTemporaryFile(bufsize=0) as sys.stdout:
exec(conddb, namespace)
namespace["main"]()
with open(sys.stdout.name) as f:
result = f.read()

sys.argv[:] = bkpargv
sys.stdout = bkpstdout

return result

def getTagsMap(db):
con = conddblib.connect(url = conddblib.make_url(db))
session = con.session()
Expand Down

0 comments on commit 9be2666

Please sign in to comment.