Browse Source

until gnupg.own_keys()

master
Volker Birk 2 years ago
parent
commit
53c8805d0e
4 changed files with 54 additions and 20 deletions
  1. +43
    -0
      gnupg.py
  2. +6
    -16
      pEp_import.py
  3. +4
    -4
      thunderbird.py
  4. +1
    -0
      unix.py

+ 43
- 0
gnupg.py View File

@ -0,0 +1,43 @@
# coding=UTF-8
import sys
import fileinput
from subprocess import Popen, PIPE
if sys.platform == 'darwin':
from platform_macOS import *
elif sys.platform == 'win32':
from platform_Windows import *
elif sys.platform == 'linux':
from platform_Linux import *
else:
sys.stderr.write("platform not supported\n")
sys.exit(1)
gpg = gpg_executable(thunderbird_base)
def command(*args):
result = []
cmd = [gpg, '--with-colons']
cmd.extend(args)
for line in Popen(cmd, stdout=PIPE).stdout:
data = line.split(':')
result.append(data)
return result
def fpr_from_keyid(keyid):
for x in command('--fingerprint', 'A9E44CABD4F2EF04'):
if x[0] == 'fpr':
return x[9]
raise LookupError()
def own_keys():
return [ fpr_from_keyid(x[4]) for x in command('-K') if x[0] == 'sec' and x[1] == 'u' ]

+ 6
- 16
pEp_import.py View File

@ -1,22 +1,12 @@
#!/usr/bin/python
# coding=UTF-8
# macOS only supports Python 2.7
import sys
if sys.platform == 'darwin':
from platform_macOS import *
elif sys.platform == 'win32':
from platform_Windows import *
elif sys.platform == 'linux':
from platform_Linux import *
else:
sys.stderr.write("platform not supported\n")
sys.exit(1)
import sys
import gnupg
gpg = gpg_executable(thunderbird_base)
print(gpg)
own_keys = gnupg.own_keys()
print own_keys

+ 4
- 4
thunderbird.py View File

@ -9,11 +9,11 @@ class ThunderbirdNotFound(LookupError):
def profile_path(thunderbird_base):
from configparser import ConfigParser
config = ConfigParser()
from ConfigParser import SafeConfigParser
config = SafeConfigParser()
filename = os.path.join(thunderbird_base, 'profiles.ini')
config.read(filename)
for section in config:
for section in config.sections():
try:
if config.get(section, 'Name') == 'default-release':
return os.path.join(thunderbird_base, config.get(section, 'Path'))
@ -24,7 +24,7 @@ def profile_path(thunderbird_base):
def enigmail_agentPath(thunderbird_base):
from fileinput import input
import re
c = re.compile(r'user_pref\(["\']extensions\.enigmail\.agentPath["\'],\s*["\'](?P<path>[^"\']*)["\']\);')
c = re.compile(r'user_pref\(["\']extensions\.enigmail\.agentPath["\'],\s*["\'](?P<path>[^"\']*)["\']\);', re.UNICODE)
filename = os.path.join(profile_path(thunderbird_base), 'prefs.js')
for line in input(files=(filename,)):
m = c.search(line)


+ 1
- 0
unix.py View File

@ -13,3 +13,4 @@ def gpg_executable(thunderbird_base):
raise GnuPGNotFound()
else:
return gpg

Loading…
Cancel
Save