-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
import os | ||
|
||
from robot.api.deco import library, keyword | ||
|
||
|
||
@library | ||
class API: | ||
|
||
result = {} | ||
|
||
@keyword | ||
def flw_input(self, name: str): | ||
variables = os.environ["FLOWABLE_INPUT_VARIABLES"] | ||
obj = json.loads(variables) | ||
return obj[name] | ||
|
||
@keyword | ||
def flw_output(self, name: str, value: any): | ||
output_file_name = os.environ.get("FLOWABLE_OUTPUT_FILE") | ||
self.result[name] = value | ||
print('assign ' + name + '=' + value) | ||
if output_file_name is not None: | ||
with open(output_file_name, "w") as f: | ||
f.write(json.dumps(self.result)) | ||
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
def call_robocorp(args, mod_name='robocorp.actions'): | ||
def call_robocorp(args, mod_name, env=None): | ||
if env is None: | ||
env = os.environ.copy() | ||
call_args = [sys.executable, "-m", mod_name] | ||
call_args.extend(args) | ||
try: | ||
return subprocess.run(call_args, capture_output=True, text=True) | ||
return subprocess.run(call_args, capture_output=True, text=True, env=env) | ||
except subprocess.CalledProcessError as exc: | ||
print("ERROR: failed to call robocorp", exc.returncode, exc.output) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters