def CreateScene(self, proName, seqName, shotName): dirPath = self.serverName + os.sep + proName dirPost = os.path.join(self.postName, proName) seqPath = dirPath + os.sep + seqName seqPost = os.path.join(dirPost, seqName) shotPath = seqPath + os.sep + shotName shotPost = os.path.join(seqPost, shotName) if not os.path.exists(shotPath): TronFolder().CreateFolder(shotPath, "0555", "") TronFolder().CreateFolder(shotPost, "0555", "")
def CreateAsset(self, proName, type, user, fileName): dirPath = self.serverName + os.sep + proName dirPost = os.path.join(self.postName, proName) if len(fileName) == 0 and len(type) == 0: print "please give me a file" else: if type == "lgt" or type == "cmp": TronFolder().CreateStuff(dirPost, "", "", type, fileName, user) else: TronFolder().CreateStuff(dirPath, "", "", type, fileName, user) if len(user) == 0: print "please give me a user" else: if type == "lgt" or type == "cmp": TronFolder().CreateWork(dirPost, "", "", user, type, fileName) else: TronFolder().CreateWork(dirPath, "", "", user, type, fileName)
def CreateRef( self, proName, type, ): refPath = self.refName + os.sep + proName if os.path.exists(refPath): if os.path.exists(refPath): if type == "shots" or type == "assets": refPath += os.sep + type if not os.path.exists(refPath): TronFolder().CreateFolder(refPath, "0777", "") else: os.chmod(refPath, 0777)
def CreateSeq(self, proName, seqName): dirPath = self.serverName + os.sep + proName dirPost = os.path.join(self.postName, proName) seqPath = dirPath + os.sep + seqName seqPost = os.path.join(dirPost, seqName) if not os.path.exists(seqPath): TronFolder().CreateFolder(seqPath, "0555", "") TronFolder().CreateFolder(seqPost, "0555", "") TronFolder().CreateStuff(dirPath, seqName, "", "", "", "") TronFolder().CreateStuff(dirPost, seqName, "", "", "", "") TronFolder().CreateStuff(dirPath, seqName, "", "prd", "", "") TronFolder().CreateWork(dirPath, seqName, "", "", "", "") TronFolder().CreateWork(dirPost, seqName, "", "", "", "")
def CreateDai(self, proName, fileName): daiPath = self.daiName + os.sep + proName if os.path.exists(daiPath): if os.path.exists(daiPath): nowstamp = time.time() hour = time.localtime(nowstamp).tm_hour createstamp = nowstamp if hour >= 18: createstamp += 3600 * 24 tm = time.localtime(createstamp) year, month, day = tm.tm_year, tm.tm_mon, tm.tm_mday daiPath += os.sep + "%04d%02d%02d" % (year, month, day) if not os.path.exists(daiPath): TronFolder().CreateFolder(daiPath, "0777", "") else: os.chmod(daiPath, 0777)
def CreatePro(self, proName): print "create project %s" % (proName) projectChild = { "Doc": "0775", "Dailies": "0555", "Vender": "0555", "Client": "0555", "References": "0555" } proPath = self.serverName + os.sep + proName proPost = os.path.join(self.postName, proName) refPaths = os.path.join(self.refName, proName) daiPaths = os.path.join(self.daiName, proName) if not os.path.exists(proPath): os.mkdir(proPath) os.mkdir(proPost) os.mkdir(daiPaths) os.mkdir(refPaths) os.chown(proPath, self.userID, self.groupID) os.chown(proPost, self.userID, self.groupID) os.chown(daiPaths, self.userID, self.groupID) os.chown(refPaths, self.userID, self.groupID) os.chmod(proPath, 0555) os.chmod(proPost, 0555) os.chmod(daiPaths, 0555) os.chmod(refPaths, 0555) projectChiName = projectChild.keys() for i in projectChiName: folderPath = proPath + os.sep + i refFolPath = refPaths daiFolPath = daiPaths if i == "Client": if not os.path.exists(folderPath): TronFolder().CreateFolder(folderPath, int(projectChild[i]), "prdleader") TronFolder().CreateFolder( (folderPath + os.sep + "incoming"), "0775", "prdleader") TronFolder().CreateFolder( (folderPath + os.sep + "outgoing"), "0775", "prdleader") TronFolder().CreateFolder( (folderPath + os.sep + "delivery"), "0775", "prdleader") elif i == "Vender": if not os.path.exists(folderPath): TronFolder().CreateFolder(folderPath, int(projectChild[i]), "prdleader") TronFolder().CreateFolder( (folderPath + os.sep + "incoming"), "0775", "prdleader") TronFolder().CreateFolder( (folderPath + os.sep + "outgoing"), "0775", "prdleader") elif i == "References": if not os.path.exists(folderPath): TronFolder().CreateFolder(folderPath, int(projectChild[i]), "prdleader") TronFolder().CreateFolder((folderPath + os.sep + "master"), "0775", "prdleader") TronFolder().CreateFolder((folderPath + os.sep + "inner"), "0775", "prdleader") TronFolder().CreateFolder((folderPath + os.sep + "backup"), "0775", "prdleader") if os.path.exists(refFolPath): TronFolder().CreateFolder((refFolPath + os.sep + "shots"), "0775", "prdleader") TronFolder().CreateFolder((refFolPath + os.sep + "assets"), "0775", "prdleader") elif i == "Dailies": if not os.path.exists(daiFolPath): TronFolder().CreateFolder(daiFolPath, int(projectChild[i]), "prdleader") else: if not os.path.exists(folderPath): if projectChild[i] == "0555": TronFolder().CreateFolder(folderPath, "0555", "zhouyc") elif projectChild[i] == "0775": TronFolder().CreateFolder(folderPath, "0775", "zhouyc") TronFolder().CreateStuff(proPath, "", "", "", "", "") TronFolder().CreateStuff(proPost, "", "", "", "", "") TronFolder().CreateStuff(proPath, "", "", "prd", "", "") TronFolder().CreateStuff(proPost, "", "", "cmp", "", "") TronFolder().CreateWork(proPath, "", "", "", "", "") TronFolder().CreateWork(proPost, "", "", "", "", "")
def _init_(): args = sys.argv[1:] logging.info(args) server_tron = config.All server_post = config.Post if args[0] == "open_dai": handle_client(args[1] + '|open_dai') elif args[0] == "Folder": handle_client(args[1] + '|Folder') elif args[0] == "Ready_render" or args[0] == "Local_render" or args[ 0] == "Cloud_render": handle_client(args[1]) elif args[0] == "clip1": # 修改相应场次的权限 path = args[1].split('|')[2] all_path = server_tron + '/' + path os.chmod(all_path, 0777) clipData = args[1] + '|clip1' handle_client(clipData) elif args[0] == "clip2": path = args[1].split('|')[1] video_dir = os.path.dirname(path) all_path = server_tron + '/' + video_dir os.chmod(all_path, 0777) clipData = args[1] + '|clip2' handle_client(clipData) elif args[0] == "clip3": post_path = server_post + args[1].split('|')[1] pack_path = post_path + '/Clip_Pack' os.chmod(post_path, 0777) if os.path.exists(pack_path): shutil.rmtree(pack_path) os.mkdir(pack_path, 0755) else: os.mkdir(pack_path, 0755) clipData = args[1] + '|clip3' handle_client(clipData) elif args[0] == "add_xml": # 修改相应场以及场下镜头的权限 path = args[1].split('|')[2] all_path = server_tron + '/' + path os.chmod(all_path, 0777) ch_li = os.listdir(all_path) for i in ch_li: os.chmod(all_path + i, 0777) clipData = args[1] + '|add_xml' handle_client(clipData) elif args[0] == "clip_del": # 'clip_del' '/FUY/001' pro_name = os.path.dirname(args[1]) all_pro = server_tron + pro_name all_seq = server_tron + args[1] new_path = args[:-3] + '.' + args[-3:] new_all_seq = server_tron + new_path os.chmod(all_pro, 0777) os.rename(all_seq, new_all_seq) os.chmod(all_pro, 0555) post_pro = server_post + pro_name post_seq = server_post + args[1] new_post_seq = server_tron + new_path os.chmod(post_pro, 0777) os.rename(post_seq, new_post_seq) os.chmod(post_pro, 0555) elif args[0] == "Project": TronProject().CreatePro( args[1].upper()) # createProject.CreatePro("HAC") CallBack().callback(args[2]) elif args[ 0] == "Dailies1": # "Dailies1" "/FUY/001/001/Stuff/cmp/" "IP|/FUY/001/001/Stuff/cmp|filename|command_id" dai_filename = args[2].split("|")[2] TronProject().CreateDai(args[1], dai_filename) dailiesData = args[2] + "|Dailies1" handle_client(dailiesData) elif args[ 0] == "Dailies2": # "Dailies1" "/FUY/001/001/Stuff/cmp/" "IP|/FUY/001/001/Stuff/cmp|filename|command_id" dai_filename = args[2].split("|")[2] TronProject().CreateDai(args[1], dai_filename) dailiesData = args[2] + "|Dailies2" handle_client(dailiesData) elif args[ 0] == "lgt_dai": # "lgt_dai" "/FUY/001/001/Stuff/cmp/" "IP|/FUY/001/001/Stuff/cmp|filename|command_id|rate|帧长" dai_filename = args[2].split("|")[2] TronProject().CreateDai(args[1], dai_filename) dailiesData = args[2] + "|lgt_dai" handle_client(dailiesData) elif args[ 0] == 'YunFolder': # "YunFolder" "ip" "filepath|时间戳" "YunFolder" "192.168.1.33" "/DSN_TXT_8/|1550839953" handle_client(args[1] + '|' + args[2] + '|YunFolder') elif args[0] == "Del": # "Del" "{公司_项目_主键id: 时间戳, 公司_项目_主键id: 时间戳}" TronDistribute().Deldir(args[1]) elif args[ 0] == "Reference": # "Reference" "HAC" "shots" "IP|文件夹路径|文件名|sql_data" TronProject().CreateRef(args[1].upper(), args[2]) referencesData = args[3] + "|Reference" handle_client(referencesData) elif args[0] == "download": # 'download' 'tron_TXT_7|路径' 'id' 'user_id' key, arg2 = args[1].split('|') res = AliyunOss('', key, '', '', '', '').download(arg2) if res: CallBack().callback_download(args[2], args[3]) elif args[ 0] == "download_out": # 'download_out' '[tron_TXT_7, tron_TXT_6]' 'ids' 'user_id' 'ip' clipData = args[4] + '|' + args[1] + '|download' downloadPath = handle_client(clipData) logging.info('download_out path: ' + downloadPath) if os.path.exists(downloadPath): for fileName in eval(args[1]): AliyunOss('', fileName, '', '', '', '').download(downloadPath) CallBack().callback_download(args[2], args[3]) elif args[0] == "Seq": # createProject.CreateSeq(proName, seqName) TronProject().CreateSeq(args[1].upper(), args[2]) CallBack().callback(args[3]) elif args[ 0] == "Shot": # "Shot" "HAC" "001" "001" "user_name" "command_id" # 创建镜头时在all盘创建stuff和work以及prd的文件夹,post盘只创建stuff和work TronProject().CreateScene(args[1].upper(), args[2], args[3]) proPath_all = server_tron + '/' + args[1].upper() TronFolder().CreateStuff(proPath_all, args[2], args[3], 'prd', '', args[4]) all_work = proPath_all + '/' + args[2] + '/' + args[3] + '/Work' TronFolder().CreateFolder(all_work, "0555", "") post_work = server_post + '/' + args[1].upper( ) + '/' + args[2] + '/' + args[3] + '/Work' post_stuff = server_post + '/' + args[1].upper( ) + '/' + args[2] + '/' + args[3] + '/Stuff' TronFolder().CreateFolder(post_work, "0555", "") TronFolder().CreateFolder(post_stuff, "0555", "") CallBack().callback(args[5]) elif args[0] == "Pack": # "Pack" "Json路径" "时间戳" "打包id" "command_id" res = TronDistribute().argParse(args[1], args[2]) if res: CallBack().callback_pack(args[3]) CallBack().callback(args[4]) elif args[ 0] == "Transit_out": # "Transit" "路径" “文件名” "transit_id" 'user_id' “command_id” res = transit(args[1], args[2]) if res: CallBack().callback_transit(args[5]) CallBack().callback_transit_complete(args[3], args[4]) elif args[ 0] == "Transit": # "Transit" "json路径" "transit_id,transit_id1" "user_id" “command_id” res = transit(args[1]) if res: CallBack().callback_transit(args[4]) CallBack().callback_transit_complete(args[2], args[3]) elif args[ 0] == "AssetTask": # "AssetTask" "HAC" "rig" "liangcy" "fileName" "command_id" TronProject().CreateAsset(args[1].upper(), args[2], args[3], args[4]) # CallBack().callback(args[5]) # args = args[6] + '|' + args[1] + '|' + args[2] + '|' + args[3] + '|' + args[4] + "|AssetTask" # handle_client(args) elif args[ 0] == "ShotTask": # "ShotTask" "HAC" "001" "001" "rig" "liangcy" "fileName" "command_id" TronProject().CreateShot(args[1].upper(), args[2], args[3], args[4], args[5], args[6])
def clientLink(data): args = data.split("|") task = args[-1] senStr = '|'.join(args[1:]) server_all = config.All log_path_client = config.log_path_client + time.strftime("%Y%m%d") + '.log' HOST = args[0] PORT = config.port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((HOST, PORT)) except: write_log(log_path_client, str(HOST) + ':' + str(PORT) + ' can not connect' + '\n') else: if senStr: write_log(log_path_client, data + '\n') s.sendall(senStr) write_log(log_path_client, ' already send' + '\n') task_set = { 'clip1', 'add_xml', 'clip2', 'download', 'Dailies1', 'Dailies2', 'lgt_dai', 'Reference' } if task in task_set: recv_data = s.recv(1024) s.close() write_log(log_path_client, 'client close' + '\n') if recv_data: write_log(log_path_client, 'recv data is: ' + recv_data + '\n') if task == 'clip2': video_dir = os.path.dirname(args[1]) path = server_all + '/' + video_dir os.chmod(path, 0555) write_log(log_path_client, path + ' already chmod 555' + '\n') elif task == 'Dailies1' or task == 'lgt_dai' or task == 'Dailies2': filePath = args[1] filename = args[2] daiPath = server_all + filePath + '/img' # /Tron/FUY/001/001/stuff/cmp/img daiPath2 = server_all + filePath + '/mov' dai_file_path = daiPath + '/' + filename dai_file_path2 = daiPath2 + '/' + filename if not os.listdir(dai_file_path): os.chmod(daiPath, 0777) os.rmdir(dai_file_path) if not os.listdir(dai_file_path2): os.chmod(daiPath2, 0777) os.rmdir(dai_file_path2) if os.path.exists(dai_file_path): os.chmod(dai_file_path, 0755) if os.path.exists(dai_file_path2): os.chmod(dai_file_path2, 0755) os.chmod(daiPath, 0555) os.chmod(daiPath2, 0555) write_log(log_path_client, daiPath + ' already chmod 555' + '\n') elif task == 'Reference': server_ref = config.Reference ref_path = server_ref + args[1] os.chmod(ref_path, 0555) write_log(log_path_client, ref_path + ' already chmod 555' + '\n') elif task == 'download': return recv_data elif task == 'clip1' or task == 'add_xml': # args:[ip, xml_path, TXT/998/, project_id, seq_id, xml_id, command_id, clip1] xml_path = args[1] # recv_data: FUY/001/ seq_path = server_all + '/' + recv_data # /Tron/FUY/001/ if os.path.exists(seq_path): shots_li = (i for i in os.listdir(seq_path) if i.isdigit()) # 获取场下的所有镜头号 proPath = seq_path[:-5] # /Tron/FUY 项目路径 seqName = seq_path[-4:-1] # 场号 it_uid = 11001 it_gid = 11000 for shotName in shots_li: shot_path = seq_path + shotName # 在镜头下创建Stuff和Work TronFolder().CreateStuff( proPath, seqName, shotName, 'prd', '', '') write_log( log_path_client, 'create stuff ' + proPath + ' / ' + seqName + shotName + '\n') work_path = shot_path + '/Work' TronFolder().CreateFolder( work_path, "0555", "") # 创建/Stuff/prd/plates/mov/tron_plates文件夹,用于存放tron的剪辑线素材 tron_plates_path = shot_path + '/Stuff/prd/plates/mov/tron_plates' TronFolder().CreateFolder( tron_plates_path, "0555", "") # 获取视频和图片路径,将视频和缩略图剪切至 /Stuff/prd/plates/mov/tron_plates mov_jpg = [ i for i in os.listdir(shot_path) if i.endswith('jpg') or i.endswith('mov') ] for mov_or_jpg in mov_jpg: mov_or_jpg_path = shot_path + '/' + mov_or_jpg shutil.move(mov_or_jpg_path, tron_plates_path) # 修改每个镜头的权限为it 555 os.chown(shot_path, it_uid, it_gid) os.chmod(shot_path, 0555) os.chmod(seq_path, 0555) xml_path = server_all + '/' + xml_path os.remove(xml_path) write_log(log_path_client, seq_path + ' already chmod 555' + '\n') CallBack().clip_to_php(1, 0, args[3], args[4], args[5]) write_log(log_path_client, 'already callback 100' + '\n')