I am trying to decrypt a tar file with GnuPG through a Python script on Win7.
filename_e_archive = askopenfilename()
current_directory = os.path.abspath('.')
folder_d_archive = filename_e_archive.split('.elog')[0]
filename_d_archive = folder_d_archive + ".tar.gz"
path_to_e_archive = os.path.dirname(filename_e_archive)
path_to_d_archive = os.path.join(path_to_e_archive,'/',folder_d_archive)
os.makedirs(path_to_d_archive)
os.chdir(path_to_d_archive)
gpg = gnupg.GPG()
with open(filename_e_archive, 'rb') as f:
status = gpg.decrypt_file(f, passphrase='mypassword',output=filename_d_archive)
When run I got the following error:
C:\LA>python test.py Traceback (most recent call last): File "test.py", line 30, in gpg = gnupg.GPG() File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 125, in init ignore_homedir_permissions=ignore_homedir_permissions, File "C:\Python27\lib\site-packages\gnupg_meta.py", line 183, in init self.homedir = os.path.expanduser(home) if home else _util._conf File "C:\Python27\lib\site-packages\gnupg_util.py", line 765, in set getattr(obj, self.fset.name)(value) File "C:\Python27\lib\site-packages\gnupg_meta.py", line 440, in _homedir_set ter raise RuntimeError(str(ae)) RuntimeError: Homedir ''C:\LA\gnupghome.config\python-gnupg'' needs read/write permissions
C:\LA>