0

I have been trying to follow this post Changing file permission in python to change the permissions of the directory and folder being generated by my python code. However I am still getting an error IOError: [Errno 13] Permission denied:

absPath = createFolder + "/" + collectionInterval
print absPath
if not os.path.exists(absPath):
    os.system("sudo mkdir " + absPath)
    os.chmod(absPath, stat.S_IRWXO | stat.S_IRWXU | stat.S_IRWXG)

scriptName = ipAddress.replace(".", "")

#create script file and save it in that location
#need to replace "name" with a distinguishable name
saveFile = absPath + "/" + scriptName + "_" + script["datasourceID"] + "_" + script["datapointID"] + ".py"
print saveFile
with open(saveFile, "w") as script_file:
    os.chmod(saveFile, stat.S_IRWXO | stat.S_IRWXU | stat.S_IRWXG)
    script_file.write(script)
Community
  • 1
  • 1
Johnathon64
  • 1,280
  • 1
  • 20
  • 45

0 Answers0