Skip to content

Commit 1cb651f

Browse files
authored
Merge pull request #105 from controlm/fix_run_on_demand
Support run ondemand Automation-API Control-M
2 parents 2377a37 + 7d99a07 commit 1cb651f

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
name="ctm-python-client",
99
packages=find_packages(where="src"),
1010
package_dir={"": "src"},
11-
version="2.4.1",
11+
version="2.4.2",
1212
description="Python Workflows for Control-M",
1313
long_description=long_description,
1414
long_description_content_type='text/markdown',

src/aapi/bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def run_on_demand(self, environment: Environment, inpath: str = f'run_on_demand{
8585
else:
8686
on_demand_workflow.add(self, inpath=inpath)
8787

88-
on_demand_workflow.run_on_demand(
88+
return on_demand_workflow.run_on_demand(
8989
skip_login=skip_login,
9090
file_path=file_path,
9191
delete_afterwards=delete_afterwards,

src/ctm_python_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '2.4.1'
1+
__version__ = '2.4.2'
22
__author__ = 'BMC Software'

src/ctm_python_client/core/workflow.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,12 @@ def run_on_demand(self, skip_login: bool = False, file_path: str = None, delete_
438438
run_.open_in_browser()
439439
return run_
440440
except Exception as e:
441-
errors = [err.get('message', '') + ' ' + err.get('item', '')
442-
for err in json.loads(e.body)['errors']]
443-
raise RuntimeError(f"AAPI request failed: {', '.join(errors)}")
441+
if e.body:
442+
errors = [err.get('message', '') + ' ' + err.get('item', '')
443+
for err in json.loads(e.body)['errors']]
444+
raise RuntimeError(f"AAPI request failed: {', '.join(errors)}")
445+
else:
446+
raise e
444447
finally:
445448
if delete_afterwards:
446449
fpath.unlink()

tests/test_aapi.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import pytest
22
import json
33
import aapi
44
from ctm_python_client.core.workflow import Workflow, WorkflowDefaults, BaseWorkflow
@@ -151,3 +151,12 @@ def test_job_in_folder_run_as():
151151
''')
152152
assert workflow.get("TestFolder").as_aapi_dict() == o
153153

154+
def test_run_ondemand_without_jobs():
155+
demand_sub_folder = aapi.SubFolder("TestFolder")
156+
with pytest.raises(Exception, match='Run is not allowed for json without jobs'):
157+
demand_sub_folder.run_on_demand(Environment.create_workbench("refael"), WorkflowDefaults(run_as='workbench'), run_as='workbench', controlm_server='workbench')
158+
159+
demand_folder = aapi.Folder("TestFolder")
160+
with pytest.raises(Exception, match='Run is not allowed for json without jobs'):
161+
demand_folder.run_on_demand(Environment.create_workbench("refael"), WorkflowDefaults(run_as='workbench'), run_as='workbench', controlm_server='workbench')
162+

tests/test_sanity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ def test_version_author():
22
import ctm_python_client
33

44
assert ctm_python_client.__author__ == 'BMC Software'
5-
assert ctm_python_client.__version__ == '2.4.1'
5+
assert ctm_python_client.__version__ == '2.4.2'
66

77

0 commit comments

Comments
 (0)