if not os.path.exists('/var/log/'):
os.makedirs('/var/log/')
print(log_filepath)
os.chmod(log_filepath, stat.S_IWOTH)
f_log_in = open(log_filepath, "a")
Without the chmod command, it will throw an error saying permission denied for the f_log_in file open command.
f_log_in = open(log_filepath, "a")
PermissionError: [Errno 13] Permission denied: '/var/log/s3_sync.log'
When I include the os.chmod command, it says:
os.chmod(log_filepath, stat.S_IWOTH)
FileNotFoundError: [Errno 2] No such file or directory: '/var/log/s3_sync.log'
Are there any other ways of approaching this?
EDIT: THIS IS NOT A DUPLICATE, I DELETED THE OTHER ONE.