Beispiel #1
0
 def edit(self, args, config, edit_path=edit_path):
     from omero.util.temp_files import create_path, remove_path
     start_text = "# Edit your preferences below. Comments are ignored\n"
     for k in sorted(config.keys()):
         start_text += ("%s=%s\n" % (k, config[k]))
     temp_file = create_path()
     try:
         edit_path(temp_file, start_text)
     except RuntimeError as re:
         self.ctx.dbg(traceback.format_exc())
         self.ctx.die(
             954, "%s: Failed to edit %s" %
             (getattr(re, "pid", "Unknown"), temp_file))
     args.NAME = config.default()
     old_config = dict(config)
     self.drop(args, config)
     args.file = [open(str(temp_file), "r")]
     args.q = True
     try:
         self.load(args, config)
     except Exception as e:
         for key, value in list(old_config.items()):
             config[key] = value
         raise e
     finally:
         remove_path(temp_file)
 def edit(self, args, config, edit_path = edit_path):
     from omero.util.temp_files import create_path, remove_path
     start_text = "# Edit your preferences below. Comments are ignored\n"
     for k in sorted(config.keys()):
         start_text += ("%s=%s\n" % (k, config[k]))
     temp_file = create_path()
     try:
         edit_path(temp_file, start_text)
     except RuntimeError, re:
         self.ctx.die(954, "%s: Failed to edit %s" % (getattr(re, "pid", "Unknown"), temp_file))
Beispiel #3
0
 def edit(self, args, config, edit_path = edit_path):
     from omero.util.temp_files import create_path, remove_path
     start_text = "# Edit your preferences below. Comments are ignored\n"
     for k in sorted(config.keys()):
         start_text += ("%s=%s\n" % (k, config[k]))
     temp_file = create_path()
     try:
         edit_path(temp_file, start_text)
     except RuntimeError, re:
         self.ctx.die(954, "%s: Failed to edit %s" % (getattr(re, "pid", "Unknown"), temp_file))
 def edit(self, args):
     client = self.ctx.conn(args)
     scriptSvc = client.sf.getScriptService()
     script_id, ofile = self._file(args, client)
     try:
         txt = client.sf.getScriptService().getScriptText(script_id)
         from omero.util.temp_files import create_path
         from omero.util import edit_path
         p = create_path()
         edit_path(p, txt)
         scriptSvc.editScript(ofile, p.text())
     except exceptions.Exception, e:
         self.ctx.err("Failed to find script: %s (%s)" % (script_id, e))
Beispiel #5
0
 def edit(self, args):
     client = self.ctx.conn(args)
     scriptSvc = client.sf.getScriptService()
     script_id, ofile = self._file(args, client)
     txt = None
     try:
         txt = client.sf.getScriptService().getScriptText(script_id)
         if not txt:
             self.ctx.err("No text for script: %s" % script_id)
             self.ctx.err("Does this file appear in the script list?")
             self.ctx.err("If not, try 'replace'")
             return
         from omero.util.temp_files import create_path
         from omero.util import edit_path
         p = create_path()
         edit_path(p, txt)
         scriptSvc.editScript(ofile, p.text())
     except Exception as e:
         self.ctx.err("Failed to find script: %s (%s)" % (script_id, e))
Beispiel #6
0
 def edit(self, args):
     client = self.ctx.conn(args)
     scriptSvc = client.sf.getScriptService()
     script_id, ofile = self._file(args, client)
     txt = None
     try:
         txt = client.sf.getScriptService().getScriptText(script_id)
         if not txt:
             self.ctx.err("No text for script: %s" % script_id)
             self.ctx.err("Does this file appear in the script list?")
             self.ctx.err("If not, try 'replace'")
             return
         from omero.util.temp_files import create_path
         from omero.util import edit_path
         p = create_path()
         edit_path(p, txt)
         scriptSvc.editScript(ofile, p.text())
     except Exception, e:
         self.ctx.err("Failed to find script: %s (%s)" % (script_id, e))
Beispiel #7
0
    def edit_options(self, req, specmap):

        from omero.util import edit_path
        from omero.util.temp_files import create_path, remove_path

        start_text = """# Edit options for your operation below.\n"""
        start_text += ("# === %s ===\n" % req.type)
        if req.type not in specmap:
            self.ctx.die(162, "Unknown type: %s" % req.type)
        start_text += self.append_options(req.type, dict(specmap))

        temp_file = create_path()
        try:
            edit_path(temp_file, start_text)
            txt = temp_file.text()
            print txt
            rv = dict()
            for line in txt.split("\n"):
                self.line_to_opts(line, rv)
            return rv
        except RuntimeError, re:
            self.ctx.die(954, "%s: Failed to edit %s" % (getattr(re, "pid", "Unknown"), temp_file))