From 169f148f885ddcd3697656129fd01968853a21de Mon Sep 17 00:00:00 2001 From: tlatorre Date: Wed, 28 Aug 2019 10:36:01 -0500 Subject: update submit-grid-jobs to use my version of splitext This commit updates the submit-grid-jobs script to use my version of splitext() which removes the full extension from the filename. This fixes an issue where the output HDF5 files had xzdab in the name whenever the input file had the file extension .xzdab.gz. --- utils/submit-grid-jobs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'utils/submit-grid-jobs') diff --git a/utils/submit-grid-jobs b/utils/submit-grid-jobs index a55a723..1fa015b 100755 --- a/utils/submit-grid-jobs +++ b/utils/submit-grid-jobs @@ -21,7 +21,7 @@ try: except ImportError: from yaml.loader import SafeLoader as Loader import string -from os.path import split, splitext, join, abspath +from os.path import split, join, abspath import uuid from subprocess import check_call import os @@ -140,6 +140,24 @@ ID = uuid.uuid1() class MyTemplate(string.Template): delimiter = '@' +def splitext(path): + """ + Like os.path.splitext() except it returns the full extension if the + filename has multiple extensions, for example: + + splitext('foo.tar.gz') -> 'foo', '.tar.gz' + """ + full_root, full_ext = os.path.splitext(path) + while True: + root, ext = os.path.splitext(full_root) + if ext: + full_ext = ext + full_ext + full_root = root + else: + break + + return full_root, full_ext + def submit_job(filename, run, gtid, dir, dqxx_dir, min_nhit, max_particles, particle_combo=None): print("submitting job for %s gtid %i" % (filename, gtid)) head, tail = split(filename) -- cgit