Mercurial > p > roundup > code
comparison test/gpgmelib.py @ 5494:b7fa56ced601
use gpg module instead of pyme module for PGP encryption
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Sun, 12 Aug 2018 16:17:14 +0100 |
| parents | dad18ee491a9 |
| children | 63006478546c |
comparison
equal
deleted
inserted
replaced
| 5493:725266c03eab | 5494:b7fa56ced601 |
|---|---|
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 11 | 11 |
| 12 import shutil, os | 12 import shutil, os |
| 13 try: | 13 try: |
| 14 import pyme, pyme.core | 14 import gpg, gpg.core |
| 15 except ImportError: | 15 except ImportError: |
| 16 pyme = None | 16 gpg = None |
| 17 | 17 |
| 18 pgp_test_key = """ | 18 pgp_test_key = """ |
| 19 -----BEGIN PGP PRIVATE KEY BLOCK----- | 19 -----BEGIN PGP PRIVATE KEY BLOCK----- |
| 20 Version: GnuPG v1.4.10 (GNU/Linux) | 20 Version: GnuPG v1.4.10 (GNU/Linux) |
| 21 | 21 |
| 123 shutil.rmtree(pgphome) | 123 shutil.rmtree(pgphome) |
| 124 os.mkdir(pgphome) | 124 os.mkdir(pgphome) |
| 125 os.environ['GNUPGHOME'] = pgphome | 125 os.environ['GNUPGHOME'] = pgphome |
| 126 # gpgme_check_version() must have been called once in a programm | 126 # gpgme_check_version() must have been called once in a programm |
| 127 # to initialise some subsystems of gpgme. See roundup/roundupdb.py. | 127 # to initialise some subsystems of gpgme. See roundup/roundupdb.py. |
| 128 ctx = pyme.core.Context() | 128 ctx = gpg.core.Context() |
| 129 key = pyme.core.Data(pgp_test_key) | 129 key = gpg.core.Data(pgp_test_key) |
| 130 ctx.op_import(key) | 130 ctx.op_import(key) |
| 131 key = pyme.core.Data(john_doe_key) | 131 key = gpg.core.Data(john_doe_key) |
| 132 ctx.op_import(key) | 132 ctx.op_import(key) |
| 133 # trust-modelling with pyme isn't working in 0.8.1 | 133 # trust-modelling with pyme isn't working in 0.8.1 |
| 134 # based on libgpgme11 1.2.0, also tried in C -- same thing. | 134 # based on libgpgme11 1.2.0, also tried in C -- same thing. |
| 135 otrust = os.popen ('gpg --import-ownertrust 2> /dev/null', 'w') | 135 otrust = os.popen ('gpg --import-ownertrust 2> /dev/null', 'w') |
| 136 otrust.write(ownertrust) | 136 otrust.write(ownertrust) |
