code format: shorten all 80+ long lines
authorJF Ding <jian-feng.ding@intel.com>
Wed, 8 Feb 2012 11:37:46 +0000 (19:37 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Wed, 8 Feb 2012 11:37:46 +0000 (19:37 +0800)
gitbuildsys/cmd_build.py
gitbuildsys/conf.py
gitbuildsys/errors.py
gitbuildsys/obspkg.py
gitbuildsys/utils.py
tools/gbs

index c328465fac5032b1da26443221c323581b2ddc5f..47a74605d32c824e6af2c4309b702ac4df9e1e9a 100644 (file)
@@ -41,7 +41,7 @@ user=%(user)s
 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')
@@ -59,16 +59,21 @@ def do(opts, args):
     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:
@@ -89,14 +94,14 @@ def do(opts, args):
     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()
 
@@ -128,5 +133,6 @@ def do(opts, args):
 
     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))
index ead7ab1839f126fa6f82f4569c76c58c0fc5cff5..a901f7de553575ec086d6a20088147afd8da725d 100644 (file)
@@ -35,7 +35,8 @@ class BrainConfigParser(SafeConfigParser):
         """
 
         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)
@@ -50,6 +51,9 @@ class BrainConfigParser(SafeConfigParser):
         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()
@@ -79,7 +83,8 @@ class BrainConfigParser(SafeConfigParser):
                 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?
@@ -123,7 +128,8 @@ class BrainConfigParser(SafeConfigParser):
                             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
@@ -149,7 +155,8 @@ class BrainConfigParser(SafeConfigParser):
                 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
 
@@ -299,7 +306,8 @@ passwdx = $build__passwdx
             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))
@@ -319,8 +327,11 @@ passwdx = $build__passwdx
                     # 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'):
@@ -338,7 +349,8 @@ passwdx = $build__passwdx
             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':
index 22bd4c3f9bef471433fc9d0eb0d3595eea9d8f38..f41fe418b423c8de6a9ca8ecb3772ea6c4d7c3cf 100644 (file)
@@ -30,10 +30,8 @@ class Usage(CmdError):
     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>'
@@ -43,7 +41,10 @@ class GitError(CmdError):
 
 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 = ''
index 16f6a992149cc3cad9705840f10b6c80f3d82c3c..34e4ef6f19059a188b6732ecd7dd3e03956f00dc 100644 (file)
@@ -177,7 +177,8 @@ class ObsProject(object):
                                                     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)
index be51ca6f61f8601469289e22a9e52cbdc29a0d73..2aadfe72d079840162c7322b7b5003774f07c012 100644 (file)
@@ -99,7 +99,8 @@ def parse_spec(spec_path, macro):
             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:
index b13af42b7aa6a5e61dbc5c76031861a8949bbe80..c6e9334635b5eeacbad656a56ca23d9b9c500af0 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
@@ -64,8 +64,12 @@ class TizenPkg(cmdln.Cmdln):
 
     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):
@@ -76,12 +80,16 @@ class TizenPkg(cmdln.Cmdln):
             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
@@ -96,8 +104,11 @@ class TizenPkg(cmdln.Cmdln):
         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
 
@@ -113,10 +124,12 @@ class TizenPkg(cmdln.Cmdln):
         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__':