Package omero.api
Interface _IScriptOperationsNC
-
- All Superinterfaces:
_ServiceInterfaceOperationsNC
- All Known Subinterfaces:
IScript
- All Known Implementing Classes:
_IScriptDisp
,_IScriptTie
public interface _IScriptOperationsNC extends _ServiceInterfaceOperationsNC
Utility service for managing and launching scripts for execution by the Processor API. Typical usage might include (PYTHON):sf = client.createSession() svc = sf.getScriptService() scripts = svc.getScripts() if len(scripts) >= 1: script_id = svc.keys()\[-1] else: script_id = svc.uploadScript('/test/my_script.py', SCRIPT_TEXT) params = svc.getParams(script_id) # You will need to parse the params to create the proper input inputs = {} # The last parameter is how long to wait as an RInt proc = svc.runScript(script_id, inputs, None) try: cb = omero.scripts.ProcessCallbackI(client, proc) while not cb.block(1000): # ms. pass cb.close() rv = proc.getResults(0) finally: proc.close(False)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
canRunScript_async(AMD_IScript_canRunScript __cb, long scriptID)
Returns true if there is a processor which will run the given script.void
deleteScript_async(AMD_IScript_deleteScript __cb, long scriptID)
Delete the script on the server with id.void
editScript_async(AMD_IScript_editScript __cb, OriginalFile fileObject, java.lang.String scriptText)
Modify the text for the given script object.void
getParams_async(AMD_IScript_getParams __cb, long scriptID)
Get the parameters that the script takes and returns, along with other metadata available from the script.void
getScriptID_async(AMD_IScript_getScriptID __cb, java.lang.String path)
Get the id of an official script by the script path.void
getScripts_async(AMD_IScript_getScripts __cb)
This method returns official server scripts as a list ofOriginalFile
objects.void
getScriptsByMimetype_async(AMD_IScript_getScriptsByMimetype __cb, java.lang.String mimetype)
This method returns official server scripts identified with the specified extension as a list ofOriginalFile
objects.void
getScriptText_async(AMD_IScript_getScriptText __cb, long scriptID)
Get the text from the server for the script with given id.void
getScriptWithDetails_async(AMD_IScript_getScriptWithDetails __cb, long scriptID)
Get the script from the server with details from OriginalFilevoid
getUserScripts_async(AMD_IScript_getUserScripts __cb, java.util.List<IObject> acceptsList)
Returns non-official scripts which have been uploaded by individual users.void
runScript_async(AMD_IScript_runScript __cb, long scriptID, java.util.Map<java.lang.String,RType> inputs, RInt waitSecs)
IfResourceError
is thrown, then noProcessor
is available.void
uploadOfficialScript_async(AMD_IScript_uploadOfficialScript __cb, java.lang.String path, java.lang.String scriptText)
LikeuploadScript
but is only callable by administrators.void
uploadScript_async(AMD_IScript_uploadScript __cb, java.lang.String path, java.lang.String scriptText)
Upload a user script to the server and return the id.void
validateScript_async(AMD_IScript_validateScript __cb, Job j, java.util.List<IObject> acceptsList)
Used internally by processor.py to check if the script attached to theJob
has a valid script attached, based on theacceptsList
and the current security context.
-
-
-
Method Detail
-
getScripts_async
void getScripts_async(AMD_IScript_getScripts __cb) throws ServerError
This method returns official server scripts as a list ofOriginalFile
objects. These scripts will be executed by the server if submitted viarunScript
. The input parameters necessary for proper functioning can be retrieved viagetParams
. TheOriginalFile.path
value can be used in other official scripts via the language specific import command, since the script directory will be placed on the appropriate environment path variable.scripts = scriptService.getScripts() for script in scripts: text = scriptService.getScriptText(script.id.val) # First character is a "/" symbol path = script.path.val\[1:\] path = path.replace("/",".") print "Possible import: %s" % path
- Parameters:
__cb
- The callback object for the operation.- Throws:
ApiUsageException
SecurityViolation
ServerError
-
getScriptsByMimetype_async
void getScriptsByMimetype_async(AMD_IScript_getScriptsByMimetype __cb, java.lang.String mimetype) throws ServerError
This method returns official server scripts identified with the specified extension as a list ofOriginalFile
objects. These scripts will be executed by the server if submitted viarunScript
. The input parameters necessary for proper functioning can be retrieved viagetParams
. TheOriginalFile.path
value can be used in other official scripts via the language specific import command, since the script directory will be placed on the appropriate environment path variable.scripts = scriptService.getScripts("py") for script in scripts: text = scriptService.getScriptText(script.id.val) path = script.path.val\[1:\] # First symbol is a "/" path = path.replace("/",".") print "Possible import: %s" % path
- Parameters:
__cb
- The callback object for the operation.mimetype
- the mimetype identifying the scripts.- Throws:
ApiUsageException
SecurityViolation
ServerError
-
getUserScripts_async
void getUserScripts_async(AMD_IScript_getUserScripts __cb, java.util.List<IObject> acceptsList) throws ServerError
Returns non-official scripts which have been uploaded by individual users. These scripts will not be run by the server, though a user can start a personal usermode processor which will allow the scripts to be executed. This is particularly useful for testing new scripts.- Parameters:
__cb
- The callback object for the operation.- Throws:
ServerError
-
getScriptID_async
void getScriptID_async(AMD_IScript_getScriptID __cb, java.lang.String path) throws ServerError
Get the id of an official script by the script path. The script service ensures that all script paths are unique. Note: there is no similar method for user scripts (e.g.getUserScriptID
) since the path is not guaranteed to be unique.- Parameters:
__cb
- The callback object for the operation.path
- The name of the script.- Throws:
ApiUsageException
SecurityViolation
ServerError
-
getScriptText_async
void getScriptText_async(AMD_IScript_getScriptText __cb, long scriptID) throws ServerError
Get the text from the server for the script with given id.- Parameters:
__cb
- The callback object for the operation.scriptID
- see above.- Throws:
ApiUsageException
ServerError
-
uploadScript_async
void uploadScript_async(AMD_IScript_uploadScript __cb, java.lang.String path, java.lang.String scriptText) throws ServerError
Upload a user script to the server and return the id. This method checks that a script with that names does not exist and that the script has parameters if possible, i.e. a usermode processor is running which for the current user.- Parameters:
__cb
- The callback object for the operation.path
- see above.- Throws:
ApiUsageException
SecurityViolation
ServerError
-
uploadOfficialScript_async
void uploadOfficialScript_async(AMD_IScript_uploadOfficialScript __cb, java.lang.String path, java.lang.String scriptText) throws ServerError
LikeuploadScript
but is only callable by administrators. The parameters for the script are also checked.- Parameters:
__cb
- The callback object for the operation.- Throws:
ServerError
-
editScript_async
void editScript_async(AMD_IScript_editScript __cb, OriginalFile fileObject, java.lang.String scriptText) throws ServerError
Modify the text for the given script object.- Parameters:
__cb
- The callback object for the operation.fileObject
- see above.- Throws:
ApiUsageException
SecurityViolation
ServerError
-
getScriptWithDetails_async
void getScriptWithDetails_async(AMD_IScript_getScriptWithDetails __cb, long scriptID) throws ServerError
Get the script from the server with details from OriginalFile- Parameters:
__cb
- The callback object for the operation.scriptID
- see above- Throws:
ApiUsageException
ServerError
-
getParams_async
void getParams_async(AMD_IScript_getParams __cb, long scriptID) throws ServerError
Get the parameters that the script takes and returns, along with other metadata available from the script.- Parameters:
__cb
- The callback object for the operation.scriptID
- see above.- Throws:
ApiUsageException
ServerError
-
deleteScript_async
void deleteScript_async(AMD_IScript_deleteScript __cb, long scriptID) throws ServerError
Delete the script on the server with id. The file will also be removed from disk.- Parameters:
__cb
- The callback object for the operation.scriptID
- Id of the script to delete.- Throws:
ApiUsageException
SecurityViolation
ServerError
-
runScript_async
void runScript_async(AMD_IScript_runScript __cb, long scriptID, java.util.Map<java.lang.String,RType> inputs, RInt waitSecs) throws ServerError
IfResourceError
is thrown, then noProcessor
is available. UsescheduleJob
to create aScriptJob
in the Waiting state. AProcessor
may become available.try: proc = scriptService.runScript(1, {}, None) except ResourceError: job = scriptService.scheduleScript(1, {}, None)
ScriptProcess
proxy MUST be closed before exiting. If you would like the script execution to continue in the background, passTrue
as the argument.try: proc.poll() # See if process is finished finally: proc.close(True) # Detach and execution can continue # proc.close(False) # OR script is immediately stopped.
- Parameters:
__cb
- The callback object for the operation.- Throws:
ServerError
-
canRunScript_async
void canRunScript_async(AMD_IScript_canRunScript __cb, long scriptID) throws ServerError
Returns true if there is a processor which will run the given script.Either the script is an official script and this method will return true (though an individual invocation may fail with an
ResourceError
for some reason) or this is a user script, and a usermode processor must be active which takes the scripts user or group.- Parameters:
__cb
- The callback object for the operation.- Throws:
ServerError
-
validateScript_async
void validateScript_async(AMD_IScript_validateScript __cb, Job j, java.util.List<IObject> acceptsList) throws ServerError
Used internally by processor.py to check if the script attached to theJob
has a valid script attached, based on theacceptsList
and the current security context. An example of an acceptsList might beExperimenter(myUserId, False)
, meaning that only scripts belonging to me should be trusted. An empty list implies that the server should return what it would by default trust. A valid script will be returned if it exists; otherwise null.- Parameters:
__cb
- The callback object for the operation.- Throws:
ServerError
-
-