Skip to content

Commit b271412

Browse files
committed
Support run ondemand Automation-API Control-M
1 parent 9c03306 commit b271412

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/aapi/bases.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def run_on_demand(self, environment: Environment, inpath: str = f'run_on_demand{
6666
file_path: str = None, delete_afterwards: bool = True, open_in_browser: str = None) -> RunMonitor:
6767
# Import circular dependency
6868
from ctm_python_client.core.workflow import Workflow, WorkflowDefaults
69-
from aapi import Job, Folder
69+
from aapi import Folder
7070

71-
if isinstance(self, Job) or (hasattr(self, 'job_list') and self.job_list is not None and len(self.job_list) > 0):
71+
if (hasattr(self, '_type') and 'Job' in self._type) or (hasattr(self, 'job_list') and self.job_list is not None and len(self.job_list) > 0):
7272
try:
7373
on_demand_workflow = Workflow(
7474
environment,
@@ -92,9 +92,12 @@ def run_on_demand(self, environment: Environment, inpath: str = f'run_on_demand{
9292
open_in_browser=open_in_browser
9393
)
9494
except Exception as e:
95-
errors = [err.get('message', '') + ' ' + err.get('item', '')
96-
for err in json.loads(e.body)['errors']]
97-
raise RuntimeError(f"AAPI request failed: {', '.join(errors)}")
95+
if e.body:
96+
errors = [err.get('message', '') + ' ' + err.get('item', '')
97+
for err in json.loads(e.body)['errors']]
98+
raise RuntimeError(f"AAPI request failed: {', '.join(errors)}")
99+
else:
100+
raise e
98101
finally:
99102
on_demand_workflow.clear_all()
100103
else:

0 commit comments

Comments
 (0)