aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/management/commands/lsupdates.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-08-01 19:38:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-11 00:09:25 +0100
commit49039829e1968418e903e5c0fda9bbbd8629f4db (patch)
tree89e61a8a649611a0ddd38cb9515356aa52697cd6 /bitbake/lib/toaster/orm/management/commands/lsupdates.py
parent33a4006529ca0e463f1e1fc95daef973a6facd3f (diff)
downloadopenembedded-core-contrib-49039829e1968418e903e5c0fda9bbbd8629f4db.tar.gz
bitbake: toaster: lsupdates Add spinner for parsing/http fetch
Adds a spinner so that you know that the parse and http fetch from the layerindex is in progress. (Bitbake rev: e1c1c8827f3892551084bf1c0909c1b33f0dca83) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/management/commands/lsupdates.py')
-rw-r--r--bitbake/lib/toaster/orm/management/commands/lsupdates.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
index be63a85859..89817c8cf1 100644
--- a/bitbake/lib/toaster/orm/management/commands/lsupdates.py
+++ b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
@@ -29,11 +29,33 @@ import sys
import json
import logging
+import threading
+import time
logger = logging.getLogger("toaster")
DEFAULT_LAYERINDEX_SERVER = "http://layers.openembedded.org/layerindex/api/"
+class Spinner(threading.Thread):
+ """ A simple progress spinner to indicate download/parsing is happening"""
+ def __init__(self, *args, **kwargs):
+ super(Spinner, self).__init__(*args, **kwargs)
+ self.setDaemon(True)
+ self.signal = True
+
+ def run(self):
+ os.system('setterm -cursor off')
+ while self.signal:
+ for char in ["/", "-", "\\", "|"]:
+ sys.stdout.write("\r" + char)
+ sys.stdout.flush()
+ time.sleep(0.25)
+ os.system('setterm -cursor on')
+
+ def stop(self):
+ self.signal = False
+
+
class Command(NoArgsCommand):
args = ""
help = "Updates locally cached information from a layerindex server"
@@ -55,6 +77,7 @@ class Command(NoArgsCommand):
Fetches layer, recipe and machine information from a layerindex
server
"""
+ os.system('setterm -cursor off')
self.apiurl = DEFAULT_LAYERINDEX_SERVER
@@ -70,6 +93,9 @@ class Command(NoArgsCommand):
oe_core_layer = 'openembedded-core'
def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER):
+ http_progress = Spinner()
+ http_progress.start()
+
_parsedurl = urlparse(apiurl)
path = _parsedurl.path
@@ -79,7 +105,10 @@ class Command(NoArgsCommand):
except URLError as e:
raise Exception("Failed to read %s: %s" % (path, e.reason))
- return json.loads(res.read().decode('utf-8'))
+ parsed = json.loads(res.read().decode('utf-8'))
+
+ http_progress.stop()
+ return parsed
# verify we can get the basic api
try:
@@ -293,5 +322,7 @@ class Command(NoArgsCommand):
self.mini_progress("recipes", i, total)
+ os.system('setterm -cursor on')
+
def handle_noargs(self, **options):
- self.update()
+ self.update()