1
2 """
3 Startup plugin for command-line importer.
4
5 Copyright 2009 Glencoe Software, Inc. All rights reserved.
6 Use is subject to license terms supplied in LICENSE.txt
7
8 """
9
10 import subprocess, optparse, os, sys, signal, time
11 from omero.cli import Arguments, BaseControl, CLI, VERSION, OMERODIR
12 import omero.java
13
14 START_CLASS="ome.formats.importer.cli.CommandLineImporter"
15 TEST_CLASS="ome.formats.test.util.TestEngine"
16
18
22
23 - def _run(self, args = []):
24 args = Arguments(args)
25 client_dir = self.ctx.dir / "lib" / "client"
26 log4j = "-Dlog4j.configuration=log4j-cli.properties"
27 classpath = [ file.abspath() for file in client_dir.files("*.jar") ]
28 xargs = [ log4j, "-Xmx1024M", "-cp", os.pathsep.join(classpath) ]
29
30
31
32
33 out = None
34 err = None
35 for i in args.args:
36 if i.startswith("---file="):
37 out = i
38 if i.startswith("---errs="):
39 err = i
40 if out:
41 args.args.remove(out)
42 out = open(out[8:], "w")
43 if err:
44 args.args.remove(err)
45 err = open(err[8:], "w")
46
47 p = omero.java.popen(self.command + args.args, debug=False, xargs = xargs, stdout=out, stderr=err)
48 self.ctx.rv = p.wait()
49
50 - def help(self, args = None):
52
56
57
63
64 try:
65 register("import", ImportControl)
66 register("testengine", TestEngine)
67 except NameError:
68 ImportControl(None)._main()
69