besapi 4.1.2__tar.gz → 4.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {besapi-4.1.2/src/besapi.egg-info → besapi-4.1.4}/PKG-INFO +1 -1
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/besapi.py +91 -1
- {besapi-4.1.2 → besapi-4.1.4/src/besapi.egg-info}/PKG-INFO +1 -1
- {besapi-4.1.2 → besapi-4.1.4}/LICENSE.txt +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/MANIFEST.in +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/README.md +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/pyproject.toml +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/setup.cfg +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/setup.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/__init__.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/__main__.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/plugin_utilities.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/plugin_utilities_win.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/schemas/BES.xsd +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/schemas/BESAPI.xsd +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi/schemas/BESActionSettings.xsd +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi.egg-info/SOURCES.txt +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi.egg-info/dependency_links.txt +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi.egg-info/requires.txt +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/besapi.egg-info/top_level.txt +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/bescli/__init__.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/bescli/__main__.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/src/bescli/bescli.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/tests/test_besapi.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/tests/test_plugin_utilities.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/tests/test_plugin_utilities_logging.py +0 -0
- {besapi-4.1.2 → besapi-4.1.4}/tests/tests.py +0 -0
|
@@ -29,7 +29,7 @@ import lxml.objectify
|
|
|
29
29
|
import requests
|
|
30
30
|
import urllib3.poolmanager
|
|
31
31
|
|
|
32
|
-
__version__ = "4.1.
|
|
32
|
+
__version__ = "4.1.4"
|
|
33
33
|
|
|
34
34
|
besapi_logger = logging.getLogger("besapi")
|
|
35
35
|
|
|
@@ -249,6 +249,96 @@ def validate_xml_bes_file(file_path):
|
|
|
249
249
|
return validate_xsd(file_data)
|
|
250
250
|
|
|
251
251
|
|
|
252
|
+
def action_xml_from_bes_file(file_path, targets="<AllComputers>"):
|
|
253
|
+
"""Create action XML from bes file with fixlet or task or singleaction."""
|
|
254
|
+
# default to empty string:
|
|
255
|
+
custom_relevance_xml = ""
|
|
256
|
+
|
|
257
|
+
if not validate_xml_bes_file(file_path):
|
|
258
|
+
err_msg = "bes file is not valid according to XML Schema!"
|
|
259
|
+
logging.error(err_msg)
|
|
260
|
+
raise ValueError(err_msg)
|
|
261
|
+
|
|
262
|
+
tree = lxml.etree.parse(file_path)
|
|
263
|
+
|
|
264
|
+
# //BES/*[self::Task or self::Fixlet]/*[@id='elid']/name()
|
|
265
|
+
bes_type = str(
|
|
266
|
+
tree.xpath("//BES/*[self::Task or self::Fixlet or self::SingleAction]")[0].tag
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
logging.debug("BES Type: %s", bes_type)
|
|
270
|
+
|
|
271
|
+
title = tree.xpath(f"//BES/{bes_type}/Title/text()")[0]
|
|
272
|
+
|
|
273
|
+
logging.debug("Title: %s", title)
|
|
274
|
+
|
|
275
|
+
try:
|
|
276
|
+
actionscript = tree.xpath(
|
|
277
|
+
f"//BES/{bes_type}/DefaultAction/ActionScript/text()"
|
|
278
|
+
)[0]
|
|
279
|
+
except IndexError:
|
|
280
|
+
# handle SingleAction case:
|
|
281
|
+
actionscript = tree.xpath(f"//BES/{bes_type}/ActionScript/text()")[0]
|
|
282
|
+
|
|
283
|
+
logging.debug("ActionScript: %s", actionscript)
|
|
284
|
+
|
|
285
|
+
try:
|
|
286
|
+
if bes_type != "SingleAction":
|
|
287
|
+
success_criteria = tree.xpath(
|
|
288
|
+
f"//BES/{bes_type}/DefaultAction/SuccessCriteria/@Option"
|
|
289
|
+
)[0]
|
|
290
|
+
else:
|
|
291
|
+
success_criteria = tree.xpath(f"//BES/{bes_type}/SuccessCriteria/@Option")[
|
|
292
|
+
0
|
|
293
|
+
]
|
|
294
|
+
except IndexError:
|
|
295
|
+
# set success criteria if missing: (default)
|
|
296
|
+
success_criteria = "RunToCompletion"
|
|
297
|
+
if bes_type == "Fixlet":
|
|
298
|
+
# set success criteria if missing: (Fixlet)
|
|
299
|
+
success_criteria = "OriginalRelevance"
|
|
300
|
+
|
|
301
|
+
if success_criteria == "CustomRelevance":
|
|
302
|
+
if bes_type != "SingleAction":
|
|
303
|
+
custom_relevance = tree.xpath(
|
|
304
|
+
f"//BES/{bes_type}/DefaultAction/SuccessCriteria/text()"
|
|
305
|
+
)[0]
|
|
306
|
+
else:
|
|
307
|
+
custom_relevance = tree.xpath(f"//BES/{bes_type}/SuccessCriteria/text()")[0]
|
|
308
|
+
|
|
309
|
+
custom_relevance_xml = f"<![CDATA[{custom_relevance}]]>"
|
|
310
|
+
|
|
311
|
+
logging.debug("success_criteria: %s", success_criteria)
|
|
312
|
+
|
|
313
|
+
relevance_clauses = tree.xpath(f"//BES/{bes_type}/Relevance/text()")
|
|
314
|
+
|
|
315
|
+
logging.debug("Relevances: %s", relevance_clauses)
|
|
316
|
+
|
|
317
|
+
relevance_clauses_combined = get_action_combined_relevance(relevance_clauses)
|
|
318
|
+
|
|
319
|
+
logging.debug("Relevance Combined: %s", relevance_clauses_combined)
|
|
320
|
+
|
|
321
|
+
action_xml = f"""<?xml version="1.0" encoding="UTF-8"?>
|
|
322
|
+
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
|
|
323
|
+
<SingleAction>
|
|
324
|
+
<Title>{title}</Title>
|
|
325
|
+
<Relevance><![CDATA[{relevance_clauses_combined}]]></Relevance>
|
|
326
|
+
<ActionScript MIMEType="application/x-Fixlet-Windows-Shell"><![CDATA[// Start:
|
|
327
|
+
{actionscript}
|
|
328
|
+
// End]]></ActionScript>
|
|
329
|
+
<SuccessCriteria Option="{success_criteria}">{custom_relevance_xml}</SuccessCriteria>
|
|
330
|
+
<Target>
|
|
331
|
+
{get_target_xml(targets)}
|
|
332
|
+
</Target>
|
|
333
|
+
</SingleAction>
|
|
334
|
+
</BES>
|
|
335
|
+
"""
|
|
336
|
+
|
|
337
|
+
logging.debug("Action XML:\n%s", action_xml)
|
|
338
|
+
|
|
339
|
+
return action_xml
|
|
340
|
+
|
|
341
|
+
|
|
252
342
|
def get_bes_conn_using_env():
|
|
253
343
|
"""Get BESConnection using environment variables."""
|
|
254
344
|
username = os.getenv("BES_USER_NAME")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|