return False
def _check_passwd(self):
- plainpass = self.get('hudson_pass')
+ plainpass = self._get('hudson_pass')
if not plainpass:
# None or ''
return
msger.warning('plaintext password in config file will be replaced by encoded one')
- self.set('hudson_passx', base64.b64encode(plainpass.encode('bz2')), replace_opt='hudson_pass')
+ self.set('hudson_pass', base64.b64encode(plainpass.encode('bz2')))
self.update()
- def get(self, opt, section='general'):
+ def _get(self, opt, section='general'):
try:
return self.cfgparser.get(section, opt)
except NoOptionError:
else:
return None
+ def get(self, opt, section='general'):
+ if opt == 'hudson_pass':
+ opt = 'hudson_passx'
+ val = self._get(opt, section)
+ if val:
+ return base64.b64decode(val).decode('bz2')
+ else:
+ return val
+ else:
+ return self._get(opt, section)
+
def set(self, opt, val, section='general', replace_opt=None):
+ if opt == 'hudson_pass':
+ opt = 'hudson_passx'
+ replace_opt = 'hudson_pass'
return self.cfgparser.set(section, opt, val, replace_opt)
def update(self):
from tizenpkg import cmd_import as cmd
cmd.do(opts, args)
+ @cmdln.alias("cfg")
+ @cmdln.option('-s', '--section', metavar='SECTION', default='general',
+ help='specify the section inside config file, default as "general"')
+ def do_getconfig(self, subcmd, opts, *args):
+ """${cmd_name}: query values of config file
+
+ Usage:
+ tizenpkg getconfig <opt1> [<opt2> ...]
+
+ ${cmd_option_list}
+ """
+
+ if not args:
+ raise errors.Usage('argument(s) expected')
+
+ for arg in args:
+ val = configmgr.get(arg, section=opts.section)
+ if val:
+ msger.verbose('The value of opt "%s" in [%s] is:' % (arg, opts.section))
+ msger.raw(val)
+ else:
+ msger.verbose('No value for opt key "%s" in [%s]' % (arg, opts.section))
+ msger.raw('') # we need a blank line
+
if __name__ == '__main__':
try:
mic = TizenPkg()