From 15aa0a5198f40a9fa8b94061d62ed71d9230390b Mon Sep 17 00:00:00 2001 From: lededev Date: Sat, 26 Jun 2021 18:21:01 +0800 Subject: [PATCH] use path.join() to avoid // path complaints --- AV_Data_Capture.py | 14 +++++++------- core.py | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 4f6cd80..209f85c 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -77,8 +77,8 @@ def rm_empty_folder(path): return for file in files: try: - os.rmdir(path + '/' + file) # 删除这个空文件夹 - print('[+]Deleting empty folder', path + '/' + file) + os.rmdir(os.path.join(path, file)) # 删除这个空文件夹 + print('[+]Deleting empty folder', os.path.join(path, file)) except: pass @@ -112,15 +112,15 @@ def create_data_and_move(file_path: str, c: config.Config, debug): if c.failed_move() == False: if c.soft_link(): print("[-]Link {} to failed folder".format(file_path)) - os.symlink(file_path, conf.failed_folder() + "/" + file_name) + os.symlink(file_path, os.path.join(conf.failed_folder(), file_name)) elif c.failed_move() == True: if c.soft_link(): print("[-]Link {} to failed folder".format(file_path)) - os.symlink(file_path, conf.failed_folder() + "/" + file_name) + os.symlink(file_path, os.path.join(conf.failed_folder(), file_name)) else: try: print("[-]Move [{}] to failed folder".format(file_path)) - shutil.move(file_path, conf.failed_folder() + "/" + file_name) + shutil.move(file_path, os.path.join(conf.failed_folder(), file_name)) except Exception as err: print('[!]', err) @@ -137,11 +137,11 @@ def create_data_and_move_with_custom_number(file_path: str, c: config.Config, cu if c.soft_link(): print("[-]Link {} to failed folder".format(file_path)) - os.symlink(file_path, conf.failed_folder() + "/" + file_name) + os.symlink(file_path, os.path.join(conf.failed_folder(), file_name)) else: try: print("[-]Move [{}] to failed folder".format(file_path)) - shutil.move(file_path, conf.failed_folder() + "/" + file_name) + shutil.move(file_path, os.path.join(conf.failed_folder(), file_name)) except Exception as err: print('[!]', err) diff --git a/core.py b/core.py index 743490d..1b517f2 100755 --- a/core.py +++ b/core.py @@ -42,10 +42,10 @@ def moveFailedFolder(filepath): file_name = os.path.basename(filepath) if conf.soft_link(): print('[-]Create symlink to Failed output folder') - os.symlink(filepath, failed_folder + '/' + file_name) + os.symlink(filepath, os.path.join(failed_folder, file_name)) else: print('[-]Move to Failed output folder') - shutil.move(filepath, failed_folder + '/' + file_name) + shutil.move(filepath, os.path.join(failed_folder, file_name)) return @@ -367,7 +367,7 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa if r == '': print('[-]Movie Data not found!') return - with open(str(path) + "/" + filename, "wb") as code: + with open(os.path.join(str(path), filename), "wb") as code: code.write(r.content) return else: @@ -379,7 +379,7 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa if r == '': print('[-]Movie Data not found!') return - with open(str(path) + "/" + filename, "wb") as code: + with open(os.path.join(str(path), filename), "wb") as code: code.write(r.content) return except requests.exceptions.RequestException: