fix ./ctl release

This commit is contained in:
j 2015-02-27 18:46:50 +05:30
parent ec6765f325
commit 0ec527dd02
2 changed files with 6 additions and 7 deletions

View file

@ -124,8 +124,7 @@ def command_release(*args):
import ed25519 import ed25519
os.chdir(root_dir) os.chdir(root_dir)
with open(os.path.expanduser('~/.openmedialibrary_release.key'), 'rb') as fd:
with open(os.path.expanduser('~/.openmedialibrary_release.key')) as fd:
SIG_KEY=ed25519.SigningKey(fd.read()) SIG_KEY=ed25519.SigningKey(fd.read())
SIG_ENCODING='base64' SIG_ENCODING='base64'
@ -134,13 +133,13 @@ def command_release(*args):
for module in sorted(release['modules']): for module in sorted(release['modules']):
value += ['%s/%s' % (release['modules'][module]['version'], release['modules'][module]['sha1'])] value += ['%s/%s' % (release['modules'][module]['version'], release['modules'][module]['sha1'])]
value = '\n'.join(value) value = '\n'.join(value)
sig = SIG_KEY.sign(value, encoding=SIG_ENCODING) sig = SIG_KEY.sign(value.encode(), encoding=SIG_ENCODING).decode()
release['signature'] = sig release['signature'] = sig
def sha1sum(path): def sha1sum(path):
h = hashlib.sha1() h = hashlib.sha1()
with open(path) as fd: with open(path, 'rb') as fd:
for chunk in iter(lambda: fd.read(128*h.block_size), ''): for chunk in iter(lambda: fd.read(128*h.block_size), b''):
h.update(chunk) h.update(chunk)
return h.hexdigest() return h.hexdigest()
@ -171,7 +170,7 @@ def command_release(*args):
} for module in MODULES} } for module in MODULES}
sign(release) sign(release)
with open('updates/release.json', 'w') as fd: with open('updates/release.json', 'w') as fd:
json.dump(release, fd, indent=2) json.dump(release, fd, indent=2, sort_keys=True)
print('signed latest release in updates/release.json') print('signed latest release in updates/release.json')
def command_shell(*args): def command_shell(*args):

View file

@ -165,6 +165,6 @@ def restart(data):
''' '''
restart (and upgrade if upgrades are available) restart (and upgrade if upgrades are available)
''' '''
subprocess.Popen(['./ctl', 'restart'], close_fds=True) subprocess.Popen([os.path.join(settings.base_dir, 'ctl'), 'restart'], close_fds=True)
return {} return {}
actions.register(restart, cache=False) actions.register(restart, cache=False)