* 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:
Eray Özkural
2005-09-30 11:19:15 +00:00
parent cd052b1269
commit b36a74fe1a
8 changed files with 12 additions and 16 deletions
+2 -2
View File
@@ -40,13 +40,13 @@ class Error(pisi.Error):
pass pass
def init(database = True, options = None, ui = None ): def init(database = True, options = None, ui = None, comar = True):
"""Initialize PiSi subsystem""" """Initialize PiSi subsystem"""
import pisi.config import pisi.config
ctx.config = pisi.config.Config(options) 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) # FIXME: just try for others (that don't use comar)
try: try:
import comar import comar
+4 -8
View File
@@ -52,12 +52,12 @@ class Command(object):
def __init__(self): def __init__(self):
# now for the real parser # now for the real parser
import pisi import pisi
self.comar = False
self.parser = OptionParser(usage=getattr(self, "__doc__"), self.parser = OptionParser(usage=getattr(self, "__doc__"),
version="%prog " + pisi.__version__) version="%prog " + pisi.__version__)
self.options() self.options()
self.commonopts() self.commonopts()
(self.options, self.args) = self.parser.parse_args() (self.options, self.args) = self.parser.parse_args()
self.override_options()
self.args.pop(0) # exclude command arg self.args.pop(0) # exclude command arg
self.check_auth_info() self.check_auth_info()
@@ -87,12 +87,6 @@ class Command(object):
options function it will be called""" options function it will be called"""
pass 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): def check_auth_info(self):
username = self.options.username username = self.options.username
password = self.options.password password = self.options.password
@@ -121,7 +115,8 @@ class Command(object):
# NB: command imports here or in the command class run fxns # NB: command imports here or in the command class run fxns
import pisi.api import pisi.api
pisi.api.init(database, self.options) pisi.api.init(database = database, options = self.options,
comar = self.comar)
def finalize(self): def finalize(self):
"""do cleanup work for PiSi components""" """do cleanup work for PiSi components"""
@@ -281,6 +276,7 @@ class PackageOp(Command):
"""Abstract package operation command""" """Abstract package operation command"""
def __init__(self): def __init__(self):
super(PackageOp, self).__init__() super(PackageOp, self).__init__()
self.comar = True
def options(self): def options(self):
p = self.parser p = self.parser
+1 -1
View File
@@ -25,7 +25,7 @@ from pisi import uri
class ArchiveFileTestCase(unittest.TestCase): class ArchiveFileTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
pisi.api.init() pisi.api.init(comar = False)
def testUnpackTar(self): def testUnpackTar(self):
bctx = BuildContext("tests/popt/pspec.xml") bctx = BuildContext("tests/popt/pspec.xml")
+1 -1
View File
@@ -20,7 +20,7 @@ from pisi import uri
class FetcherTestCase(unittest.TestCase): class FetcherTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
pisi.api.init() pisi.api.init(database = False, comar = False)
self.spec = SpecFile() self.spec = SpecFile()
self.spec.read("tests/popt/pspec.xml") self.spec.read("tests/popt/pspec.xml")
+1 -1
View File
@@ -19,7 +19,7 @@ from pisi import util
class InstallDBTestCase(unittest.TestCase): class InstallDBTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
pisi.api.init() pisi.api.init(database = True, comar = False)
self.installdb = ctx.installdb self.installdb = ctx.installdb
def testRemoveDummy(self): def testRemoveDummy(self):
+1 -1
View File
@@ -21,7 +21,7 @@ class PackageDBTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
# setUp will be called for each test individually # setUp will be called for each test individually
pisi.api.init() pisi.api.init(comar = False)
self.spec = SpecFile() self.spec = SpecFile()
self.spec.read('tests/popt/pspec.xml') self.spec.read('tests/popt/pspec.xml')
+1 -1
View File
@@ -20,7 +20,7 @@ from pisi.specfile import SpecFile
class SourceDBTestCase(unittest.TestCase): class SourceDBTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
pisi.api.init() pisi.api.init(comar = False)
self.sourcedb = pisi.sourcedb.init() self.sourcedb = pisi.sourcedb.init()
self.spec = SpecFile() self.spec = SpecFile()
+1 -1
View File
@@ -24,7 +24,7 @@ from pisi.xmlext import *
class XmlFileTestCase(unittest.TestCase): class XmlFileTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
pisi.api.init(False) pisi.api.init(database = False, comar = False)
def testMetaClass(self): def testMetaClass(self):