def cache_code(): global task_list if request.method == 'POST': request_args = to_unicode(eval(request.data)) #记录打包信息,且返回id from build_script.util.my_dict import toDict cache_info = toDict(request_args) from models.enterprise import RepositoryModule cache_id = RepositoryModule.add_repository(cache_info) #存入队列 request_args['cache_id'] = cache_id import uuid task_id = uuid.uuid1() task = { 'task_id': task_id, 'task_type': 'cachecode', 'task_name': '缓存代码中...', 'task_info': request_args, } task_list.append(task) return make_response(jsonify({ "result": 'success!', 'task_id': task_id }), 200)
def exec_task_for(task): if task.has_key('task_type'): task_type = task['task_type'] task_function = getattr(Task, "task_%s" % task_type) if task.has_key('task_info'): task_info = task['task_info'] return task_function(toDict(task_info))
def update_conf(self): """ """ local_code = self.setup_info.get("local_code") enterprise_number = self.conf_info.get("enterprise_number") #Update config if len(self.conf_setting): for con_set in self.conf_setting: # con_set = toDict(con_set) switch_info = {} for file_item in con_set.file_items: if file_item['item_name'] in self.conf_info: switch_info[ file_item['item_name']] = self.conf_info.get( file_item['item_name']) if switch_info: self.to_parse_file(local_code, con_set, switch_info) #Update logo if self.is_changeLogo == '1': from build_script.util.update_logo import update_logo logo_info = dict(local_code=local_code, enterprise_number=enterprise_number, os_mode=self.os_mode) update_logo(logo_info)
def getLog(history_info): history_info = toDict(history_info) if history_info.has_key('enterprise_number') & history_info.has_key( 'operation_time'): enterprise_number = history_info.enterprise_number operation_time = history_info.operation_time file_name = '{log_dir}{enterprise_number}_{operation_time}.log'.format( log_dir=build_conf.LOG_DIR, enterprise_number=enterprise_number, operation_time=operation_time) cmd = 'cat {0}'.format(file_name) #os.popen #usage: #os.popen(command[, mode[, bufsize]]) fd = os.popen(cmd) log_info = fd.read() fd.close() return log_info else: return False
def upload_package(): global task_list if request.method == 'POST': request_args = to_unicode(eval(request.data)) #记录打包信息,且返回id from build_script.util.my_dict import toDict cache_info = toDict(request_args) #存入队列 import uuid task_id = uuid.uuid1() task = { 'task_id': task_id, 'task_type': 'packageupload', 'task_name': '正在上传安装包...', 'task_info': request_args, } task_list.append(task) return make_response(jsonify({ "result": 'success!', 'task_id': task_id }), 200)