1
2 """
3 Scripting types
4 - Classes:
5 - Type -- Top of parameter type hierarchy
6 - Long --
7 - String --
8 - Bool --
9
10 - Functions:
11 - client -- Produces an omero.client object with given input/output constraints.
12
13 Copyright 2008 Glencoe Software, Inc. All rights reserved.
14 Use is subject to license terms supplied in LICENSE.txt
15
16 """
17
18 import exceptions, omero
19 from omero.rtypes import *
20
22 - def __init__(self, name, optional = False, out = False):
23 self.name = name
24 self.type = None
25 self.optional = optional
26 self._in = True
27 self._out = out
29 self._in = False
30 self._out = True
31 return self
33 self._in = True
34 self._out = True
35 return self
39
41 - def __init__(self, name, optional = False, out = False):
45 - def __init__(self, name, optional = False, out = False):
49 - def __init__(self, name, optional = False, out = False):
53 - def __init__(self, name, optional = False, out = False):
57 - def __init__(self, name, optional = False, out = False):
61 - def __init__(self, name, optional = False, out = False, *contents):
65 - def __init__(self, name, optional = False, out = False, **contents):
68
70 """
71 Raised when this script should just parse parameters and return.
72 """
73
75 exceptions.Exception.__init__(self)
76 self.params = params
77
78 -def client(name, description = None, *args, **kwargs):
79 """
80 Entry point for all script engine scripts.
81
82 Typical usage consists of::
83
84 client = omero.scripts.client("name","description", \
85 omero.scripts.Long("name"),...)
86
87 where the returned client is created via the empty constructor to omero.client
88 using only --Ice.Config or ICE_CONFIG, and the function arguments are taken
89 as metdata about the current script. With this information, all script
90 consumers should be able to determine the required types for execution.
91
92 Possible types are all subclasses of omero.scripts.Type
93
94 To change the omero.model.Format of the stdout and stderr produced by
95 this script, use the constructor arguments::
96
97 client = omero.scripts.client(..., \
98 stdoutFormat = "text/plain",
99 stderrFormat = "text/plain")
100
101 If you would like to prevent stdout and/or stderr from being
102 uploaded, set the corresponding value to None. If you would like
103 to overwrite the value with another file, use
104 client.setOutput(). Though it is possible to attach any RType to
105 "stdout" or "stderr", there is an assumption that the value will
106 be an robject(OriginalFileI())
107
108 Providing your own client is possible via the kwarg "client = ...",
109 but be careful since this may break usage with the rest of the
110 scripting framework. The client should not have a session, and
111 must be configured for the argumentless version of createSession()
112 """
113
114
115 if not kwargs.has_key("stdoutFormat"):
116 kwargs["stdoutFormat"]="text/plain"
117 if not kwargs.has_key("stderrFormat"):
118 kwargs["stderrFormat"]="text/plain"
119 if not kwargs.has_key("client"):
120 kwargs["client"] = omero.client()
121
122 c = kwargs["client"]
123 c.params = omero.grid.JobParams()
124 c.params.name = name
125 c.params.description = description
126 c.params.inputs = {}
127 c.params.outputs = {}
128 c.params.stdoutFormat = kwargs["stdoutFormat"]
129 c.params.stderrFormat = kwargs["stderrFormat"]
130 for p in args:
131 param = omero.grid.Param()
132 param.name = p.name
133 param.optional = p.optional
134 param.prototype = p.type
135 if p._in:
136 c.params.inputs[p.name] = param
137 if p._out:
138 c.params.outputs[p.name] = param
139
140 c.createSession().detachOnDestroy()
141 handleParse(c)
142 return c
143
148