Reputation: 405
So I'm currently using a python program a friend wrote in order to quickly run hundreds of files at once. I'm receiving some kind of file permissions error. I've already lowered UAC to lowest and other than that I'm not sure what else it could be, as I've tried multiple directories.
Here's the code:
import os
import fnmatch
import subprocess
matches = []
outputs = []
foutputs = []
for root, dirs, files in os.walk("C:\\Users\\Freeman\\Desktop"):
for files in fnmatch.filter(files, '*.c'):
matches.append(os.path.join(root,files))
outputs.append(os.path.join(root,"a.exe"))
foutputs.append(os.path.join(root,"out.txt"))
for n,m,l in zip(matches, outputs, foutputs):
print n
# Compile
cmd = ['gcc', '-O2', n, '-o', m]
p = subprocess.call(cmd, shell=True)
fin = file("C:\\Users\\Freeman\\Desktop")
# Set up append mode for output
if os.path.exists(l):
os.remove(l)
fout = file(l,"a")
if os.path.exists(m):
# Test multiple cases
p = subprocess.Popen(m, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
fout.write(repr(p.communicate(fin.readline())))
And here's the error I'm receiving:
C:\Users\Freeman\Desktop\Assignment 3\Assignment 3- Abdulrahman Ruaa - 13015067923101\assigh 3.c
^^This is the first user's code thats supposed to run
Traceback (most recent call last):
File "C:\Users\Freeman\Desktop\Assignment 3\test.py", line 20, in <module>
fin = file("C:\\Users\\Freeman\\Desktop")
IOError: [Errno 13] Permission denied: 'C:\\Users\\Freeman\\Desktop'
^^Thats the directory issue, and I've tried different directories as stated to no avail.
Thank you for your consideration.
Regards,
Michael
Upvotes: 0
Views: 658
Reputation: 9587
The problem lies in trying to open a directory with the file
built-in.
You cannot do that.
You seem to have a semantic error in your code, as you are trying to read line-by-line from the user's Desktop
directory.
Upvotes: 1