diff options
-rw-r--r-- | bitbake/lib/toaster/orm/management/commands/lsupdates.py | 35 |
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 | ||
30 | import json | 30 | import json |
31 | import logging | 31 | import logging |
32 | import threading | ||
33 | import time | ||
32 | logger = logging.getLogger("toaster") | 34 | logger = logging.getLogger("toaster") |
33 | 35 | ||
34 | DEFAULT_LAYERINDEX_SERVER = "http://layers.openembedded.org/layerindex/api/" | 36 | DEFAULT_LAYERINDEX_SERVER = "http://layers.openembedded.org/layerindex/api/" |
35 | 37 | ||
36 | 38 | ||
39 | class 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 | |||
37 | class Command(NoArgsCommand): | 59 | class 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() |