Merge pull request #529 from lededev/joindir

use os.path.join() to avoid // path complaints
This commit is contained in:
Yoshiko2
2021-06-27 21:22:57 +08:00
committed by GitHub
2 changed files with 11 additions and 11 deletions

View File

@@ -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)

View File

@@ -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: