* better solution: add a comar flag to init.api,
problem solved for good. ui writers: default is to run comard
This commit is contained in:
+2
-2
@@ -40,13 +40,13 @@ class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
|
||||
def init(database = True, options = None, ui = None ):
|
||||
def init(database = True, options = None, ui = None, comar = True):
|
||||
"""Initialize PiSi subsystem"""
|
||||
|
||||
import pisi.config
|
||||
ctx.config = pisi.config.Config(options)
|
||||
|
||||
if not ctx.config.get_option('ignore_comar'):
|
||||
if comar and not ctx.config.get_option('ignore_comar'):
|
||||
# FIXME: just try for others (that don't use comar)
|
||||
try:
|
||||
import comar
|
||||
|
||||
@@ -52,12 +52,12 @@ class Command(object):
|
||||
def __init__(self):
|
||||
# now for the real parser
|
||||
import pisi
|
||||
self.comar = False
|
||||
self.parser = OptionParser(usage=getattr(self, "__doc__"),
|
||||
version="%prog " + pisi.__version__)
|
||||
self.options()
|
||||
self.commonopts()
|
||||
(self.options, self.args) = self.parser.parse_args()
|
||||
self.override_options()
|
||||
self.args.pop(0) # exclude command arg
|
||||
|
||||
self.check_auth_info()
|
||||
@@ -87,12 +87,6 @@ class Command(object):
|
||||
options function it will be called"""
|
||||
pass
|
||||
|
||||
def override_options(self):
|
||||
# if ignore_comar is not defined, it is True, where it is defined
|
||||
# its default is False. Confused? Don't get confused, it's correct :)
|
||||
if not hasattr(self.options, 'ignore_comar'):
|
||||
self.options.ignore_comar = True
|
||||
|
||||
def check_auth_info(self):
|
||||
username = self.options.username
|
||||
password = self.options.password
|
||||
@@ -121,7 +115,8 @@ class Command(object):
|
||||
|
||||
# NB: command imports here or in the command class run fxns
|
||||
import pisi.api
|
||||
pisi.api.init(database, self.options)
|
||||
pisi.api.init(database = database, options = self.options,
|
||||
comar = self.comar)
|
||||
|
||||
def finalize(self):
|
||||
"""do cleanup work for PiSi components"""
|
||||
@@ -281,6 +276,7 @@ class PackageOp(Command):
|
||||
"""Abstract package operation command"""
|
||||
def __init__(self):
|
||||
super(PackageOp, self).__init__()
|
||||
self.comar = True
|
||||
|
||||
def options(self):
|
||||
p = self.parser
|
||||
|
||||
@@ -25,7 +25,7 @@ from pisi import uri
|
||||
|
||||
class ArchiveFileTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pisi.api.init()
|
||||
pisi.api.init(comar = False)
|
||||
|
||||
def testUnpackTar(self):
|
||||
bctx = BuildContext("tests/popt/pspec.xml")
|
||||
|
||||
@@ -20,7 +20,7 @@ from pisi import uri
|
||||
|
||||
class FetcherTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pisi.api.init()
|
||||
pisi.api.init(database = False, comar = False)
|
||||
|
||||
self.spec = SpecFile()
|
||||
self.spec.read("tests/popt/pspec.xml")
|
||||
|
||||
@@ -19,7 +19,7 @@ from pisi import util
|
||||
class InstallDBTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pisi.api.init()
|
||||
pisi.api.init(database = True, comar = False)
|
||||
self.installdb = ctx.installdb
|
||||
|
||||
def testRemoveDummy(self):
|
||||
|
||||
@@ -21,7 +21,7 @@ class PackageDBTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# setUp will be called for each test individually
|
||||
pisi.api.init()
|
||||
pisi.api.init(comar = False)
|
||||
|
||||
self.spec = SpecFile()
|
||||
self.spec.read('tests/popt/pspec.xml')
|
||||
|
||||
@@ -20,7 +20,7 @@ from pisi.specfile import SpecFile
|
||||
class SourceDBTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pisi.api.init()
|
||||
pisi.api.init(comar = False)
|
||||
|
||||
self.sourcedb = pisi.sourcedb.init()
|
||||
self.spec = SpecFile()
|
||||
|
||||
@@ -24,7 +24,7 @@ from pisi.xmlext import *
|
||||
class XmlFileTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pisi.api.init(False)
|
||||
pisi.api.init(database = False, comar = False)
|
||||
|
||||
def testMetaClass(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user