misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
c72cb5b962
commit
63568f1725
@ -62,8 +62,7 @@ def check(version, repo, native=True):
|
|||||||
def install(display, update):
|
def install(display, update):
|
||||||
name = update['repo'].split('/')[1]
|
name = update['repo'].split('/')[1]
|
||||||
|
|
||||||
display.set('status', 'Downloading %s ...' % name)
|
display.update(force=True, new_data={'status': 'Downloading %s ...' % name})
|
||||||
display.update(force=True)
|
|
||||||
|
|
||||||
path = os.path.join("/tmp/updates/", name)
|
path = os.path.join("/tmp/updates/", name)
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
@ -81,8 +80,7 @@ def install(display, update):
|
|||||||
|
|
||||||
logging.info("[update] extracting %s to %s ..." % (target_path, path))
|
logging.info("[update] extracting %s to %s ..." % (target_path, path))
|
||||||
|
|
||||||
display.set('status', 'Extracting %s ...' % name)
|
display.update(force=True, new_data={'status': 'Extracting %s ...' % name})
|
||||||
display.update(force=True)
|
|
||||||
|
|
||||||
os.system('unzip "%s" -d "%s"' % (target_path, path))
|
os.system('unzip "%s" -d "%s"' % (target_path, path))
|
||||||
|
|
||||||
@ -92,6 +90,8 @@ def install(display, update):
|
|||||||
logging.warning("native update without SHA256 checksum file")
|
logging.warning("native update without SHA256 checksum file")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
display.update(force=True, new_data={'status': 'Verifying %s ...' % name})
|
||||||
|
|
||||||
binary_path = os.path.join(path, name)
|
binary_path = os.path.join(path, name)
|
||||||
checksum = checksums[0]
|
checksum = checksums[0]
|
||||||
|
|
||||||
@ -106,6 +106,8 @@ def install(display, update):
|
|||||||
logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (binary_path, expected, real))
|
logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (binary_path, expected, real))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
display.update(force=True, new_data={'status': 'Installing %s ...' % name})
|
||||||
|
|
||||||
if update['native']:
|
if update['native']:
|
||||||
dest_path = subprocess.getoutput("which %s" % name)
|
dest_path = subprocess.getoutput("which %s" % name)
|
||||||
logging.info("[update] installing %s to %s ... TODO" % (binary_path, dest_path))
|
logging.info("[update] installing %s to %s ... TODO" % (binary_path, dest_path))
|
||||||
@ -130,8 +132,7 @@ def on_internet_available(agent):
|
|||||||
prev_status = display.get('status')
|
prev_status = display.get('status')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
display.set('status', 'Checking for updates ...')
|
display.update(force=True, new_data={'status': 'Checking for updates ...'})
|
||||||
display.update(force=True)
|
|
||||||
|
|
||||||
to_install = []
|
to_install = []
|
||||||
to_check = [
|
to_check = [
|
||||||
@ -164,5 +165,4 @@ def on_internet_available(agent):
|
|||||||
logging.error("[update] %s" % e)
|
logging.error("[update] %s" % e)
|
||||||
|
|
||||||
logging.debug("[update] setting status '%s'" % prev_status)
|
logging.debug("[update] setting status '%s'" % prev_status)
|
||||||
display.set('status', prev_status if prev_status is not None else '')
|
display.update(force=True, new_data={'status': prev_status if prev_status is not None else ''})
|
||||||
display.update(force=True)
|
|
||||||
|
@ -310,7 +310,10 @@ class View(object):
|
|||||||
self.set('status', self._voice.custom(text))
|
self.set('status', self._voice.custom(text))
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def update(self, force=False):
|
def update(self, force=False, new_data={}):
|
||||||
|
for key, val in new_data.items():
|
||||||
|
self.set(key, val)
|
||||||
|
|
||||||
with self._lock:
|
with self._lock:
|
||||||
if self._frozen:
|
if self._frozen:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user