0

I have a simple script to pull the latest version of a file down to a local machine. Here's a snippet of the code that is failing.

....
d = "D:\\" + youngest[2]
if os.path.exists(d):
    shutil.rmtree(d)
os.mkdir(d)
os.chmod(d, stat.S_IWRITE)
shutil.copyfile(youngest[1] + "/EXE/FILE.EXE", d)
....

The error I'm getting is:

PermissionError: [Errno 13] Permission denied: 'D:\23.5.2.224'

After googling, it seems that os.chmod() is my ticket to changing permissions of this folder. What am I doing wrong?

MrDysprosium
  • 489
  • 9
  • 20

1 Answers1

0

I’m assuming your on windows because of the D drive. Chmod on windows doesn’t work like it would on a Linux OS. Check out this post Chmod issue to change file permission using python they explain a module that can help with setting windows permissions

mep
  • 431
  • 1
  • 4
  • 15
  • Yeah, I saw that. Though I'm not sure how to apply that to a folder. – MrDysprosium Sep 27 '17 at 17:13
  • https://stackoverflow.com/a/12168268/7770917 try out this. He uses the win32 module to set folder permissions – mep Sep 27 '17 at 17:15
  • interesting, I can't pip install win32/pywin32/win32security – MrDysprosium Sep 27 '17 at 17:17
  • `Could not find a version that satisfies the requirement pywin32 (from versions: )` `No matching distribution found for pywin32` I'm assuming these don't exist for python3.6 – MrDysprosium Sep 27 '17 at 17:20
  • It may support up to python 3.3 the sourceforge is down right now I can’t confirm. Make sure the win32 and python are both either 64 bit or 32bit. If that doesn’t work this module may only work python 3.3 and below but that seems odd to me – mep Sep 27 '17 at 17:27