本文整理汇总了Python中omero.cli.CLI类的典型用法代码示例。如果您正苦于以下问题:Python CLI类的具体用法?Python CLI怎么用?Python CLI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
self.__output = []
self.__error = []
self.__popen = []
self.__call = []
self.mox = mox.Mox()
CLI.__init__(self, *args, **kwargs)
示例2: TestJvmCfg
class TestJvmCfg(object):
"""Test template files regeneration"""
@pytest.fixture(autouse=True)
def setup_method(self, tmpadmindir):
self.cli = CLI()
self.cli.register("admin", AdminControl, "TEST")
self.cli.register("config", PrefsControl, "TEST")
self.args = ["admin", "jvmcfg"]
self.cli.dir = path(tmpadmindir)
def testNoTemplatesGeneration(self):
"""Test no template files are generated by the jvmcfg subcommand"""
# Test non-existence of configuration files
for f in GRID_FILES:
assert not os.path.exists(path(self.cli.dir) / "etc" / "grid" / f)
for f in ETC_FILES:
assert not os.path.exists(path(self.cli.dir) / "etc" / f)
# Call the jvmcf command and test file genearation
self.cli.invoke(self.args, strict=True)
for f in GRID_FILES:
assert not os.path.exists(path(self.cli.dir) / "etc" / "grid" / f)
for f in ETC_FILES:
assert not os.path.exists(path(self.cli.dir) / "etc" / f)
@pytest.mark.parametrize("suffix", ["", ".blitz", ".indexer", ".pixeldata", ".repository"])
def testInvalidJvmCfgStrategy(self, suffix, tmpdir):
"""Test invalid JVM strategy configuration leads to CLI error"""
key = "omero.jvmcfg.strategy%s" % suffix
self.cli.invoke(["config", "set", key, "bad"], strict=True)
with pytest.raises(NonZeroReturnCode):
self.cli.invoke(self.args, strict=True)
示例3: testParametersParsedCorrectly
def testParametersParsedCorrectly(self):
class TestControl(BaseControl):
def __call__(self2, args):
self.assertEquals("b",args["a"])
cli = CLI()
cli.register("test", TestControl, "HELP")
cli.invoke(["test","a=b"])
self.assertEquals(0, cli.rv)
示例4: T
class T(Thread):
def run(self, *args):
pause = random.random()
event.wait(pause)
self.cli = CLI()
self.cli.loadplugins()
self.con = self.cli.controls["admin"]
self.cmp = self.con.ctx
示例5: testLineParsedCorrectly
def testLineParsedCorrectly(self):
class TestControl(BaseControl):
def __call__(self, args):
if len(*args) != 2:
raise Exc("Args was over parsed! %s" % args)
cli = CLI()
cli.register("test", TestControl, "HELP")
cli.invoke(["test","a","a b c d e"])
self.assertEquals(0, cli.rv)
示例6: __init__
def __init__(self, *args, **kwargs):
CLI.__init__(self, *args, **kwargs)
self.DIR = create_path(folder=True)
self.REQRESP = {}
self.STORE = MyStore(self.DIR)
self.STORE.clear(testhost, testuser)
self.register("s", SessionsControl, "TEST")
self.controls["s"].FACTORY = lambda ignore: self.STORE
assert self.STORE.count(testhost, testuser) == 0
示例7: testNoArgumentsDies
def testNoArgumentsDies(self):
cli = CLI()
cli.register("import", ImportControl, "HELP")
try:
cli.invoke([])
self.assert_(cli.rv != 0)
except NonZeroReturnCode, nzrc:
pass
示例8: TestChgrp
class TestChgrp(object):
def setup_method(self, method):
self.cli = CLI()
self.cli.register("chgrp", ChgrpControl, "TEST")
self.args = ["chgrp"]
def testHelp(self):
self.args += ["-h"]
self.cli.invoke(self.args, strict=True)
示例9: AbstractCLITest
class AbstractCLITest(ITest):
def setup_method(self, method):
super(AbstractCLITest, self).setup_method(method)
self.cli = CLI()
self.cli.register("sessions", SessionsControl, "TEST")
def setup_mock(self):
self.mox = Mox()
def teardown_mock(self):
self.mox.UnsetStubs()
self.mox.VerifyAll()
示例10: check
def check(self):
from omero.cli import CLI
from omero.gateway import BlitzGateway
cli = CLI()
cli.loadplugins()
cli.onecmd('login -q')
try:
gateway = BlitzGateway(client_obj=cli.get_client())
for experiment in self.m["experiments"]:
self.check_object(gateway, experiment, "Project")
for experiment in self.m["screens"]:
self.check_object(gateway, experiment, "Screen")
if "map" in self.m:
if self.m["experiments"]:
study_type = "Project"
else:
study_type = "Screen"
self.check_object(gateway, self.m, study_type)
finally:
if cli:
cli.close()
gateway.close()
示例11: setup_method
def setup_method(self, method):
self.cli = CLI()
self.cli.register("db", DatabaseControl, "TEST")
dir = path(__file__) / ".." / ".." / ".." / ".." / ".." / ".." /\
".." / "dist" # FIXME: should not be hard-coded
dir = dir.abspath()
cfg = dir / "etc" / "omero.properties"
cfg = cfg.abspath()
self.cli.dir = dir
self.data = {}
for line in cfg.text().split("\n"):
line = line.strip()
for x in ("version", "patch"):
key = "omero.db." + x
if line.startswith(key):
self.data[x] = line[len(key)+1:]
self.file = create_path()
self.script_file = "%(version)s__%(patch)s.sql" % self.data
if os.path.isfile(self.script_file):
os.rename(self.script_file, self.script_file + '.bak')
assert not os.path.isfile(self.script_file)
self.mox = Mox()
self.mox.StubOutWithMock(getpass, 'getpass')
self.mox.StubOutWithMock(__builtin__, "raw_input")
示例12: setup_method
def setup_method(self, method):
# # Non-temp directories
ctxdir = path() / ".." / ".." / ".." / "dist"
etc_dir = ctxdir / "etc"
# List configuration files to backup
self.cfg_files = {}
for f in ['internal.cfg', 'master.cfg', 'ice.config']:
self.cfg_files[f] = etc_dir / f
for f in ['windefault.xml', 'default.xml', 'config.xml']:
self.cfg_files[f] = etc_dir / 'grid' / f
# Create temp files for backup
tmp_dir = create_path(folder=True)
self.tmp_cfg_files = {}
for key in self.cfg_files.keys():
if self.cfg_files[key].exists():
self.tmp_cfg_files[key] = tmp_dir / key
self.cfg_files[key].copy(self.tmp_cfg_files[key])
else:
self.tmp_cfg_files[key] = None
# Other setup
self.cli = CLI()
self.cli.dir = ctxdir
self.cli.register("admin", AdminControl, "TEST")
self.args = ["admin", "ports"]
示例13: TestHql
class TestHql(object):
def setup_method(self, method):
self.cli = CLI()
self.cli.register("hql", HqlControl, "TEST")
self.args = ["hql"]
def testHelp(self):
self.args += ["-h"]
self.cli.invoke(self.args, strict=True)
@pytest.mark.parametrize("key", BLACKLISTED_KEYS)
def testFilterBlacklist(self, key):
output = self.cli.controls["hql"].filter({key: 1})
assert output == {}
@pytest.mark.parametrize("key", ["rois", "groupExperimenterMap"])
def testFilterLoaded(self, key):
output = self.cli.controls["hql"].filter({"_" + key + "Loaded": 1})
assert output == {}
@pytest.mark.parametrize(
("value", "outcome"),
[("owner=None;group=None", {}),
("owner=1", {"details": "owner=1"})])
def testFilterDetails(self, value, outcome):
output = self.cli.controls["hql"].filter({"_details": value})
assert output == outcome
@pytest.mark.parametrize("multi_value", [[0, 1]])
def testFilterMultiValue(self, multi_value):
output = self.cli.controls["hql"].filter({'key': multi_value})
assert output == {}
@pytest.mark.parametrize("empty_value", [None, [], {}])
def testFilterEmptyValue(self, empty_value):
output = self.cli.controls["hql"].filter({'key': empty_value})
assert output == {}
@pytest.mark.parametrize("value", WHITELISTED_VALUES)
def testFilterWhitelist(self, value):
output = self.cli.controls["hql"].filter({'key': value})
assert output == {'key': value}
def testFilterStrip(self):
output = self.cli.controls["hql"].filter({'_key': 1})
assert output == {'key': 1}
示例14: testDropBoxArgs
def testDropBoxArgs(self):
class MockImportControl(ImportControl):
def importer(this, args):
self.assertEquals(args.server, "localhost")
self.assertEquals(args.port, "4064")
self.assertEquals(args.key, "b0742975-03a1-4f6d-b0ac-639943f1a147")
self.assertEquals(args.errs, "/Users/cblackburn/omero/tmp/omero_cblackburn/6915/dropboxuUGl5rerr")
self.assertEquals(args.file, "/Users/cblackburn/omero/tmp/omero_cblackburn/6915/dropboxaDCjQlout")
cmd = ['-s', 'localhost', '-p', '4064', '-k', 'b0742975-03a1-4f6d-b0ac-639943f1a147']
cmd += ['import', '---errs=/Users/cblackburn/omero/tmp/omero_cblackburn/6915/dropboxuUGl5rerr']
cmd += ['---file=/Users/cblackburn/omero/tmp/omero_cblackburn/6915/dropboxaDCjQlout']
cmd += ['--', '/OMERO/DropBox/root/tinyTest.d3d.dv']
cli = CLI()
cli.register("import", MockImportControl, "HELP")
cli.invoke(cmd)
示例15: setup_method
def setup_method(self, method):
self.cli = CLI()
self.cli.register("import", ImportControl, "TEST")
self.args = ["import"]
dist_dir = path(__file__) / ".." / ".." / ".." / ".." / ".." / ".." /\
".." / "dist" # FIXME: should not be hard-coded
dist_dir = dist_dir.abspath()
client_dir = dist_dir / "lib" / "client"
self.args += ["--clientdir", client_dir]