comparison frontends/src/jp/cmd_param.py @ 1864:96ba685162f6

jp: all commands now use the new start method and set need_loop in __init__ when needed
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:52:51 +0100
parents d17772b0fe22
children 3e168cde7a7d
comparison
equal deleted inserted replaced
1863:b2ddd7f5dcdf 1864:96ba685162f6
32 self.parser.add_argument("category", nargs='?', type=base.unicode_decoder, help=_(u"Category of the parameter")) 32 self.parser.add_argument("category", nargs='?', type=base.unicode_decoder, help=_(u"Category of the parameter"))
33 self.parser.add_argument("name", nargs='?', type=base.unicode_decoder, help=_(u"Name of the parameter")) 33 self.parser.add_argument("name", nargs='?', type=base.unicode_decoder, help=_(u"Name of the parameter"))
34 self.parser.add_argument("-a", "--attribute", type=str, default="value", help=_(u"Name of the attribute to get")) 34 self.parser.add_argument("-a", "--attribute", type=str, default="value", help=_(u"Name of the attribute to get"))
35 self.parser.add_argument("--security-limit", type=int, default=-1, help=_(u"Security limit")) 35 self.parser.add_argument("--security-limit", type=int, default=-1, help=_(u"Security limit"))
36 36
37 def connected(self): 37 def start(self):
38 super(Get, self).connected()
39 if self.args.category is None: 38 if self.args.category is None:
40 categories = self.host.bridge.getParamsCategories() 39 categories = self.host.bridge.getParamsCategories()
41 print u"\n".join(categories) 40 print u"\n".join(categories)
42 elif self.args.name is None: 41 elif self.args.name is None:
43 try: 42 try:
65 self.parser.add_argument("category", type=base.unicode_decoder, help=_(u"Category of the parameter")) 64 self.parser.add_argument("category", type=base.unicode_decoder, help=_(u"Category of the parameter"))
66 self.parser.add_argument("name", type=base.unicode_decoder, help=_(u"Name of the parameter")) 65 self.parser.add_argument("name", type=base.unicode_decoder, help=_(u"Name of the parameter"))
67 self.parser.add_argument("value", type=base.unicode_decoder, help=_(u"Name of the parameter")) 66 self.parser.add_argument("value", type=base.unicode_decoder, help=_(u"Name of the parameter"))
68 self.parser.add_argument("--security-limit", type=int, default=-1, help=_(u"Security limit")) 67 self.parser.add_argument("--security-limit", type=int, default=-1, help=_(u"Security limit"))
69 68
70 def connected(self): 69 def start(self):
71 super(Set, self).connected()
72 try: 70 try:
73 self.host.bridge.setParam(self.args.name, self.args.value, self.args.category, self.args.security_limit, self.profile) 71 self.host.bridge.setParam(self.args.name, self.args.value, self.args.category, self.args.security_limit, self.profile)
74 except Exception as e: 72 except Exception as e:
75 print u"Can set requested parameter: {}".format(e) 73 print u"Can set requested parameter: {}".format(e)
76 74
80 super(SaveTemplate, self).__init__(host, 'save', use_profile=False, help=_('Save parameters template to xml file')) 78 super(SaveTemplate, self).__init__(host, 'save', use_profile=False, help=_('Save parameters template to xml file'))
81 79
82 def add_parser_options(self): 80 def add_parser_options(self):
83 self.parser.add_argument("filename", type=str, help=_("Output file")) 81 self.parser.add_argument("filename", type=str, help=_("Output file"))
84 82
85 def run(self): 83 def start(self):
86 """Save parameters template to xml file""" 84 """Save parameters template to xml file"""
87 if self.host.bridge.saveParamsTemplate(self.args.filename): 85 if self.host.bridge.saveParamsTemplate(self.args.filename):
88 print _("Parameters saved to file %s") % self.args.filename 86 print _("Parameters saved to file %s") % self.args.filename
89 else: 87 else:
90 print _("Can't save parameters to file %s") % self.args.filename 88 print _("Can't save parameters to file %s") % self.args.filename
96 super(LoadTemplate, self).__init__(host, 'load', use_profile=False, help=_('Load parameters template from xml file')) 94 super(LoadTemplate, self).__init__(host, 'load', use_profile=False, help=_('Load parameters template from xml file'))
97 95
98 def add_parser_options(self): 96 def add_parser_options(self):
99 self.parser.add_argument("filename", type=str, help=_("Input file")) 97 self.parser.add_argument("filename", type=str, help=_("Input file"))
100 98
101 def run(self): 99 def start(self):
102 """Load parameters template from xml file""" 100 """Load parameters template from xml file"""
103 if self.host.bridge.loadParamsTemplate(self.args.filename): 101 if self.host.bridge.loadParamsTemplate(self.args.filename):
104 print _("Parameters loaded from file %s") % self.args.filename 102 print _("Parameters loaded from file %s") % self.args.filename
105 else: 103 else:
106 print _("Can't load parameters from file %s") % self.args.filename 104 print _("Can't load parameters from file %s") % self.args.filename