Skip to content

Commit

Permalink
Fix python syntax warnings and conductor import http code
Browse files Browse the repository at this point in the history
  • Loading branch information
mirohudec committed May 14, 2024
1 parent 166a0fc commit 84d4232
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def import_workflows(path):
headers=conductor_headers,
)
local_logs.info("Response status code - %s", r.status_code)
if r.status_code != 204:
if r.status_code != requests.codes.ok:
local_logs.warning(
"Import of workflow %s failed. "
"Ignoring the workflow. Response content: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ def execute_mount_netconf(task):
if (
"reconcile" in task["inputData"]
and task["inputData"]["reconcile"] is not None
and task["inputData"]["reconcile"] is not ""
and task["inputData"]["reconcile"] != ""
):
mount_body["input"]["netconf"]["node-extension:reconcile"] = task["inputData"]["reconcile"]

if (
"schema-cache-directory" in task["inputData"]
and task["inputData"]["schema-cache-directory"] is not None
and task["inputData"]["schema-cache-directory"] is not ""
and task["inputData"]["schema-cache-directory"] != ""
):
mount_body["input"]["netconf"]["netconf-node-topology:schema-cache-directory"] = task[
"inputData"
Expand All @@ -91,7 +91,7 @@ def execute_mount_netconf(task):
if (
"sleep-factor" in task["inputData"]
and task["inputData"]["sleep-factor"] is not None
and task["inputData"]["sleep-factor"] is not ""
and task["inputData"]["sleep-factor"] != ""
):
mount_body["input"]["netconf"]["netconf-node-topology:sleep-factor"] = task["inputData"][
"sleep-factor"
Expand All @@ -100,7 +100,7 @@ def execute_mount_netconf(task):
if (
"between-attempts-timeout-millis" in task["inputData"]
and task["inputData"]["between-attempts-timeout-millis"] is not None
and task["inputData"]["between-attempts-timeout-millis"] is not ""
and task["inputData"]["between-attempts-timeout-millis"] != ""
):
mount_body["input"]["netconf"]["netconf-node-topology:between-attempts-timeout-millis"] = (
task["inputData"]["between-attempts-timeout-millis"]
Expand All @@ -109,7 +109,7 @@ def execute_mount_netconf(task):
if (
"connection-timeout-millis" in task["inputData"]
and task["inputData"]["connection-timeout-millis"] is not None
and task["inputData"]["connection-timeout-millis"] is not ""
and task["inputData"]["connection-timeout-millis"] != ""
):
mount_body["input"]["netconf"]["netconf-node-topology:connection-timeout-millis"] = task[
"inputData"
Expand All @@ -118,7 +118,7 @@ def execute_mount_netconf(task):
if (
"uniconfig-native" in task["inputData"]
and task["inputData"]["uniconfig-native"] is not None
and task["inputData"]["uniconfig-native"] is not ""
and task["inputData"]["uniconfig-native"] != ""
):
mount_body["input"]["netconf"]["uniconfig-config:uniconfig-native-enabled"] = task[
"inputData"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,9 @@ def parse_devices(task, fail_on_empty=True):
if "name" in dev:
extracted_devices.append(dev.get("name"))
else:
extracted_devices = (
[x.strip() for x in devices.split(",") if x is not ""] if devices else []
)
extracted_devices = [x.strip() for x in devices.split(",") if x != ""] if devices else []

if fail_on_empty and len(extracted_devices) is 0:
if fail_on_empty and len(extracted_devices) == 0:
raise Exception(
"For Uniconfig RPCs, a list of devices needs to be specified. "
"Global RPCs (involving all devices in topology) are not allowed for your own safety."
Expand Down

0 comments on commit 84d4232

Please sign in to comment.