aboutsummaryrefslogtreecommitdiffstats
path: root/policyhandler/policy_rest.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-06-14 12:06:42 -0400
committerAlex Shatov <alexs@att.com>2018-06-14 12:06:42 -0400
commitc9ec231483d905f3a391c3985c2c2762344ed5c1 (patch)
treefae12736cb572f07f733fe4a5ffd68e2df21d77e /policyhandler/policy_rest.py
parent83de7401162dc895ae8343a2e43f2c9eb57afb06 (diff)
3.0.0 policy-handler - migrated to python 3.6
- migrated from python 2.7 to 3.6 - brought up the latest versions of dependencies -- Cherrypy 15.0.0, requests 2.18.4, websocket-client 0.48.0 - fixed migration errors -- renamed the standard package Queue to queue -- dict.items() instead of dict.iteritems() -- dict.keys() instead of dict.viewkeys() -- range() instead of xrange() -- subprocess.check_output(..., universal_newlines=True) to get str instead of byte-stream from stdout - cleaned up migration warnings -- super() instead of super(A, self) -- logger.warning() instead of .warn() - moved main() from policy_handler.py to __main__.py - getting the policy_handler version directly from setup.py instead of the env var on init of the audit Change-Id: I0fc4ddc51c08a64f3cfdc5d2f010b1c6a1ae92f0 Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-515
Diffstat (limited to 'policyhandler/policy_rest.py')
-rw-r--r--policyhandler/policy_rest.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/policyhandler/policy_rest.py b/policyhandler/policy_rest.py
index 977a9a1..16c38bb 100644
--- a/policyhandler/policy_rest.py
+++ b/policyhandler/policy_rest.py
@@ -207,7 +207,7 @@ class PolicyRest(object):
latest_policy = None
expect_policy_removed = (ignore_policy_names and not min_version_expected)
- for retry in xrange(1, PolicyRest._policy_retry_count + 1):
+ for retry in range(1, PolicyRest._policy_retry_count + 1):
PolicyRest._logger.debug(str_metrics)
status_code, policy_configs = PolicyRest._pdp_get_config(
@@ -323,7 +323,7 @@ class PolicyRest(object):
apns = [(audit, policy_id,
policy_to_find.get(PolicyRest.MIN_VERSION_EXPECTED),
policy_to_find.get(PolicyRest.IGNORE_POLICY_NAMES))
- for (policy_id, policy_to_find) in policies_to_find.iteritems()]
+ for (policy_id, policy_to_find) in policies_to_find.items()]
policies = None
apns_length = len(apns)
@@ -343,13 +343,13 @@ class PolicyRest(object):
if policy and policy.get(POLICY_ID))
removed_policies = dict((policy_id, True)
- for (policy_id, policy_to_find) in policies_to_find.iteritems()
+ for (policy_id, policy_to_find) in policies_to_find.items()
if not policy_to_find.get(PolicyRest.MIN_VERSION_EXPECTED)
and policy_to_find.get(PolicyRest.IGNORE_POLICY_NAMES)
and policy_id not in updated_policies)
errored_policies = dict((policy_id, policy_to_find)
- for (policy_id, policy_to_find) in policies_to_find.iteritems()
+ for (policy_id, policy_to_find) in policies_to_find.items()
if policy_id not in updated_policies
and policy_id not in removed_policies)
@@ -413,7 +413,7 @@ class PolicyRest(object):
audit.set_http_status_code(status_code)
valid_policies = {}
errored_policies = {}
- for (policy_id, policy) in latest_policies.iteritems():
+ for (policy_id, policy) in latest_policies.items():
if PolicyRest._validate_policy(policy):
valid_policies[policy_id] = policy
else:
@@ -481,10 +481,10 @@ class PolicyRest(object):
# latest_policies == [(valid_policies, errored_policies, errored_scope_prefix), ...]
result[LATEST_POLICIES] = dict(
- pair for (vps, _, _) in latest_policies if vps for pair in vps.iteritems())
+ pair for (vps, _, _) in latest_policies if vps for pair in vps.items())
result[ERRORED_POLICIES] = dict(
- pair for (_, eps, _) in latest_policies if eps for pair in eps.iteritems())
+ pair for (_, eps, _) in latest_policies if eps for pair in eps.items())
result[ERRORED_SCOPES] = sorted([esp for (_, _, esp) in latest_policies if esp])