def get_makedirs(a_fun, a_db, a_module, a_module_type, a_id_list): if not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_id_list, list): raise Exception("_module.get_makedirs argv error, must be( str,str,str,list)") if unicode(a_db).lower().strip()=="public": raise Exception("_module.get_makedirs , can not use to public database") if len(a_id_list)==0: return False t_os=_lib.get_os() #怕选择的要创建的目录太多的时候。进行分ID取数据 t_page_num=100#每次的条数 t_num=len(a_id_list)/t_page_num #循环的次数 t_module_num=len(a_id_list)%t_page_num #取模 if t_module_num>0: t_num=t_num+1 t_all_data_lis=[] for i in range(t_num): temp_id_lis=a_id_list[i*t_page_num: (i+1)*t_page_num] res=a_fun("c_folder","get_create_folder_data", {"db":a_db, "module":a_module, "module_type":a_module_type, "os":t_os, "task_id_array":temp_id_lis}) t_all_data_lis=t_all_data_lis+res return t_all_data_lis
def get_submit_filebox(a_fun, a_db, a_module, a_module_type, a_id): if not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_id, (str, unicode)): raise Exception("_module.get_submit_filebox argv error, must be( str,str,str,str)") if unicode(a_id).strip()=="": return [] t_os=_lib.get_os() return a_fun("c_file","filebox_get_submit_data",{"db":a_db,"module":a_module,"module_type":a_module_type, "task_id":a_id, "os":t_os})
def get_filebox(a_fun, a_db, a_module, a_module_type, a_id, a_filebox_id): if not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_id, (str, unicode)) or not isinstance(a_filebox_id, (str, unicode)): raise Exception("_module.get_filebox argv error, must be( str,str,str,str,str)") if unicode(a_db).lower().strip()=="public": raise Exception("_module.get_filebox , can not use to public database") if unicode(a_id).strip()=="": return [] t_os=_lib.get_os() return a_fun("c_file","filebox_get_one_with_id",{"db":a_db, "module":a_module,"module_type":a_module_type, "task_id":a_id, "os":t_os, "filebox_id":a_filebox_id})
def create(a_fun, a_http_ip, a_cgtw_path, a_token, a_account_id, a_db, a_module, a_module_type, a_task_id_list, a_text, a_cc_acount_id="", a_image_list=[]): if not isinstance(a_http_ip, (str, unicode)) or not isinstance(a_cgtw_path, (str, unicode)) or not isinstance(a_account_id, (str, unicode)) or not isinstance(a_token, (str, unicode)) or \ not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_task_id_list, list) or not isinstance(a_text, (str, unicode)) or not isinstance(a_cc_acount_id, (str, unicode)) or not isinstance(a_image_list, list): raise Exception( "_note.create argv error, must be( str,str,str,str,str,str,str,list,str,str,list)" ) if len(a_task_id_list) == 0: return False t_os = _lib.get_os() image_list = [] if len(a_image_list) != 0: if a_cgtw_path not in sys.path: sys.path.append(a_cgtw_path) import ct t_http = ct.http(a_http_ip, a_token) for t_image_file in a_image_list: res = t_http.upload_project_img(t_image_file, a_db) if res.has_key("max") and res.has_key("min"): image_list.append(res) return a_fun( "c_note", "create", { "db": a_db, "cc_acount_id": a_cc_acount_id, "field_data_array": { "module": a_module, "module_type": a_module_type, "#task_id": ",".join(a_task_id_list), "text": { "data": a_text, "image": image_list }, "#from_account_id": a_account_id } })
def download_image(a_fun, a_http_ip, a_cgtw_path, a_token, a_db, a_module, a_module_type, a_id_list, a_field_sign, a_is_small=True, a_local_path=""): if not isinstance(a_http_ip, (str, unicode)) or not isinstance(a_cgtw_path, (str, unicode)) or not isinstance(a_token, (str, unicode)) or \ not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_id_list, list) or not isinstance(a_field_sign, (str, unicode)) or not isinstance(a_is_small, bool) or not isinstance(a_local_path, (str, unicode)): raise Exception("_module.download_image argv error, must be( str,str,str,list,str,bool,str)") t_os=_lib.get_os() if a_cgtw_path not in sys.path: sys.path.append(a_cgtw_path) import ct t_localpath=a_local_path if t_localpath.strip()=="": t_localpath=ct.com().get_tmp_path() if not os.path.exists(t_localpath): try: os.mkdir(t_localpath) except Exception, e: raise Exception(e)
def get_dir(a_fun, a_db, a_module, a_module_type, a_id_list, a_folder_sign_list): if not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_id_list, list) or not isinstance(a_folder_sign_list, list): raise Exception("_module.get_dir argv error, must be( str,str,str,list, list)") if unicode(a_db).lower().strip()=="public": raise Exception("_module.get_dir , can not use to public database") if len(a_id_list)<=0: return [] t_os=_lib.get_os() t_data_list=a_fun("c_folder", "get_replace_path_in_sign", {"db":a_db, "module":a_module, "module_type":a_module_type, "task_id_array":a_id_list, "os":t_os, "sign_array":a_folder_sign_list}) t_result_list=[] for key in t_data_list.keys(): t_tmp_dict={} t_tmp_dict["id"]=key for i in range(len(a_folder_sign_list)): if len(a_folder_sign_list)!=len(t_data_list[key]): t_tmp_dict[a_folder_sign_list[i]]="" t_tmp_dict[a_folder_sign_list[i]]=t_data_list[key][i] t_result_list.append(t_tmp_dict) return t_result_list