refinements in output of sugar-control
This commit is contained in:
parent
a579adef44
commit
70079de872
@ -19,6 +19,7 @@
|
||||
|
||||
import sys
|
||||
import getopt
|
||||
from gettext import gettext as _
|
||||
|
||||
from sugar import env
|
||||
|
||||
@ -27,18 +28,19 @@ sys.path.insert(0, env.get_shell_path())
|
||||
from controlpanel import control
|
||||
|
||||
def cmd_help():
|
||||
print 'Usage: sugar-control [ option ] key [ args ... ] \n\
|
||||
print _('Usage: sugar-control-panel [ option ] key [ args ... ] \n\
|
||||
Control for the sugar environment. \n\
|
||||
Options: \n\
|
||||
-h, --help show this help message and exit \n\
|
||||
-h show this help message and exit \n\
|
||||
-l list all the available options \n\
|
||||
-h key show information about this key \n\
|
||||
-g key get the current value of the key \n\
|
||||
-s key set the current value for the key \n\
|
||||
'
|
||||
')
|
||||
|
||||
def main():
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "h:s:g:", ["help"])
|
||||
opts, args = getopt.getopt(sys.argv[1:], "h:s:g:l", [])
|
||||
except getopt.GetoptError:
|
||||
cmd_help()
|
||||
sys.exit(2)
|
||||
@ -46,31 +48,40 @@ def main():
|
||||
output = None
|
||||
verbose = False
|
||||
|
||||
if not opts:
|
||||
cmd_help()
|
||||
sys.exit()
|
||||
|
||||
for opt, key in opts:
|
||||
if opt in ("-h"):
|
||||
method = getattr(control, 'set_' + key, None)
|
||||
if method is None:
|
||||
cmd_help()
|
||||
print _("sugar-control-panel: key=%s not an available option"% key)
|
||||
sys.exit()
|
||||
else:
|
||||
print method.__doc__
|
||||
if opt in ("-l"):
|
||||
elems = dir(control)
|
||||
for elem in elems:
|
||||
if elem.startswith('set_'):
|
||||
print elem[4:]
|
||||
if opt in ("-g"):
|
||||
method = getattr(control, 'print_' + key, None)
|
||||
if method is None:
|
||||
cmd_help()
|
||||
print _("sugar-control-panel: key=%s not an available option"% key)
|
||||
sys.exit()
|
||||
else:
|
||||
method()
|
||||
if opt in ("-s"):
|
||||
method = getattr(control, 'set_' + key, None)
|
||||
if method is None:
|
||||
cmd_help()
|
||||
print _("sugar-control-panel: key=%s not an available option"% key)
|
||||
sys.exit()
|
||||
else:
|
||||
try:
|
||||
method(*args)
|
||||
except Exception, e:
|
||||
print "sugar-control: %s"% e
|
||||
print _("sugar-control-panel: %s"% e)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -236,12 +236,23 @@ def print_color():
|
||||
color = get_color().to_string()
|
||||
str = color.split(',')
|
||||
|
||||
stroke = None
|
||||
fill = None
|
||||
for color in _COLORS:
|
||||
for hue in _COLORS[color]:
|
||||
if _COLORS[color][hue] == str[0]:
|
||||
print 'stroke: color=%s hue=%s'%(color, hue)
|
||||
stroke = (color, hue)
|
||||
if _COLORS[color][hue] == str[1]:
|
||||
print 'fill: color=%s hue=%s'%(color, hue)
|
||||
fill = (color, hue)
|
||||
|
||||
if stroke is not None:
|
||||
print 'stroke: color=%s hue=%s'%(stroke[0], stroke[1])
|
||||
else:
|
||||
print 'stroke: %s'%(str[0])
|
||||
if fill is not None:
|
||||
print 'fill: color=%s hue=%s'%(fill[0], fill[1])
|
||||
else:
|
||||
print 'fill: %s'%(str[1])
|
||||
|
||||
def set_color(stroke, fill, modstroke='medium', modfill='medium'):
|
||||
"""Set the system color by setting a fill and stroke color.
|
||||
@ -343,9 +354,9 @@ def get_timezone():
|
||||
timezone = string.replace(tokens[1], '"', '')
|
||||
return timezone
|
||||
except Exception, e:
|
||||
print (_("get_timezone: %s") % e)
|
||||
print "get_timezone: %s"% e
|
||||
except Exception, e:
|
||||
print (_("get_timezone: %s") % e)
|
||||
print "get_timezone: %s"% e
|
||||
return None
|
||||
|
||||
def print_timezone():
|
||||
|
Loading…
Reference in New Issue
Block a user