From c81c3e687047ff191ee70f9208181cdc3b9a8004 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Tue, 19 Nov 2019 14:47:33 +0000 Subject: [PATCH 1/4] Enforce CLI plugins are sorted before loading --- src/omero/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omero/cli.py b/src/omero/cli.py index 57cb569ad..2d7ff3761 100755 --- a/src/omero/cli.py +++ b/src/omero/cli.py @@ -1646,7 +1646,7 @@ def loadplugins(self): def loadpath(self, pathobj): if pathobj.isdir(): - for plugin in pathobj.walkfiles("*.py"): + for plugin in sorted(pathobj.walkfiles("*.py")): if -1 == plugin.find("#"): # Omit emacs files self.loadpath(path(plugin)) else: From 9160a889ecc83b8a6e89445c7b5261e1df6f4076 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Tue, 19 Nov 2019 15:13:07 +0000 Subject: [PATCH 2/4] Rename metadata and upload plugins as deprecated --- src/omero/plugins/{metadata.py => _metadata_deprecated.py} | 0 src/omero/plugins/{upload.py => _upload_deprecated.py} | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/omero/plugins/{metadata.py => _metadata_deprecated.py} (100%) rename src/omero/plugins/{upload.py => _upload_deprecated.py} (94%) diff --git a/src/omero/plugins/metadata.py b/src/omero/plugins/_metadata_deprecated.py similarity index 100% rename from src/omero/plugins/metadata.py rename to src/omero/plugins/_metadata_deprecated.py diff --git a/src/omero/plugins/upload.py b/src/omero/plugins/_upload_deprecated.py similarity index 94% rename from src/omero/plugins/upload.py rename to src/omero/plugins/_upload_deprecated.py index cfed6b673..fec6a7aef 100755 --- a/src/omero/plugins/upload.py +++ b/src/omero/plugins/_upload_deprecated.py @@ -53,7 +53,7 @@ def _configure(self, parser): def upload(self, args): self.ctx.err( "This module is deprecated as of OMERO 5.5.0. Use the module" - " available from https://pypi.org/project/omero-cli-upload/" + " available from https://pypi.org/project/omero-upload/" " instead.", DeprecationWarning) client = self.ctx.conn(args) objIds = [] @@ -76,7 +76,7 @@ def upload(self, args): warnings.warn( "This plugin is deprecated as of OMERO 5.5.0. Use the upload" " CLI plugin available from" - " https://pypi.org/project/omero-cli-upload/ instead.", + " https://pypi.org/project/omero-upload/ instead.", DeprecationWarning) register("upload", UploadControl, HELP) except NameError: From f2388c448a1a396a07f14c727537c2b72abf3c3b Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Tue, 26 Nov 2019 11:29:56 +0000 Subject: [PATCH 3/4] Add deprecation message to all subcommands of the deprecated metadata plugin --- src/omero/plugins/_metadata_deprecated.py | 46 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/omero/plugins/_metadata_deprecated.py b/src/omero/plugins/_metadata_deprecated.py index b5a2ca290..9b89db924 100755 --- a/src/omero/plugins/_metadata_deprecated.py +++ b/src/omero/plugins/_metadata_deprecated.py @@ -285,6 +285,10 @@ def _format_ann(self, md, obj, indent=None): def summary(self, args): "Provide a general summary of available metadata" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) name = md.get_name() line = "-" * len(name) @@ -332,6 +336,10 @@ def summary(self, args): def original(self, args): "Print the original metadata in ini format" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) try: source, global_om, series_om = md.get_original() @@ -370,6 +378,10 @@ def _output_ann(self, mdobj, func, parents, indent): def bulkanns(self, args): ("Provide a list of the NSBULKANNOTATION tables linked " "to the given object") + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -380,6 +392,10 @@ def bulkanns(self, args): def measures(self, args): ("Provide a list of the NSMEASUREMENT tables linked " "to the given object") + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -394,7 +410,10 @@ def get_anns(md): if args.nsre and not re.match(args.nsre, a.get_ns()): continue yield a - + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -408,7 +427,10 @@ def get_anns(md): if args.nsre and not re.match(args.nsre, a.get_ns()): continue yield a - + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -417,6 +439,10 @@ def get_anns(md): def testtables(self, args): "Tests whether tables can be created and initialized" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) client, conn = self._clientconn(args) sf = client.getSession() @@ -449,6 +475,10 @@ def testtables(self, args): def populate(self, args): "Add metadata (bulk-annotations) to an object" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) client, conn = self._clientconn(args) # TODO: Configure logging properly @@ -500,6 +530,10 @@ def populate(self, args): def rois(self, args): "Manage ROIs" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) if args.delete: graphspec = "/%s/Roi:%d" % (md.get_type(), md.get_id()) @@ -545,6 +579,10 @@ def rois(self, args): def populateroi(self, args): "Add ROIs to an object" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) md = self._load(args) client = self.ctx.conn(args) # TODO: Configure logging properly @@ -574,6 +612,10 @@ def populateroi(self, args): def pixelsize(self, args): "Set physical pixel size" + self.ctx.err( + "This module is deprecated as of OMERO 5.4.8. Use the module" + " available from https://pypi.org/project/omero-metadata/" + " instead.", DeprecationWarning) if not args.x and not args.y and not args.z: self.ctx.die(100, "No pixel sizes specified.") From 1440c773aa7d94100bbd0c11bedab5193582a8c5 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Tue, 26 Nov 2019 20:53:13 +0000 Subject: [PATCH 4/4] Reduce the amount of copy-paste --- src/omero/plugins/_metadata_deprecated.py | 65 ++++++----------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/src/omero/plugins/_metadata_deprecated.py b/src/omero/plugins/_metadata_deprecated.py index 9b89db924..496337aa3 100755 --- a/src/omero/plugins/_metadata_deprecated.py +++ b/src/omero/plugins/_metadata_deprecated.py @@ -40,6 +40,10 @@ GUI clients. """ +DEPRECATION_MESSAGE = ( + "This plugin is deprecated as of OMERO 5.4.8. Use the plugin" + " available from https://pypi.org/project/omero-metadata/" + " instead.") ANNOTATION_TYPES = [t for t in dir(omero.model) if re.match(r'[A-Za-z0-9]+Annotation$', t)] @@ -285,10 +289,7 @@ def _format_ann(self, md, obj, indent=None): def summary(self, args): "Provide a general summary of available metadata" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) name = md.get_name() line = "-" * len(name) @@ -336,10 +337,7 @@ def summary(self, args): def original(self, args): "Print the original metadata in ini format" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) try: source, global_om, series_om = md.get_original() @@ -378,10 +376,7 @@ def _output_ann(self, mdobj, func, parents, indent): def bulkanns(self, args): ("Provide a list of the NSBULKANNOTATION tables linked " "to the given object") - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -392,10 +387,7 @@ def bulkanns(self, args): def measures(self, args): ("Provide a list of the NSMEASUREMENT tables linked " "to the given object") - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -410,10 +402,7 @@ def get_anns(md): if args.nsre and not re.match(args.nsre, a.get_ns()): continue yield a - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -427,10 +416,7 @@ def get_anns(md): if args.nsre and not re.match(args.nsre, a.get_ns()): continue yield a - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) indent = None if args.report: @@ -439,10 +425,7 @@ def get_anns(md): def testtables(self, args): "Tests whether tables can be created and initialized" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) client, conn = self._clientconn(args) sf = client.getSession() @@ -475,10 +458,7 @@ def testtables(self, args): def populate(self, args): "Add metadata (bulk-annotations) to an object" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) client, conn = self._clientconn(args) # TODO: Configure logging properly @@ -530,10 +510,7 @@ def populate(self, args): def rois(self, args): "Manage ROIs" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) if args.delete: graphspec = "/%s/Roi:%d" % (md.get_type(), md.get_id()) @@ -579,10 +556,7 @@ def rois(self, args): def populateroi(self, args): "Add ROIs to an object" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) md = self._load(args) client = self.ctx.conn(args) # TODO: Configure logging properly @@ -612,10 +586,7 @@ def populateroi(self, args): def pixelsize(self, args): "Set physical pixel size" - self.ctx.err( - "This module is deprecated as of OMERO 5.4.8. Use the module" - " available from https://pypi.org/project/omero-metadata/" - " instead.", DeprecationWarning) + self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) if not args.x and not args.y and not args.z: self.ctx.die(100, "No pixel sizes specified.") @@ -677,11 +648,7 @@ def pixelsize(self, args): try: if "OMERO_DEV_PLUGINS" in os.environ: - warnings.warn( - "This module is deprecated as of OMERO 5.4.8. Use the metadata" - " CLI plugin available from" - " https://pypi.org/project/omero-metadata/ instead.", - DeprecationWarning) + warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning) register("metadata", MetadataControl, HELP) except NameError: if __name__ == "__main__":