diff --git a/exporter.py b/exporter.py index decd0a5..bd73c42 100755 --- a/exporter.py +++ b/exporter.py @@ -62,10 +62,9 @@ return sent_all_jobs and not len(jobs) if not from_stdin: - base_args = make_base_job_args(args) for i in args["input"]: try: - job = Job(input = i, **base_args) + job = Job(in_file = i) jobs[job.id] = job except Exception, e: print e @@ -92,10 +91,9 @@ if err is not None: print err else: - base_args = make_base_job_args(dict(args.items() + line_args.items())) for i in line_args["input"]: try: - job = Job(input = i, **base_args) + job = Job(in_file = i) jobs[job.id] = job except Exception, e: print e diff --git a/exporter.py b/exporter.py index decd0a5..bd73c42 100755 --- a/exporter.py +++ b/exporter.py @@ -62,10 +62,9 @@ return sent_all_jobs and not len(jobs) if not from_stdin: - base_args = make_base_job_args(args) for i in args["input"]: try: - job = Job(input = i, **base_args) + job = Job(in_file = i) jobs[job.id] = job except Exception, e: print e @@ -92,10 +91,9 @@ if err is not None: print err else: - base_args = make_base_job_args(dict(args.items() + line_args.items())) for i in line_args["input"]: try: - job = Job(input = i, **base_args) + job = Job(in_file = i) jobs[job.id] = job except Exception, e: print e diff --git a/job.py b/job.py index 9c448e8..548ca8a 100644 --- a/job.py +++ b/job.py @@ -1,8 +1,16 @@ import os.path import base64 import json +from jsonschema import validate from args import * +asset_src_schema = { + "type":"object", + "properties":{ + "graphics":{"type":"array"} + } +} + class Job: next_id = 0 def __init__(self, in_file, base_dir = None, out_dir = None): @@ -20,14 +28,19 @@ self.graphics = [] with open(self.in_file, mode="r") as f: graphics = [] + file_json = {} try: file_json = json.loads(f.read()) except: raise Exception("Failed: " + in_file + " does not contain valid data") - if not "graphics" in file_json or not isinstance(file_json["graphics"], list): - raise Exception("Failed: " + in_file + " does not contain a \"graphics\" list") - for graphic_json in file_json["graphics"]: - self.graphics.append(Graphic(graphic_json)) + + try: + validate(instance=file_json, schema=asset_src_schema) + except Exception, e: + raise Exception("Faield: " + in_files + " " + str(e)) + + for graphic_json in file_json["graphics"]: + self.graphics.append(Graphic(graphic_json)) def get_cmd(self): return {"graphics":[g.get_cmd() for g in self.graphic], "id":self.id}