passx=%(passwdx)s
"""
-SRCSERVER = configmgr.get('build_server', 'build')
+APISERVER = configmgr.get('build_server', 'build')
USER = configmgr.get('user', 'build')
PASSWDX = configmgr.get('passwdx', 'build')
TMPDIR = configmgr.get('tmpdir')
if not os.path.exists(tmpdir):
os.makedirs(tmpdir)
- oscrc = OSCRC_TEMPLATE % {"apiurl": SRCSERVER, "user": USER, "passwdx": PASSWDX}
+ oscrc = OSCRC_TEMPLATE % {
+ "apiurl": APISERVER,
+ "user": USER,
+ "passwdx": PASSWDX,
+ }
(fd, oscrcpath) = tempfile.mkstemp(dir=tmpdir,prefix='.oscrc')
os.close(fd)
f = file(oscrcpath, 'w+')
f.write(oscrc)
f.close()
+ # TODO: check ./packaging dir at first
specs = glob.glob('./packaging/*.spec')
if not specs:
- msger.error('no spec file found, please add spec file to packaging directory')
+ msger.error('no spec file found under /packaging sub-directory')
specfile = specs[0] #TODO:
if len(specs) > 1:
else:
target_prj = opts.target_obsprj
- prj = obspkg.ObsProject(target_prj, apiurl = SRCSERVER, oscrc = oscrcpath)
+ prj = obspkg.ObsProject(target_prj, apiurl = APISERVER, oscrc = oscrcpath)
msger.info('checking status of obs project: %s ...' % target_prj)
if prj.is_new():
msger.info('creating %s for package build ...' % target_prj)
prj.branch_from(base_prj)
msger.info('checking out %s/%s to %s ...' % (target_prj, name, tmpdir))
- localpkg = obspkg.ObsPackage(tmpdir, target_prj, name, SRCSERVER, oscrcpath)
+ localpkg = obspkg.ObsPackage(tmpdir, target_prj, name, APISERVER, oscrcpath)
workdir = localpkg.get_workdir()
localpkg.remove_all()
os.unlink(oscrcpath)
msger.info('local changes submitted to build server successfully')
- msger.info('follow the link to monitor the build progress: ')
- msger.info('%s/project/show?project=%s' % (SRCSERVER.replace('api', 'build'), target_prj))
+ msger.info('follow the link to monitor the build progress:\n'
+ ' %s/project/show?project=%s' \
+ % (APISERVER.replace('api', 'build'), target_prj))
"""
if len(filenames) > 1:
- msger.warning('Will not support multiple config files, only read in the last one.')
+ msger.warning('Will not support multiple config files, '
+ 'only read in the last one.')
filenames = filenames[-1:]
return SafeConfigParser.read(self, filenames)
the sections and keys
"""
+ def _get_savekey(sec, opt):
+ return "%s.%s" % (sec, opt)
+
# save the original filepath and contents
self._fpname = fname
self._flines = fp.readlines()
value = line.strip()
if value:
cursect[optname] = "%s\n%s" % (cursect[optname], value)
- self._opt_linenos["%s.%s" % (cursect['__name__'], optname)].append(lineno)
+ savekey = _get_savekey(cursect['__name__'], optname)
+ self._opt_linenos[savekey].append(lineno)
# a section header or option header?
else:
# is it a section header?
optval = ''
optname = self.optionxform(optname.rstrip())
cursect[optname] = optval
- self._opt_linenos["%s.%s" % (cursect['__name__'], optname)] = [lineno]
+ savekey = _get_savekey(cursect['__name__'], optname)
+ self._opt_linenos[savekey] = [lineno]
else:
# a non-fatal parsing error occurred. set up the
return -1
found = False
- for sec, lineno in sorted(self._sec_linenos.items(), key=lambda x: x[1][0]):
+ for sec, lineno in sorted(self._sec_linenos.items(),
+ key=lambda x: x[1][0]):
if found:
return lineno[0]-1
defaults['build']['user'] = raw_input('Username: ')
msger.info('Your password will be encoded before saving ...')
defaults['build']['passwd'] = ''
- defaults['build']['passwdx'] = base64.b64encode(getpass.getpass().encode('bz2'))
+ defaults['build']['passwdx'] = \
+ base64.b64encode(getpass.getpass().encode('bz2'))
with open(fpath, 'w') as wf:
wf.write(self.get_default_conf(defaults))
# None or ''
continue
- msger.warning('plaintext password in config file will be replaced by encoded one')
- self.set('passwd', base64.b64encode(plainpass.encode('bz2')), sec)
+ msger.warning('plaintext password in config file will '
+ 'be replaced by encoded one')
+ self.set('passwd',
+ base64.b64encode(plainpass.encode('bz2')),
+ sec)
self.update()
def _get(self, opt, section='general'):
if opt in self.DEFAULTS[section]:
return self.DEFAULTS[section][opt]
else:
- raise errors.ConfigError('no opt: %s in section %s' % (opt, section))
+ raise errors.ConfigError('no opt: %s in section %s' \
+ % (opt, section))
def get(self, opt, section='general'):
if opt == 'passwd':
keyword = '<usage>'
def __str__(self):
- return self.keyword + str(self.msg) + ', please use "--help" for more info'
-
-class Abort(CmdError):
- keyword = ''
+ return self.keyword + str(self.msg) + \
+ ', please use "--help" for more info'
class ConfigError(CmdError):
keyword = '<config>'
class GitInvalid(GitError):
def __str__(self):
- return 'Dir %s is not a valid git tree' % str(self.msg)
+ return '<git>dir %s is not a valid git tree' % str(self.msg)
class ObsError(CmdError):
keyword = '<obs>'
+
+class Abort(CmdError):
+ keyword = ''
target_package = 'dumb_pkg')
if target_prj != self._prj:
- raise ObsError('branched prj: %s is not expected %s' % (target_prj, self._prj))
+ raise ObsError('branched prj: %s is not the expected %s' \
+ % (target_prj, self._prj))
# remove the dumb pkg
self._bs.deletePackage(target_prj, target_pkg)
if line.startswith('+ echo '):
return line[7:].rstrip()
- msger.warning('invalid spec file, cannot get the value of macro %s' % macro)
+ msger.warning('invalid spec file, cannot get the value of macro %s' \
+ % macro)
return ''
else:
def get_optparser(self):
optparser = cmdln.CmdlnOptionParser(self, version=self.version)
- optparser.add_option('-d', '--debug', action='store_true', dest='debug', help='print debug message')
- optparser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='verbose information')
+ optparser.add_option('-d', '--debug', action='store_true',
+ dest='debug',
+ help='print debug message')
+ optparser.add_option('-v', '--verbose', action='store_true',
+ dest='verbose',
+ help='verbose information')
return optparser
def postoptparse(self):
msger.set_loglevel('debug')
@cmdln.alias("bl")
- @cmdln.option('-T', '--target-obsprj', default=None, dest='target_obsprj',
- help='The corresponding OBS target project used to build package, '\
- 'If not specified, "home:<userid>:gbs:Trunk" will be used.')
- @cmdln.option('-B', '--base-obsprj', default=None, dest='base_obsprj',
- help='The corresponding OBS Base project used to branch from, ' \
- 'If not specified, "Trunk" will be used.')
+ @cmdln.option('-T', '--target-obsprj',
+ default=None,
+ dest='target_obsprj',
+ help='OBS target project being used to build package, ' \
+ 'use "home:<userid>:gbs:Trunk" if not specified')
+ @cmdln.option('-B', '--base-obsprj',
+ default=None,
+ dest='base_obsprj',
+ help='Base OBS project being used to branch from, ' \
+ 'use "Trunk" if not specified')
@_fall_to_shell('build')
def do_build(self, subcmd, opts, *args):
"""${cmd_name}: test building for current pkg
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"')
+ @cmdln.option('-s', '--section',
+ metavar='SECTION',
+ default='general',
+ help='specify the section inside config file, ' \
+ 'use "general" as the default')
def do_getconfig(self, subcmd, opts, *args):
"""${cmd_name}: query values of config file
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.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.verbose('No value for opt key "%s" in [%s]' \
+ % (arg, opts.section))
msger.raw('') # we need a blank line
if __name__ == '__main__':