Skip to content

Commit

Permalink
[Software update] Fine tuned status text.
Browse files Browse the repository at this point in the history
Signed-off by Birdman.

This gives a textual mapping for all possible return states for use by SoftwareUpdate::checkNetworkState() and ChoiceBox::onshow()
Declared here for consistency and co-location with choices.
  • Loading branch information
RobvanderDoes committed Aug 4, 2016
1 parent ffc4e1a commit 7fee5fa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
20 changes: 17 additions & 3 deletions lib/python/Components/OnlineUpdateCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def IsInt(self, val):
except ValueError:
return False

def getFeedSatus(self):
def getFeedStatus(self):
status = '1'
trafficLight = 'unknown'
if about.getIfConfig('eth0').has_key('addr') or about.getIfConfig('eth1').has_key('addr') or about.getIfConfig('wlan0').has_key('addr') or about.getIfConfig('ra0').has_key('addr'):
Expand Down Expand Up @@ -63,12 +63,26 @@ def getFeedSatus(self):
print '[OnlineVersionCheck] ERROR: -2'
return -2

# We need a textual mapping for all possible return states for use by
# SoftwareUpdate::checkNetworkState() and ChoiceBox::onshow()
# Declared here for consistency and co-location with choices.
#
feed_status_msgs = {
'stable': _('Feeds status: Stable'),
'unstable': _('Feeds status: Unstable'),
'updating': _('Feeds status: Updating'),
'-2': _('ERROR: No network found'),
'403': _('ERROR: Forbidden'),
'404': _('ERROR: No internet found'),
'inprogress': _('ERROR: Check is already running in background, please wait a few minutes and try again'),
'unknown': _('Feeds status: Unknown'),
}
def getFeedsBool(self):
global error
feedstatus = feedsstatuscheck.getFeedSatus()
feedstatus = feedsstatuscheck.getFeedStatus()
if feedstatus in (-2, 403, 404):
print '[OnlineVersionCheck] Error %s' % feedstatus
return feedstatus
return str(feedstatus)
elif error:
print '[OnlineVersionCheck] Check already in progress'
return 'inprogress'
Expand Down
8 changes: 4 additions & 4 deletions lib/python/Screens/ChoiceBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ def __init__(self, session, title="", list=None, keys=None, selection=0, skin_na

def onshow(self):
if self.skinName and 'SoftwareUpdateChoices' in self.skinName and self.var:
status_msgs = {'stable': _('Feeds status: Stable'), 'unstable': _('Feeds status: Unstable'), 'updating': _('Feeds status: Updating'), '-2': _('ERROR: No network found'), '404': _('ERROR: No internet found'), 'inprogress': _('ERROR: Check is already running in background, please wait a few minutes and try again'), 'unknown': _('Feeds status: Unknown')}
if self.var in status_msgs:
status_text = status_msgs[self.var]
from Components.OnlineUpdateCheck import feedsstatuscheck
if self.var in feedsstatuscheck.feed_status_msgs:
status_text = feedsstatuscheck.feed_status_msgs[self.var]
else:
status_text = 'Unexpected'
status_text = _('Feeds status: Unexpected')
self['feedStatusMSG'].setText(status_text)
self['tl_off'].hide()
self['tl_red'].hide()
Expand Down
9 changes: 4 additions & 5 deletions lib/python/Screens/SoftwareUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,11 @@ def checkNetworkState(self):
self['tl_yellow'].hide()
self['tl_green'].hide()
self['tl_off'].hide()
self.trafficLight = feedsstatuscheck.getFeedsBool()
status_msgs = {'stable': _('Feeds status: Stable'), 'unstable': _('Feeds status: Unstable'), 'updating': _('Feeds status: Updating'), '-2': _('ERROR: No network found'), '404': _('ERROR: No internet found'), 'inprogress': _('ERROR: Check is already running in background'), 'unknown': _('Feeds status: Unknown')}
if self.trafficLight in status_msgs:
status_text = status_msgs[self.trafficLight]
self.trafficLight = feedsstatuscheck.getFeedsBool()
if self.trafficLight in feedsstatuscheck.feed_status_msgs:
status_text = feedsstatuscheck.feed_status_msgs[self.trafficLight]
else:
status_text = 'Unexpected'
status_text = _('Feeds status: Unexpected')
if self.trafficLight:
self['feedStatusMSG'].setText(status_text)
if self.trafficLight == 'stable':
Expand Down

0 comments on commit 7fee5fa

Please sign in to comment.