2010-07-26 3 views
0

Я пытаюсь расшифровать некоторые данные из загруженных файлов gpg. Загрузка файлов в каталог не проблема, но у меня проблемы с их расшифровкой. Вот что я делаю прямо сейчас:Расшифровка файла gpg с помощью gnupg

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?

ответ

2

Возможно, вам нужен вывод как имя файла вместо каталога.

Смежные вопросы