def _save_as_csv(self, path): with open(path, 'w', newline='\n') as f: first_as_dict = RenderJob().to_dict() del first_as_dict['children'] first_as_dict['parent'] = "" keys = first_as_dict.keys() writer = csv.DictWriter(f, fieldnames=keys) writer.writeheader() self._write_csv_rows(writer, self.rootjobs)
def create_job_list(): job = RenderJob() job.blend_path = "../test/TheRing.blend" job.scene = 'Scene' job.percentage = 25 job.samples = 32 job.startframe = 1 job.endframe = 10 joblist = RenderJobList() joblist.append(job) joblist.prepare() joblist.break_jobs(5) joblist.describe() joblist.save_as('joblist.csv')
def load(cls, path): result = RenderJobList() result.path = path with open(path, 'r') as f: reader = csv.DictReader(f) for row in reader: job = RenderJob.from_dict(row) parentid = row['parent'] if parentid: parent = next((x for x in result.rootjobs if x.id == parentid), None) if parent is None: raise Exception(f'Parent "{parentid}" not found."') parent.add_child(job) else: result.rootjobs.append(job) return result
def describe(self, dates=False): print(RenderJob.get_str_header()) self._describe_jobs(self.rootjobs, dates=dates)
def from_dict(cls, obj): result = RenderJobList() result.rootjobs = list(map(lambda j: RenderJob.from_dict(j), obj['rootjobs'])) return result
def get_test_job(self): job = RenderJob() job.blend_path = '../test/TheRing.blend' job.scene = 'Scene' return job
def command_add(args): validate_add(args) jobs = load(args) packer = RenderPacker() job = RenderJob() job.source_blend_path = args.blend job.package = packer.pack(args.blend, args.additionalfile) job.description = args.description job.additional_file_count = len( args.additionalfile) if args.additionalfile != None else 0 job.scene = args.scene job.startframe = args.startframe job.endframe = args.endframe job.step = args.step job.xres = args.xres job.yres = args.yres job.samples = args.samples job.percentage = args.percentage job.use_large_disk = truthy(args.large) job.prepare() if args.breaksize >= 1: if job.startframe < 1 or job.endframe < 1: raise Exception( "Can only break a job if -f/--startframe and -e/--endframe are specified." ) job.break_job(args.breaksize) job.describe(True) jobs.rootjobs.append(job) jobs.save()
def command_add(args): validate_add(args) jobs = load(args) job = RenderJob() job.blend_path = args.blend job.scene = args.scene job.startframe = args.startframe job.endframe = args.endframe job.step = args.step job.xres = args.xres job.yres = args.yres job.samples = args.samples job.percentage = args.percentage job.prepare() if args.breaksize >= 1: if job.startframe < 1 or job.endframe < 1: raise Exception( "Can only break a job if -f/--startframe and -e/--endframe are specified." ) job.break_job(args.breaksize) job.describe(True) jobs.rootjobs.append(job) jobs.save()