[Tutor] Help with python-gnupg

Becky Mcquilling ladymcse2000 at gmail.com
Sat Mar 12 07:39:39 CET 2011


If anyone is familiar with python-gnupg, I am having some difficulty with
the syntax.  I've tried the following:

f = open('c:/test/filename.txt', 'r')
datae = gpg.encrypt_file(f.read(), 'ladymcse at gmail.com',
output=open('c:/gpg_test/data.gpg2', 'w'))

or
file_to_encrypt = open('c:/gpg_test/data.gpg2', 'w')
datae = gpg(f.read(), 'ladymcse at gmail.com', output=file_to_encrypt)

Either way, I can't get the output written to a file, it gives me an error:

Traceback (most recent call last):
  File "<pyshell#65>", line 1, in <module>
    datae = gpg.encrypt_file(f.read(), 'beckymcq at google.com',
output=open('c:/test/data.gpg2', 'w'))
  File "C:\Python27\lib\site-packages\gnupg.py", line 583, in encrypt_file
    if os.path.exists(output):
  File "C:\Python27\lib\genericpath.py", line 18, in exists
    os.stat(path)
TypeError: coercing to Unicode: need string or buffer, file found

Any thoughts?  Would reallly appreciate the help.

If you aren't familiar with this and know of resources, it would be awesome.


Becky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110311/f5cc8a21/attachment.html>


More information about the Tutor mailing list