Created
May 27, 2015 22:34
-
-
Save daktak/33cbbd67f16a32f103e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python2 | |
# | |
# | |
############################################################################## | |
### NZBGET POST-PROCESSING SCRIPT ### | |
# chmod for nzbget | |
# NOTE: This script requires Python to be installed on your system. | |
############################################################################## | |
### OPTIONS ### | |
### NZBGET POST-PROCESSING SCRIPT ### | |
############################################################################## | |
import os | |
import stat | |
import sys | |
# Exit codes used by NZBGet | |
POSTPROCESS_SUCCESS=93 | |
POSTPROCESS_ERROR=94 | |
# Check if the script is called from nzbget 11.0 or later | |
if not 'NZBOP_SCRIPTDIR' in os.environ: | |
print('*** NZBGet post-processing script ***') | |
print('This script is supposed to be called from nzbget (11.0 or later).') | |
sys.exit(POSTPROCESS_ERROR) | |
for dirname, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): | |
st = os.stat(dirname) | |
os.chmod(dirname, st.st_mode | stat.S_IRWXG | stat.S_IRWXO) | |
print dirname | |
for filename in filenames: | |
st = os.stat(os.path.join(dirname, filename)) | |
os.chmod(os.path.join(dirname, filename), st.st_mode | stat.S_IRWXG | stat.S_IRWXO) | |
# All OK, returning exit status 'POSTPROCESS_SUCCESS' (int <93>) to let NZBGet know | |
# that our script has successfully completed. | |
sys.exit(POSTPROCESS_SUCCESS) |
If executed by a user that can do so, yes. However this script would be executed by nzbget, on files saved by nzbget.
Thanks, that is exactly what I need
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will this work on Windows to change file read only attribute?