- Überblick
- Kryptografie
- Datenbank
- Java
- Python
- WebAPI
- Versionshinweise
- Über das WebAPI-Aktivitätspaket
- Projektkompatibilität
- XML deserialisieren (Deserialize XML)
- XPath ausführen (Execute XPath)
- XML-Knotenattribute erhalten (Get XML Node Attributes)
- XML-Knoten erhalten (Get XML Nodes)
- JSON serialisieren
- Deserialize JSON
- JSON-Zusammenstellung deserialisieren (Deserialize Json Array)
- HTTP Request (legacy)
- HTTP-Anfrage (HTTP Request)
- SOAP-Anfrage (SOAP Request)
Entwickleraktivitäten
Im folgenden Beispiel wird erklärt, wie Sie automatisch einen zur Laufzeit erstellten Python-Code ausführen und ein Dateiprotokoll schreiben. Dabei werden Aktivitäten wie Python Scope und Run Python Script verwendet. Diese Aktivitäten finden Sie im Paket UiPath.Python.Activities.
Before running any Python workflow, make sure that you have Python3 installed.
So kann der Automatisierungsprozess erstellt werden:
-
Öffnen Sie Studio und erstellen Sie einen neuen Prozess.
-
Ziehen Sie einen Sequence-Container in den Workflow-Designer.
-
Erstellen Sie ein neues Argument:
Argument name Richtung Argumenttyp Standardwert in_PythonPathin String Fügen Sie den Pfad des Ordners hinzu, in dem Python installiert wurde -
Drag an If activity inside the Sequence container.
- Fügen Sie den Ausdruck
String.IsNullOrEmpty(in_PythonPath) orelse not Directory.Exists(in_PythonPath)in das Feld Bedingung ein.
- Fügen Sie den Ausdruck
-
Ziehen Sie einen Sequence-Container in das Then-Feld der If-Aktivität.
-
Drag a Message Box activity inside the Sequence container.
- In the Properties panel, add the expression
"Error"in the Caption field. - Fügen Sie den Ausdruck
"Pyhon Path not configured. Please configure path by setting the argument 'in_PythonPath'."in das Feld Text ein.
- In the Properties panel, add the expression
-
Ziehen Sie eine Terminate Workflow-Aktivität nach der Aktivität Message Box.
- In the Properties panel, add the expression
"Input Arguments not correct"in the Reason field.
- In the Properties panel, add the expression
-
Ziehen Sie eine Python Scope-Aktivität nach der If-Aktivität.
- 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:
-
Führen Sie den Prozess aus. Die Automatisierung führt den Python-Code aus und schreibt ein Protokoll in eine Datei mit dem Namen
logs.txt.