only update new modules

This commit is contained in:
j 2014-08-05 11:51:17 +02:00
parent 81e29d1fc2
commit 0ff98f616b

View file

@ -63,18 +63,19 @@ def update():
fd.write(release_data) fd.write(release_data)
os.chdir(settings.base_dir) os.chdir(settings.base_dir)
for module in release['modules']: for module in release['modules']:
package_tar = os.path.join(settings.updates_path, release['modules'][module]['name']) if release['modules'][module]['version'] > settings.release['modules'][module]['version']:
url = RELEASE_URL.replace('release.json', package_tar) package_tar = os.path.join(settings.updates_path, release['modules'][module]['name'])
download(url, package_tar) url = RELEASE_URL.replace('release.json', package_tar)
if ox.sha1sum(package_tar) == release['modules'][module]['sha1']: download(url, package_tar)
shutil.move(module, '%s_old' % module) if ox.sha1sum(package_tar) == release['modules'][module]['sha1']:
tar = tarfile.open(package_tar) shutil.move(module, '%s_old' % module)
tar.extractall() tar = tarfile.open(package_tar)
tar.close() tar.extractall()
shutil.rmtree('%s_old' % module) tar.close()
else: shutil.rmtree('%s_old' % module)
return False else:
os.unlink(package_tar) return False
os.unlink(package_tar)
with open(os.path.join(settings.config_dir, 'release.json'), 'w') as fd: with open(os.path.join(settings.config_dir, 'release.json'), 'w') as fd:
fd.write(release_data) fd.write(release_data)
cmd = ['./ctl', 'stop'] cmd = ['./ctl', 'stop']