Skip to content
Snippets Groups Projects
Commit 08668bd9 authored by BIGARET Sebastien's avatar BIGARET Sebastien
Browse files

1st version of Praxis w/ a generic service allowing to execute any script.

A new type has been added for parameters'descriptions: TEXT.  It is
equivalent to STRING, with the only difference that it is displayed
using a text area in the dialog dedicated to programs' parameters,
instead of a simple text field.

A new service 'generic' has been added to project 'test' to
demonstrate the feature.
parent c6c0a35c
No related branches found
No related tags found
No related merge requests found
Pipeline #75 failed
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
ismandatory %boolean; #IMPLIED ismandatory %boolean; #IMPLIED
ishidden %boolean; #IMPLIED ishidden %boolean; #IMPLIED
isexpert %boolean; #IMPLIED isexpert %boolean; #IMPLIED
type (command | code | input | output | input-directory | output-directory | int | float | string | boolean | enum | List ) #REQUIRED type (command | code | input | output | input-directory | output-directory | int | float | string | text | boolean | enum | List ) #REQUIRED
create-directory %boolean; #IMPLIED create-directory %boolean; #IMPLIED
> >
......
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
<program id="test___cat_input_with_vdef___1.0"/> <program id="test___cat_input_with_vdef___1.0"/>
<program id="test___sleep___1.0"/> <program id="test___sleep___1.0"/>
<program id="test___failure___1.0"/> <program id="test___failure___1.0"/>
<program id="test___generic___1.0"/>
</programs> </programs>
</platform> </platform>
application.id=test application.id=test
ALL=YELLOW ALL=BLACK
OTHER=WHITE OTHER=WHITE
BANK=WHITE
FILE=GREEN FILE=GREEN
# Universal types can be connected to any type # Universal types can be connected to any type
universal_types=ALL universal_types=ALL
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
<resource name="test___cat_input_with_vdef___1.0" /> <resource name="test___cat_input_with_vdef___1.0" />
<resource name="test___sleep___1.0" /> <resource name="test___sleep___1.0" />
<resource name="test___failure___1.0" /> <resource name="test___failure___1.0" />
<resource name="test___generic___1.0" />
</type> </type>
</resourcesTree> </resourcesTree>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE program_description PUBLIC "-//Telecom Bretagne/DTD XML Praxis Program Description 3.0//EN" "http://perso.telecom-bretagne.eu/~bigaret/praxis/dtd/program_description.dtd">
<program_description export_date="2009-08-15 18:30" modification_date="2009-08-15 18:30">
<program provider="test" name="generic" version="1.0" />
<from desc_id="S9999" />
<description>A generic box allowing to execute commands and custom scripts
- The input file is named 'infile'.
- An output file should be written, named 'outfile'.
- The script, if used, will be written in a file named 'script' before the command-line is executed.
Example: a program reading the infile in python and numbering the lines
cmdline: 'python script infile outfile' (without the quotes)
Use a script: Yes
Script (until "# end"):
import sys
print "argv: ", sys.argv
# here, sys.argv[0] is 'script'
input=sys.argv[1]
output=sys.argv[2]
idx=0
output=open(output, 'w')
for line in open(input):
output.write("%i: %s"%(idx, line))
idx += 1
output.close()
# end
Remarks:
- the cmdline launches python on the script file:
- the script reads its arguments from the command-line; another solution would be to hard-code the name "infile" and "outfile" in the script itself.
</description>
<parameters>
<parameter id="generic_cmd" type="string">
<name>cmdline</name>
<description>Command-line</description>
<position>1</position>
<code>%s</code>
<vdef />
</parameter>
<parameter id="infile" ishidden="0" type="input">
<name>infile </name>
<description>Input data file</description>
<position>200</position>
<code />
<types>
<type>all</type>
</types>
<vdef>infile</vdef>
</parameter>
<parameter id="outfile" ishidden="0" type="output">
<name>outfile</name>
<description>Output data file</description>
<position>300</position>
<code />
<types>
<type>all</type>
</types>
<vdef>outfile</vdef>
</parameter>
<parameter id="provide_script" ishidden="0" type="boolean">
<name>Use a script? </name>
<indent>0</indent>
<description> Produce second output? </description>
<position>0</position>
<code />
<vdef>0</vdef>
<dep/>
</parameter>
<parameter id="script" ishidden="0" type="text">
<name>Script (put in file named: 'script')</name>
<indent>0</indent>
<description>The script to execute</description>
<position>0</position>
<code><![CDATA[cat >script<<EOF%n%s%nEOF%n]]></code>
<vdef></vdef>
<dep>(provide_script:value="1")</dep>
</parameter>
</parameters>
</program_description>
...@@ -39,7 +39,7 @@ public class ParameterDescription implements Serializable ...@@ -39,7 +39,7 @@ public class ParameterDescription implements Serializable
public enum ParameterType public enum ParameterType
{ {
COMMAND, CODE, INPUT, INPUT_DIRECTORY, OUTPUT, OUTPUT_DIRECTORY, ENUM, BOOLEAN, INT, FLOAT, STRING; COMMAND, CODE, INPUT, INPUT_DIRECTORY, OUTPUT, OUTPUT_DIRECTORY, ENUM, BOOLEAN, INT, FLOAT, STRING, TEXT;
/** /**
* Tells whether the type denotes an input parameter. * Tells whether the type denotes an input parameter.
...@@ -751,6 +751,7 @@ public class ParameterDescription implements Serializable ...@@ -751,6 +751,7 @@ public class ParameterDescription implements Serializable
case OUTPUT: case OUTPUT:
case OUTPUT_DIRECTORY: case OUTPUT_DIRECTORY:
case STRING: case STRING:
case TEXT:
default: default:
return data; return data;
} }
......
...@@ -58,7 +58,7 @@ public class Parameter implements Cloneable, PropertyChangeListener ...@@ -58,7 +58,7 @@ public class Parameter implements Cloneable, PropertyChangeListener
protected Program program; protected Program program;
/** Value for the parameter, only for {@link ParameterType#INT}, /** Value for the parameter, only for {@link ParameterType#INT},
* {@link ParameterType#FLOAT}, {@link ParameterType#STRING}, * {@link ParameterType#FLOAT}, {@link ParameterType#STRING}, {@link ParameterType#TEXT},
* and {@link ParameterType#BOOLEAN} parameters */ * and {@link ParameterType#BOOLEAN} parameters */
String data = null; String data = null;
...@@ -120,6 +120,7 @@ public class Parameter implements Cloneable, PropertyChangeListener ...@@ -120,6 +120,7 @@ public class Parameter implements Cloneable, PropertyChangeListener
case FLOAT: case FLOAT:
case INT: case INT:
case STRING: case STRING:
case TEXT:
data = xml.getChildText("data"); data = xml.getChildText("data");
// TODO: check FLOAT, INT, peut-être pour tout le monde d'ailleurs (boolean, etc.) // TODO: check FLOAT, INT, peut-être pour tout le monde d'ailleurs (boolean, etc.)
break; break;
...@@ -181,6 +182,7 @@ public class Parameter implements Cloneable, PropertyChangeListener ...@@ -181,6 +182,7 @@ public class Parameter implements Cloneable, PropertyChangeListener
data = description.getVdef().equals("")?"0":description.getVdef(); data = description.getVdef().equals("")?"0":description.getVdef();
break; break;
case STRING: case STRING:
case TEXT:
data = description.getVdef(); data = description.getVdef();
break; break;
case ENUM: case ENUM:
......
...@@ -587,7 +587,8 @@ public class Program ...@@ -587,7 +587,8 @@ public class Program
param.setItem(copied_param.getItem()); param.setItem(copied_param.getItem());
if (parameterType.equals(ParameterType.INT) || parameterType.equals(ParameterType.FLOAT) if (parameterType.equals(ParameterType.INT) || parameterType.equals(ParameterType.FLOAT)
|| parameterType.equals(ParameterType.STRING) || parameterType.equals(ParameterType.BOOLEAN)) || parameterType.equals(ParameterType.STRING) || parameterType.equals(ParameterType.TEXT)
|| parameterType.equals(ParameterType.BOOLEAN))
{ {
param.setData(copied_param.getData()); param.setData(copied_param.getData());
} }
......
...@@ -435,6 +435,7 @@ public abstract class SimpleFormatterPlatform ...@@ -435,6 +435,7 @@ public abstract class SimpleFormatterPlatform
case INT: case INT:
case FLOAT: case FLOAT:
case STRING: case STRING:
case TEXT:
return getCode_IntFloatString(parameter); return getCode_IntFloatString(parameter);
case OUTPUT: case OUTPUT:
case OUTPUT_DIRECTORY: case OUTPUT_DIRECTORY:
...@@ -521,6 +522,7 @@ public abstract class SimpleFormatterPlatform ...@@ -521,6 +522,7 @@ public abstract class SimpleFormatterPlatform
{ {
assert ((param.getDescription().getType().equals(ParameterType.INT)) assert ((param.getDescription().getType().equals(ParameterType.INT))
|| (param.getDescription().getType().equals(ParameterType.STRING)) || (param.getDescription().getType().equals(ParameterType.STRING))
|| (param.getDescription().getType().equals(ParameterType.TEXT))
|| (param.getDescription().getType().equals(ParameterType.FLOAT))); || (param.getDescription().getType().equals(ParameterType.FLOAT)));
return String.format(param.getDescription().getValueTemplate(), param.getData(), param.getData()); return String.format(param.getDescription().getValueTemplate(), param.getData(), param.getData());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment