- Vue d'ensemble (Overview)
- Cryptographie
- Base de donnés
- Java
- Python
- APIweb
Activités du développeur.
L’exemple suivant explique comment exécuter automatiquement un code Python créé au moment du runtime et écrire un journal de fichier. Il contient des activités telles que Étendue Python (Python Scope) et Exécuter le script Python (Run Python Script). Vous pouvez retrouver ces activités dans le package UiPath.Python.Activities.
Before running any Python workflow, make sure that you have Python3 installed.
Voici comment le processus d'automatisation peut être créé :
-
Ouvrez Studio et démarrez un nouveau Processus.
-
Faites glisser un conteneur Séquence vers le concepteur de workflow.
-
Créez un nouvel argument :
Argument name Direction Types d'arguments Valeur par défaut in_PythonPathdans Chaîne de caractères (string) Ajouter le chemin du dossier dans lequel Python a été installé -
Drag an If activity inside the Sequence container.
- Ajoutez l’expression
String.IsNullOrEmpty(in_PythonPath) orelse not Directory.Exists(in_PythonPath)dans le champ Condition.
- Ajoutez l’expression
-
Faites glisser un conteneur Sequence dans le champ Alors (Then) de l'activité Si (If).
-
Drag a Message Box activity inside the Sequence container.
- In the Properties panel, add the expression
"Error"in the Caption field. - Ajoutez l’expression
"Pyhon Path not configured. Please configure path by setting the argument 'in_PythonPath'."dans le champ Texte.
- In the Properties panel, add the expression
-
Faites glisser une activité Terminer le workflow (Terminate Workflow) après l’activité Zone de message (Message Box).
- In the Properties panel, add the expression
"Input Arguments not correct"in the Reason field.
- In the Properties panel, add the expression
-
Faites glisser une activité Étendue Python (Python Scope) après l’activité Si (If).
- In the Properties panel, add the argument
in_PythonPathin the Path field. - Select your Python version from the Version drop-down list (Python_36 in this example).
- In the Properties panel, add the argument
-
Drag a Run Python Script activity inside the Python Scope container.
- In the Properties panel, add the following code snippet in the Code field:
String.Format( "import sys" + Environment.NewLine _ + "import os " + Environment.NewLine _ + "with open('{0}\logs.txt', 'w') as f: " + Environment.NewLine _ + " f.write('Starting script! \n')" + Environment.NewLine _ + " f.write('Computing!\n')" + Environment.NewLine _ + " f.write('Finishing script! \n')" + Environment.NewLine, _ Directory.GetCurrentDirectory.Replace("\", "\\"))String.Format( "import sys" + Environment.NewLine _ + "import os " + Environment.NewLine _ + "with open('{0}\logs.txt', 'w') as f: " + Environment.NewLine _ + " f.write('Starting script! \n')" + Environment.NewLine _ + " f.write('Computing!\n')" + Environment.NewLine _ + " f.write('Finishing script! \n')" + Environment.NewLine, _ Directory.GetCurrentDirectory.Replace("\", "\\"))
- In the Properties panel, add the following code snippet in the Code field:
-
Exécutez le processus. L'automatisation exécute le code Python et écrit un journal dans un fichier nommé
logs.txt.