Display a message when interactively syncing
When a foreground sync is happening (because of a search for a specific change number, including via "gertty --open") display a message telling the user what's going on. Change-Id: I4c12c73ec92cba8a8b3f3d69f036d1442323787e
This commit is contained in:
parent
714a8c8986
commit
5232cbd805
@ -398,11 +398,16 @@ class App(object):
|
||||
|
||||
def popup(self, widget,
|
||||
relative_width=50, relative_height=25,
|
||||
min_width=20, min_height=8):
|
||||
min_width=20, min_height=8,
|
||||
width=None, height=None):
|
||||
self.clearInputBuffer()
|
||||
if width is None:
|
||||
width = ('relative', relative_width)
|
||||
if height is None:
|
||||
height = ('relative', relative_height)
|
||||
overlay = urwid.Overlay(widget, self.loop.widget,
|
||||
'center', ('relative', relative_width),
|
||||
'middle', ('relative', relative_height),
|
||||
'center', width,
|
||||
'middle', height,
|
||||
min_width=min_width, min_height=min_height)
|
||||
self.log.debug("Overlaying %s on screen %s" % (widget, self.loop.widget))
|
||||
self.screens.append(self.loop.widget)
|
||||
@ -464,15 +469,22 @@ class App(object):
|
||||
if change_key is None:
|
||||
if self.sync.offline:
|
||||
raise Exception('Can not sync change while offline.')
|
||||
task = sync.SyncChangeByNumberTask(number or changeid, sync.HIGH_PRIORITY)
|
||||
self.sync.submitTask(task)
|
||||
succeeded = task.wait(300)
|
||||
if not succeeded:
|
||||
raise Exception('Unable to find change.')
|
||||
for subtask in task.tasks:
|
||||
succeeded = subtask.wait(300)
|
||||
dialog = mywid.SystemMessage("Syncing change...")
|
||||
self.popup(dialog, width=40, height=6)
|
||||
self.loop.draw_screen()
|
||||
try:
|
||||
task = sync.SyncChangeByNumberTask(number or changeid, sync.HIGH_PRIORITY)
|
||||
self.sync.submitTask(task)
|
||||
succeeded = task.wait(300)
|
||||
if not succeeded:
|
||||
raise Exception('Unable to sync change.')
|
||||
raise Exception('Unable to find change.')
|
||||
for subtask in task.tasks:
|
||||
succeeded = subtask.wait(300)
|
||||
if not succeeded:
|
||||
raise Exception('Unable to sync change.')
|
||||
finally:
|
||||
# Remove "syncing..." popup
|
||||
self.backScreen()
|
||||
with self.db.getSession() as session:
|
||||
if number:
|
||||
change = session.getChangeByNumber(number)
|
||||
|
@ -128,6 +128,11 @@ class MyEdit(urwid.Edit):
|
||||
self.ring.kill(text)
|
||||
return super(MyEdit, self).keypress(size, key)
|
||||
|
||||
class SystemMessage(urwid.WidgetWrap):
|
||||
def __init__(self, message):
|
||||
w = urwid.Filler(urwid.Text(message, align='center'))
|
||||
super(SystemMessage, self).__init__(urwid.LineBox(w))
|
||||
|
||||
@mouse_scroll_decorator.ScrollByWheel
|
||||
class ButtonDialog(urwid.WidgetWrap):
|
||||
def __init__(self, title, message, entry_prompt=None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user