Support custom location of configuration file, #92
authorZhang Qiang <qiang.z.zhang@intel.com>
Fri, 6 Jul 2012 09:19:00 +0000 (17:19 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Fri, 6 Jul 2012 09:19:00 +0000 (17:19 +0800)
gitbuildsys/conf.py
tools/gbs

index f816b0ff40761d070f0958cdbf48f0f731a2d48a..6b63e93328b11c0316f798203eaf67a0c2b9bd6c 100644 (file)
@@ -276,12 +276,12 @@ distconf = $build__distconf
 
     def __init__(self, fpath=None):
         self.cfgparser = BrainConfigParser()
+        self.reset_from_conf(fpath)
 
+    def reset_from_conf(self, fpath):
         if fpath:
             if not os.path.exists(fpath):
-                if not self._new_conf(fpath):
-                    msger.error('No config file available')
-
+                raise errors.ConfigError('Configuration file %s does not exist' % fpath)
             fpaths = [fpath]
         else:
             # use the default path
index 40f070c9dc2615285f342470121aea3c57d5f489..94cfb6a6e612d04895ebfbdec15c393319e508ee 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
@@ -66,15 +66,20 @@ class Gbs(cmdln.Cmdln):
         optparser.add_option('-v', '--verbose', action='store_true',
                                                 dest='verbose',
                                                 help='verbose information')
+        optparser.add_option('-c', '--conf', dest='conf',
+                                             help='specify config file for gbs')
         return optparser
 
     def postoptparse(self):
+        from gitbuildsys.conf import configmgr
         if self.options.verbose:
             msger.set_loglevel('verbose')
 
         if self.options.debug:
             msger.set_loglevel('debug')
 
+        if self.options.conf:
+            configmgr.reset_from_conf(self.options.conf)
     '''
     @cmdln.alias('sr')
     @cmdln.option('--changelog',
@@ -335,7 +340,6 @@ class Gbs(cmdln.Cmdln):
 
 if __name__ == '__main__':
     try:
-        from gitbuildsys.conf import configmgr
         sys.exit(Gbs().main())
 
     except KeyboardInterrupt: