本文整理汇总了Python中omero.cli.CLI.invoke方法的典型用法代码示例。如果您正苦于以下问题:Python CLI.invoke方法的具体用法?Python CLI.invoke怎么用?Python CLI.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.cli.CLI
的用法示例。
在下文中一共展示了CLI.invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testParametersParsedCorrectly
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
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)
示例2: testNoArgumentsDies
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
def testNoArgumentsDies(self):
cli = CLI()
cli.register("import", ImportControl, "HELP")
try:
cli.invoke([])
self.assert_(cli.rv != 0)
except NonZeroReturnCode, nzrc:
pass
示例3: testLineParsedCorrectly
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
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)
示例4: TestChgrp
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
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)
示例5: as_stdout
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
def as_stdout(path, readers=""):
path = _to_list(path)
readers = str(readers)
cli = CLI()
cli.loadplugins()
if readers:
cli.invoke(["import", "-l", readers, "-f"]+path)
else:
cli.invoke(["import", "-f"]+path)
if cli.rv != 0:
raise omero.InternalException(None, None, "'import -f' exited with a rc=%s. See console for more information" % cli.rv)
示例6: TestTag
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
class TestTag(object):
def setup_method(self, method):
self.cli = CLI()
self.cli.register("fs", FsControl, "TEST")
self.args = ["fs"]
def testHelp(self):
self.args += ["-h"]
self.cli.invoke(self.args, strict=True)
@pytest.mark.parametrize('subcommand', FsControl().get_subcommands())
def testSubcommandHelp(self, subcommand):
self.args += [subcommand, "-h"]
self.cli.invoke(self.args, strict=True)
示例7: TestUser
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
class TestUser(object):
def setup_method(self, method):
self.cli = CLI()
self.cli.register("user", UserControl, "TEST")
self.args = ["user"]
# Help subcommands
# ========================================================================
def testHelp(self):
self.args += ["-h"]
self.cli.invoke(self.args, strict=True)
@pytest.mark.parametrize("subcommand", UserControl().get_subcommands())
def testSubcommandHelp(self, subcommand):
self.args += [subcommand, "-h"]
self.cli.invoke(self.args, strict=True)
示例8: TestHql
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
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}
示例9: testDropBoxArgs
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
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)
示例10: TestDownload
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
class TestDownload(object):
def setup_method(self, method):
self.cli = CLI()
self.cli.register("download", DownloadControl, "TEST")
self.args = ["download"]
def testHelp(self):
self.args += ["-h"]
self.cli.invoke(self.args, strict=True)
@pytest.mark.parametrize(
'bad_input',
['-1', 'OriginalFile:-1', 'FileAnnotation:-1', 'Image:-1'])
def testInvalidInput(self, bad_input):
self.args += [bad_input, '-']
with pytest.raises(NonZeroReturnCode):
self.cli.invoke(self.args, strict=True)
示例11: TestJvmCfg
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
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)
示例12: TestCli
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
class TestCli(object):
def testMultipleLoad(self):
"""
In DropBox, the loading of multiple CLIs seems to
lead to the wrong context being assigned to some
controls.
See #4749
"""
import random
from threading import Thread, Event
event = Event()
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
threads = [T() for x in range(20)]
for t in threads:
t.start()
event.set()
for t in threads:
t.join()
assert len(threads) == len(set([t.cli for t in threads]))
assert len(threads) == len(set([t.con for t in threads]))
assert len(threads) == len(set([t.cmp for t in threads]))
def testLoad(self):
tmp = create_path()
tmp.write_text("foo")
self.cli = CLI()
self.cli.register("load", LoadControl, "help")
with pytest.raises(NonZeroReturnCode):
self.cli.invoke("load %s" % tmp, strict=True)
self.cli.invoke("load -k %s" % tmp, strict=True)
self.cli.invoke("load --keep-going %s" % tmp, strict=True)
示例13: hrm_to_omero
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
def hrm_to_omero(conn, id_str, image_file):
"""Upload an image into a specific dataset in OMERO.
In case we know from the suffix that a given file format is not supported
by OMERO, the upload will not be initiated at all (e.g. for SVI-HDF5,
having the suffix '.h5').
The import itself is done by instantiating the CLI class, assembling the
required arguments, and finally running cli.invoke(). This eventually
triggers the importer() method defined in OMERO's Python bindings in
<OMERO.server/lib/python/omero/plugins/import.py>, respectively (source)
<openmicroscopy.git/components/tools/OmeroPy/src/omero/plugins/import.py>.
Parameters
==========
id_str: str - the ID of the target dataset in OMERO (e.g. "G:7:Dataset:23")
image_file: str - the local image file including the full path
Returns
=======
True in case of success, False otherwise.
"""
if image_file.lower().endswith(('.h5', '.hdf5')):
print 'ERROR: HDF5 files are not supported by OMERO!'
return False
# TODO I: group switching required!!
_, gid, obj_type, dset_id = id_str.split(':')
# we have to create the annotations *before* we actually upload the image
# data itself and link them to the image during the upload - the other way
# round is not possible right now as the CLI wrapper (see below) doesn't
# expose the ID of the newly created object in OMERO (confirmed by J-M and
# Sebastien on the 2015 OME Meeting):
namespace = 'deconvolved.hrm'
#### mime = 'text/plain'
# extract the image basename without suffix:
# TODO: is it [0-9a-f] or really [0-9a-z] as in the original PHP code?
basename = re.sub(r'(_[0-9a-f]{13}_hrm)\..*', r'\1', image_file)
comment = gen_parameter_summary(basename + '.parameters.txt')
#### annotations = []
#### # TODO: the list of suffixes should not be hardcoded here!
#### for suffix in ['.hgsb', '.log.txt', '.parameters.txt']:
#### if not os.path.exists(basename + suffix):
#### continue
#### ann = conn.createFileAnnfromLocalFile(
#### basename + suffix, mimetype=mime, ns=namespace, desc=None)
#### annotations.append(ann.getId())
# currently there is no direct "Python way" to import data into OMERO, so
# we have to use the CLI wrapper for this:
from omero.cli import CLI
cli = CLI()
cli.loadplugins()
# NOTE: cli._client should be replaced with cli.set_client() when switching
# to support for OMERO 5.1 and later only:
cli._client = conn.c
import_args = ["import"]
import_args.extend(['-d', dset_id])
if comment is not None:
import_args.extend(['--annotation_ns', namespace])
import_args.extend(['--annotation_text', comment])
#### for ann_id in annotations:
#### import_args.extend(['--annotation_link', str(ann_id)])
import_args.append(image_file)
# print("import_args: " + str(import_args))
try:
cli.invoke(import_args, strict=True)
except:
print('ERROR: uploading "%s" to %s failed!' % (image_file, id_str))
# print(import_args)
return False
return True
示例14: TestImport
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
class TestImport(object):
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]
def mkdir(self, parent, name, with_ds_store=False):
child = parent / name
child.mkdir()
if with_ds_store:
ds_store = child / ".DS_STORE"
ds_store.write("")
return child
def mkfakescreen(self, screen_dir, nplates=2, nruns=2, nwells=2,
nfields=4, with_ds_store=False):
fieldfiles = []
for iplate in range(nplates):
plate_dir = self.mkdir(
screen_dir, "Plate00%s" % str(iplate),
with_ds_store=with_ds_store)
for irun in range(nruns):
run_dir = self.mkdir(
plate_dir, "Run00%s" % str(irun),
with_ds_store=with_ds_store)
for iwell in range(nwells):
well_dir = self.mkdir(
run_dir, "WellA00%s" % str(iwell),
with_ds_store=with_ds_store)
for ifield in range(nfields):
fieldfile = (well_dir / ("Field00%s.fake" %
str(ifield)))
fieldfile.write('')
fieldfiles.append(fieldfile)
return fieldfiles
def testDropBoxArgs(self):
class MockImportControl(ImportControl):
def importer(this, args):
assert args.server == "localhost"
assert args.port == "4064"
assert args.key == "b0742975-03a1-4f6d-b0ac-639943f1a147"
assert args.errs == "/Users/cblackburn/omero/tmp/\
omero_cblackburn/6915/dropboxuUGl5rerr"
assert args.file == "/Users/cblackburn/omero/tmp/\
omero_cblackburn/6915/dropboxaDCjQlout"
self.cli.register("mock-import", MockImportControl, "HELP")
self.args = ['-s', 'localhost', '-p', '4064', '-k',
'b0742975-03a1-4f6d-b0ac-639943f1a147']
self.args += ['mock-import', '---errs=/Users/cblackburn/omero/tmp/\
omero_cblackburn/6915/dropboxuUGl5rerr']
self.args += ['---file=/Users/cblackburn/omero/tmp/\
omero_cblackburn/6915/dropboxaDCjQlout']
self.args += ['--', '/OMERO/DropBox/root/tinyTest.d3d.dv']
self.cli.invoke(self.args)
@pytest.mark.parametrize('help_argument', help_arguments)
def testHelp(self, help_argument):
"""Test help arguments"""
self.args += [help_argument]
self.cli.invoke(self.args)
@pytest.mark.parametrize("data", (("1", False), ("3", True)))
def testImportDepth(self, tmpdir, capfd, data):
"""Test import using depth argument"""
dir1 = tmpdir.join("a")
dir1.mkdir()
dir2 = dir1 / "b"
dir2.mkdir()
fakefile = dir2 / "test.fake"
fakefile.write('')
self.args += ["-f", "--debug=ERROR"]
self.args += [str(dir1)]
depth, result = data
self.cli.invoke(self.args + ["--depth=%s" % depth], strict=True)
o, e = capfd.readouterr()
if result:
assert str(fakefile) in str(o)
else:
assert str(fakefile) not in str(o)
def testImportFakeImage(self, tmpdir, capfd):
"""Test fake image import"""
fakefile = tmpdir.join("test.fake")
fakefile.write('')
self.args += ["-f", "--debug=ERROR"]
#.........这里部分代码省略.........
示例15: TestTag
# 需要导入模块: from omero.cli import CLI [as 别名]
# 或者: from omero.cli.CLI import invoke [as 别名]
class TestTag(object):
def setup_method(self, method):
self.cli = CLI()
self.cli.register("tag", TagControl, "TEST")
self.args = ["tag"]
def testHelp(self):
self.args += ["-h"]
self.cli.invoke(self.args, strict=True)
@pytest.mark.parametrize('subcommand', TagControl().get_subcommands())
def testSubcommandHelp(self, subcommand):
self.args += [subcommand, "-h"]
self.cli.invoke(self.args, strict=True)
def testCreateTagsetFails(self):
self.args += ["createset", "--tag", "A"]
with pytest.raises(NonZeroReturnCode):
self.cli.invoke(self.args, strict=True)
def testListFails(self):
self.args += ["list", "--tagset", "tagset"]
with pytest.raises(NonZeroReturnCode):
self.cli.invoke(self.args, strict=True)
def testListsetsFails(self):
self.args += ["listsets", "--tag", "tag"]
with pytest.raises(NonZeroReturnCode):
self.cli.invoke(self.args, strict=True)
@pytest.mark.parametrize(
('object_arg', 'tag_arg'),
[('Image:1', 'test'), ('Image', '1'), ('Image:image', '1'),
('1', '1')])
def testLinkFails(self, object_arg, tag_arg):
self.args += ["link", object_arg, tag_arg]
with pytest.raises(NonZeroReturnCode):
self.cli.invoke(self.args, strict=True)