summaryrefslogtreecommitdiffstats
path: root/bitbake
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
parent33a4006529ca0e463f1e1fc95daef973a6facd3f (diff)
downloadpoky-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')
-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
29 29
30import json 30import json
31import logging 31import logging
32import threading
33import time
32logger = logging.getLogger("toaster") 34logger = logging.getLogger("toaster")
33 35
34DEFAULT_LAYERINDEX_SERVER = "http://layers.openembedded.org/layerindex/api/" 36DEFAULT_LAYERINDEX_SERVER = "http://layers.openembedded.org/layerindex/api/"
35 37
36 38
39class Spinner(threading.Thread):
40 """ A simple progress spinner to indicate download/parsing is happening"""
41 def __init__(self, *args, **kwargs):
42 super(Spinner, self).__init__(*args, **kwargs)
43 self.setDaemon(True)
44 self.signal = True
45
46 def run(self):
47 os.system('setterm -cursor off')
48 while self.signal:
49 for char in ["/", "-", "\\", "|"]:
50 sys.stdout.write("\r" + char)
51 sys.stdout.flush()
52 time.sleep(0.25)
53 os.system('setterm -cursor on')
54
55 def stop(self):
56 self.signal = False
57
58
37class Command(NoArgsCommand): 59class Command(NoArgsCommand):
38 args = "" 60 args = ""
39 help = "Updates locally cached information from a layerindex server" 61 help = "Updates locally cached information from a layerindex server"
@@ -55,6 +77,7 @@ class Command(NoArgsCommand):
55 Fetches layer, recipe and machine information from a layerindex 77 Fetches layer, recipe and machine information from a layerindex
56 server 78 server
57 """ 79 """
80 os.system('setterm -cursor off')
58 81
59 self.apiurl = DEFAULT_LAYERINDEX_SERVER 82 self.apiurl = DEFAULT_LAYERINDEX_SERVER
60 83
@@ -70,6 +93,9 @@ class Command(NoArgsCommand):
70 oe_core_layer = 'openembedded-core' 93 oe_core_layer = 'openembedded-core'
71 94
72 def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER): 95 def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER):
96 http_progress = Spinner()
97 http_progress.start()
98
73 _parsedurl = urlparse(apiurl) 99 _parsedurl = urlparse(apiurl)
74 path = _parsedurl.path 100 path = _parsedurl.path
75 101
@@ -79,7 +105,10 @@ class Command(NoArgsCommand):
79 except URLError as e: 105 except URLError as e:
80 raise Exception("Failed to read %s: %s" % (path, e.reason)) 106 raise Exception("Failed to read %s: %s" % (path, e.reason))
81 107
82 return json.loads(res.read().decode('utf-8')) 108 parsed = json.loads(res.read().decode('utf-8'))
109
110 http_progress.stop()
111 return parsed
83 112
84 # verify we can get the basic api 113 # verify we can get the basic api
85 try: 114 try:
@@ -293,5 +322,7 @@ class Command(NoArgsCommand):
293 322
294 self.mini_progress("recipes", i, total) 323 self.mini_progress("recipes", i, total)
295 324
325 os.system('setterm -cursor on')
326
296 def handle_noargs(self, **options): 327 def handle_noargs(self, **options):
297 self.update() 328 self.update()