0
我試圖從我下載的gpg文件中解密一些數據。將文件下載到目錄是沒有問題的,但我實際上在解密它們時遇到麻煩。下面是我在做什麼現在:使用gnupg解密gpg文件
def extractGPGs(gpglist,path,gpgPath="\"C:\\Program Files\\GNU\\GnuPG\\gpg.exe\""):
os.chdir(path)
if not os.path.isdir("GPGFiles"):
os.mkdir("GPGFiles")
if not os.path.isdir("OtherFiles"):
os.mkdir("OtherFiles")
if gpglist == None:
print "No GPG files found"
return
try:
gpg = gnupg.GPG(gpgbinary=gpgPath)
except:
raise "Path to gpg.exe is bad"
print "Extracting GPG Files..."
for filename in gpglist:
print "Extracting %s..." % filename
stream = open(filename,"rb")
decrypted_data = gpg.decrypt_file(stream,output=".\\OtherFiles")
stream.close()
print "Finished Extracting GPG Files"
這裏就是我得到的錯誤:
Traceback (most recent call last):
File "C:\Documents and Settings\nlesniewski\Desktop\downloadData.py", line 281, in <module>
main(vendor,category)
File "C:\Documents and Settings\nlesniewski\Desktop\downloadData.py", line 273, in main
extractAndParse.main(info['LocalFolder'])
File "C:\Documents and Settings\nlesniewski\Desktop\extractAndParse.py", line 147, in main
extractGPGs(getGPGs(getAllArchives(path)),path)
File "C:\Documents and Settings\nlesniewski\Desktop\extractAndParse.py", line 133, in extractGPGs
decrypted_data = gpg.decrypt_file(stream,output=".\\OtherFiles")
File "C:\Python25\Lib\site-packages\gnupg.py", line 574, in decrypt_file
os.remove(output) # to avoid overwrite confirmation message
WindowsError: [Error 5] Access is denied: '.\\OtherFiles'
爲什麼會出現這個錯誤,而且,更重要的是,我怎麼能解密gpg的?