def queue_append(queue_list): try: logger.debug(queue_list) new_queue_list = [] for q in queue_list: src, tar = q.split('|') tmps = tar.split('/') if len(tmps) > 1: for i in range(1, len(tmps)): tmps[i] = Util.change_text_for_use_filename( tmps[i]).replace(' ', ' ').replace( ' ', ' ').rstrip('.').strip() new_queue_list.append('%s|%s/%s' % (src, tmps[0], '/'.join(tmps[1:]))) else: new_queue_list.append(q) logger.debug(new_queue_list) tmp = ModelSetting.get('gclone_queue_list') tmp += '\n' + '\n'.join(new_queue_list) ModelSetting.set('gclone_queue_list', tmp) socketio_callback('refresh_queue', ModelSetting.get('gclone_queue_list')) return LogicGclone.start() except Exception as e: logger.error('Exception:%s', e) logger.error(traceback.format_exc())
def func(): LogicGclone.current_data['status'] = 'is_running' while True: count = 0 job_list = ModelSetting.get_list( 'gclone_queue_list', '\n') for job in job_list: try: if LogicGclone.current_data['user_stop']: break tmp = job.split('#')[0].split('|') if len(tmp) == 2: target = tmp[1].strip() target = target.replace( '{}', '{%s}' % ModelSetting.get( 'gclone_default_folderid')) if target.find('{}') != -1: continue if target.find(':') == -1: continue return_code = LogicGclone.gclone_execute( tmp[0].strip(), target) # 0 정상 logger.debug('return_code:%s', return_code) if return_code == 0: tmp2 = ModelSetting.get( 'gclone_queue_list') for t in tmp2.split('\n'): if t.strip().startswith( '%s|%s' % (tmp[0], tmp[1])): ModelSetting.set( 'gclone_queue_list', tmp2.replace(t, '')) socketio_callback( 'refresh_queue', ModelSetting.get( 'gclone_queue_list')) count += 1 except Exception as e: logger.error('Exception:%s', e) logger.error(traceback.format_exc()) if LogicGclone.current_data['user_stop']: break if count == 0: break LogicGclone.current_data['status'] = 'ready' LogicGclone.current_data['user_stop'] = False data = {'type': 'success', 'msg': u'gclone 작업을 완료하였습니다.'} socketio.emit("notify", data, namespace='/framework', broadcast=True)