use path.join() to avoid // path complaints
This commit is contained in:
@@ -77,8 +77,8 @@ def rm_empty_folder(path):
|
|||||||
return
|
return
|
||||||
for file in files:
|
for file in files:
|
||||||
try:
|
try:
|
||||||
os.rmdir(path + '/' + file) # 删除这个空文件夹
|
os.rmdir(os.path.join(path, file)) # 删除这个空文件夹
|
||||||
print('[+]Deleting empty folder', path + '/' + file)
|
print('[+]Deleting empty folder', os.path.join(path, file))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -112,15 +112,15 @@ def create_data_and_move(file_path: str, c: config.Config, debug):
|
|||||||
if c.failed_move() == False:
|
if c.failed_move() == False:
|
||||||
if c.soft_link():
|
if c.soft_link():
|
||||||
print("[-]Link {} to failed folder".format(file_path))
|
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:
|
elif c.failed_move() == True:
|
||||||
if c.soft_link():
|
if c.soft_link():
|
||||||
print("[-]Link {} to failed folder".format(file_path))
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
print("[-]Move [{}] to failed folder".format(file_path))
|
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:
|
except Exception as err:
|
||||||
print('[!]', 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():
|
if c.soft_link():
|
||||||
print("[-]Link {} to failed folder".format(file_path))
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
print("[-]Move [{}] to failed folder".format(file_path))
|
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:
|
except Exception as err:
|
||||||
print('[!]', err)
|
print('[!]', err)
|
||||||
|
|
||||||
|
|||||||
8
core.py
8
core.py
@@ -42,10 +42,10 @@ def moveFailedFolder(filepath):
|
|||||||
file_name = os.path.basename(filepath)
|
file_name = os.path.basename(filepath)
|
||||||
if conf.soft_link():
|
if conf.soft_link():
|
||||||
print('[-]Create symlink to Failed output folder')
|
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:
|
else:
|
||||||
print('[-]Move to Failed output folder')
|
print('[-]Move to Failed output folder')
|
||||||
shutil.move(filepath, failed_folder + '/' + file_name)
|
shutil.move(filepath, os.path.join(failed_folder, file_name))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa
|
|||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
return
|
return
|
||||||
with open(str(path) + "/" + filename, "wb") as code:
|
with open(os.path.join(str(path), filename), "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r.content)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -379,7 +379,7 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa
|
|||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
return
|
return
|
||||||
with open(str(path) + "/" + filename, "wb") as code:
|
with open(os.path.join(str(path), filename), "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r.content)
|
||||||
return
|
return
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
|
|||||||
Reference in New Issue
Block a user