config: Add a method for setting options
This fixes a regression appeared after Config class became a singleton. Different parts of pisi tries to create an instance of Config class with different options. Since it is a singleton, later contructions won't get the new options. Fix this by implementing a new method for setting options instance.
This commit is contained in:
+1
-1
@@ -76,5 +76,5 @@ sys.setdefaultencoding('utf-8')
|
||||
|
||||
atexit.register(_cleanup)
|
||||
|
||||
ctx.config = pisi.config.Config(pisi.config.Options())
|
||||
ctx.config = pisi.config.Config()
|
||||
init_logging()
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ def set_options(options):
|
||||
options.verbose # flag controlling verbosity of the output messages
|
||||
options.output_dir # build and delta operations package output directory
|
||||
"""
|
||||
ctx.config = pisi.config.Config(options)
|
||||
ctx.config.set_options(options)
|
||||
|
||||
def list_needs_restart():
|
||||
"""
|
||||
|
||||
+4
-1
@@ -46,7 +46,7 @@ class Config(object):
|
||||
__metaclass__ = pisi.util.Singleton
|
||||
|
||||
def __init__(self, options = Options()):
|
||||
self.options = options
|
||||
self.set_options(options)
|
||||
self.values = pisi.configfile.ConfigurationFile("/etc/pisi/pisi.conf")
|
||||
|
||||
destdir = self.get_option('destdir')
|
||||
@@ -66,6 +66,9 @@ class Config(object):
|
||||
# build process.
|
||||
self.environ = copy.deepcopy(os.environ)
|
||||
|
||||
def set_options(self, options):
|
||||
self.options = options
|
||||
|
||||
def set_option(self, opt, val):
|
||||
setattr(self.options, opt, val)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user