port = match.group('port') if not name: name = default_name return server, name, port def _get_server(self, store, name): defserver = store.last_host() rv = self.ctx.input("Server: [%s]" % defserver) if not rv: return defserver, name, None else: return self._parse_conn(rv, name) def _get_username(self, defuser): if defuser is None: defuser = get_user("root") rv = self.ctx.input("Username: [%s]" % defuser) if not rv: return defuser else: return rv try: register("sessions", SessionsControl, HELP) except NameError: if __name__ == "__main__": cli = CLI() cli.register("sessions", SessionsControl, HELP) cli.invoke(sys.argv[1:])
def setup_method(self, method): self.cli = CLI() self.cli.register("fs", FsControl, "TEST") self.args = ["fs"]
def setup_method(self, tmpadmindir): self.cli = CLI() self.cli.dir = path(tmpadmindir) self.cli.register("admin", AdminControl, "TEST") self.cli.register("config", PrefsControl, "TEST") self.args = ["admin", "rewrite"]
def setup_method(self): self.cli = CLI() self.cli.register("render", RenderControl, "TEST") self.render = self.cli.controls['render']
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
def setup_method(self, method): self.cli = CLI() self.cli.register("config", PrefsControl, HELP) self.p = create_path() self.args = ["-d1", "config", "--source", "%s" % self.p]
def setup_method(self, method): self.cli = CLI() self.cli.register("hql", HqlControl, "TEST") self.args = ["hql"]
def cli(self): cli = CLI() cli.register("upload", UploadControl, "TEST") cli.register("sessions", SessionsControl, "TEST") cli.register("s", ScriptControl, "TEST") return cli
def testOne(self): cli = CLI() cli.register("t", TestRCode.T, "TEST") cli.invoke(["t"]) assert cli.rv == 1, cli.rv
def setup_method(self, method): self.cli = CLI() self.cli.register("import", ImportControl, "TEST") self.args = ["import"]
def setup_class(cls): super(AbstractCLITest, cls).setup_class() cls.cli = CLI() cls.cli.register("sessions", SessionsControl, "TEST")
def setup_method(self, method): self.cli = CLI() self.cli.register("user", UserControl, "TEST") self.args = ["user"]
def setup_method(self, method): self.cli = CLI() self.cli.register("tag", TagControl, "TEST") self.args = ["tag"]
def setup_method(self, method): self.cli = CLI() self.cli.register("script", ScriptControl, "TEST") self.args = ["script"]