#!/usr/bin/env python
# -*- coding: utf-8 -*-
import qondor, seutils
import argparse, sys, uuid
parser = argparse.ArgumentParser()
parser.add_argument('pythonfile', type=str, help='Path to a python file to be submitted to htcondor')
# Save all other arguments in order to use them for the python script in the job
args, other_args = parser.parse_known_args()

def main():
    qondor.utils.check_proxy()
    python_script_args = sys.argv[2:]
    with seutils.root.cache(cache_dir='.fcache/rootcache-{}'.format(uuid.uuid4())) as cache_dir:
        submitter = qondor.Submitter(args.pythonfile)
        cluster_id, ads = submitter.submit(python_script_args)

if __name__ == '__main__':
    main()