def isValidForTranscode(path): if '.mts' in path: return True else: return False ### entry point print "This script will insert transcode jobs for all files recursively beneath a bucket and path" print "" print "Please enter the target bucket with path (ie <bucket>/<path>" TARGET = stdin.readline().rstrip('\n') pr = PipelineResolver(TARGET.split('/')[0]) PIPELINEID = pr.getPipelineId() REGION = pr.getRegion() BUCKET = pr.getBucket() if PIPELINEID != None: print "resolved pipelineid:"+PIPELINEID+"\n" print "resolved region:"+REGION+"\n" command = 's4cmd ls s3://'+TARGET+'/ -r' print "running command ",command child = pexpect.spawn(command, timeout=None) #do not time out for line in child: print line
if '.mts' in path and '=>' in path: return True else: return False ### entry point print "This script will upload files recursively from a target and call transcode for completed uploads" print "" print "Please enter the source (directory only):" SOURCE = stdin.readline().rstrip('\n') print "Please enter the target bucket:" TARGET = stdin.readline().rstrip('\n') pr = PipelineResolver(TARGET) PIPELINEID = pr.getPipelineId() REGION = pr.getRegion() if PIPELINEID != None: print "resolved pipelineid:"+PIPELINEID+"\n" print "resolved region:"+REGION+"\n" command = 's4cmd put '+SOURCE+'/ s3://'+TARGET+'/ -r' print "running command ",command child = pexpect.spawn(command, timeout=None) #do not time out for line in child: print 'got output from s4cmd:'+line if isValidForTranscode(line):