mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Refactor rchmod to utils.paths.rchmod
This commit is contained in:
parent
aa057e65d5
commit
d960c432eb
3 changed files with 35 additions and 17 deletions
|
@ -46,10 +46,27 @@ from six.moves import reload_module
|
||||||
from core import logger, main_db, version_check, databases, transcoder
|
from core import logger, main_db, version_check, databases, transcoder
|
||||||
from core.configuration import config
|
from core.configuration import config
|
||||||
from core.utils import (
|
from core.utils import (
|
||||||
RunningProcess, wake_up, category_search, clean_dir, clean_dir, copy_link,
|
RunningProcess,
|
||||||
create_torrent_class, extract_files, flatten, get_dirs, get_download_info,
|
category_search,
|
||||||
list_media_files, make_dir, parse_args, pause_torrent, remove_torrent,
|
clean_dir,
|
||||||
resume_torrent, remove_dir, remove_read_only, sanitize_name, update_download_info_status,
|
copy_link,
|
||||||
|
create_torrent_class,
|
||||||
|
extract_files,
|
||||||
|
flatten,
|
||||||
|
get_dirs,
|
||||||
|
get_download_info,
|
||||||
|
list_media_files,
|
||||||
|
make_dir,
|
||||||
|
parse_args,
|
||||||
|
pause_torrent,
|
||||||
|
rchmod,
|
||||||
|
remove_dir,
|
||||||
|
remove_read_only,
|
||||||
|
remove_torrent,
|
||||||
|
resume_torrent,
|
||||||
|
sanitize_name,
|
||||||
|
update_download_info_status,
|
||||||
|
wake_up,
|
||||||
)
|
)
|
||||||
|
|
||||||
__version__ = '12.0.6'
|
__version__ = '12.0.6'
|
||||||
|
@ -866,16 +883,3 @@ def restart():
|
||||||
status = p.returncode
|
status = p.returncode
|
||||||
|
|
||||||
os._exit(status)
|
os._exit(status)
|
||||||
|
|
||||||
|
|
||||||
def rchmod(path, mod):
|
|
||||||
logger.log('Changing file mode of {0} to {1}'.format(path, oct(mod)))
|
|
||||||
os.chmod(path, mod)
|
|
||||||
if not os.path.isdir(path):
|
|
||||||
return # Skip files
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(path):
|
|
||||||
for d in dirs:
|
|
||||||
os.chmod(os.path.join(root, d), mod)
|
|
||||||
for f in files:
|
|
||||||
os.chmod(os.path.join(root, f), mod)
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ from core.utils.paths import (
|
||||||
get_dir_size,
|
get_dir_size,
|
||||||
make_dir,
|
make_dir,
|
||||||
onerror,
|
onerror,
|
||||||
|
rchmod,
|
||||||
remote_dir,
|
remote_dir,
|
||||||
remove_dir,
|
remove_dir,
|
||||||
remove_empty_folders,
|
remove_empty_folders,
|
||||||
|
|
|
@ -149,3 +149,16 @@ def clean_directory(path, files):
|
||||||
shutil.rmtree(path, onerror=onerror)
|
shutil.rmtree(path, onerror=onerror)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error('Unable to delete directory {0}'.format(path))
|
logger.error('Unable to delete directory {0}'.format(path))
|
||||||
|
|
||||||
|
|
||||||
|
def rchmod(path, mod):
|
||||||
|
logger.log('Changing file mode of {0} to {1}'.format(path, oct(mod)))
|
||||||
|
os.chmod(path, mod)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
return # Skip files
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(path):
|
||||||
|
for d in dirs:
|
||||||
|
os.chmod(os.path.join(root, d), mod)
|
||||||
|
for f in files:
|
||||||
|
os.chmod(os.path.join(root, f), mod)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue