def copy_file(source_file,target_file): try: source = getRootDir(source_file) desfilename=source_file.replace('/',os.sep).replace(source,target_file,1).replace('\\\\',os.sep) LogHelper.debug(source_file + " copy to "+desfilename) if not os.path.exists(os.path.dirname(desfilename)): os.makedirs(os.path.dirname(desfilename)) if not os.path.exists(desfilename): shutil.copy(source_file,desfilename)#如果要改为移动,而不是拷贝,可以将copy改为move return "1,.," except Exception as e: LogHelper.error("CopyError0:" + e.message) return "0,.,CopyError0:" + e.message
LogHelper.info(str_config) obj = RedisHelper(str_r_ip, str_r_pwd, str_r_port, str_r_db, str_r_chan, str_r_chan2) # 赋值订阅变量 redis_sub = obj.subscribe() for item in redis_sub.listen(): LogHelper.info(item) if item['type'] == "message": if bytes.decode(item['channel']) == str_r_chan: #新建一个新的command_info对象 obj_msg = command_info() #将字典转化为对象 obj_msg.__dict__ = json.loads(item['data']) LogHelper.debug(obj_msg.__dict__) obj_result = Result_info() obj_result.type = obj_msg.type if obj_msg.type == 1: #1、获取所有硬盘基本信息 obj_result.flag = True tmplist = disk_info.get_fs_info() LogHelper.debug(tmplist) obj_result.code = len(tmplist) obj_result.msg = json_dict_to_str(tmplist) LogHelper.debug(obj_result.msg) str_result = json_dict_to_str(obj_result.__dict__) redis_public(obj, str_result) elif obj_msg.type == 2: #2、扫描硬盘 obj_result.flag = True dirs = obj_msg.msg.split(',.,') #多个目录扫描, C:,D:,E: