diff --git a/exporter.py b/exporter.py index 2a00557..1520da2 100755 --- a/exporter.py +++ b/exporter.py @@ -39,7 +39,7 @@ return lambda v: make_type(v) if condition(make_type(v)) else None def folder(self, v): - path = os.path.abspath(os.getcwd() + "/" + v) + path = abspath(v) if os.path.isdir(path): return path return None @@ -139,6 +139,13 @@ return {"type": args["type"] if "type" in args else 1, \ "scale": args["scale"] if "scale" in args else 1} +class Job: + next_id = 0 + __init__(self, base_cmd, job_cmd): + self.id = next_id + next_id += 1 + + num_jobs_sent = 0 def send_job(conn, base_cmd, in_file): global num_jobs_sent @@ -239,3 +246,13 @@ if (conn): conn.close() s.close() + +def abspath(path): + return os.path.abspath(os.path.expanduser(path)) + +def file_in_path(file, path): + file = abspath(file) + path = abspath(path) + if not os.path.isdir(path) or not os.path.isfile(file): + return False + return os.path.commonprefix(path, file) == path