Skip to content

Commit a25c215

Browse files
authored
fix crash on empty/new config file
fix crash on empty/new config file caused by import-time unavailability of config registry (due to ordering). so move the code to runtime.
1 parent aa8213b commit a25c215

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pythonbits/api_utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33

44
from .config import config
55

6-
seed = config.get('Tracker', 'domain').encode('utf8')
7-
test = sha224(seed).hexdigest()
8-
if not test.endswith('f280f') and not test.endswith('5abc3'):
9-
raise Exception('Wrong domain! Manually fix {}'.format(config.config_path))
10-
psk = sha256(seed).hexdigest()
116

7+
def get_psk():
8+
seed = config.get('Tracker', 'domain').encode('utf8')
9+
test = sha224(seed).hexdigest()
10+
if not test.endswith('f280f') and not test.endswith('5abc3'):
11+
raise Exception('Wrong domain! '
12+
'Manually fix {}'.format(config.config_path))
13+
return sha256(seed).hexdigest()
1214

1315
def d(a):
16+
psk = get_psk()
1417
return "".join([chr(ord(a[i]) ^ ord(psk[i])) for i in range(len(a))])

0 commit comments

Comments
 (0)