From 547cbb18de94dc36c549bbed6a79c3dc757817d4 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Wed, 18 Oct 2017 10:36:00 -0700 Subject: [PATCH 01/12] Updates for dxl bootstrap 0.1.3 --- clean.py | 18 +++++++++--------- dist.py | 7 ------- dxlciscopxgridclient/_config/__init__.py | 0 .../_config/sample/__init__.py | 0 .../_config/sample/dxlclient.config | 0 setup.py | 8 ++++++-- 6 files changed, 15 insertions(+), 18 deletions(-) create mode 100644 dxlciscopxgridclient/_config/__init__.py create mode 100644 dxlciscopxgridclient/_config/sample/__init__.py rename sample/dxlclient.config.dist => dxlciscopxgridclient/_config/sample/dxlclient.config (100%) diff --git a/clean.py b/clean.py index 368412e..4b55dd7 100644 --- a/clean.py +++ b/clean.py @@ -3,17 +3,15 @@ from shutil import copyfile -def clean_dir(directory): +def clean_dir(src_dir, directory): if os.path.exists(directory): print("Cleaning directory: " + directory + "\n") for f in os.listdir(directory): - if not os.path.isdir(os.path.join(directory, f)) \ - and not f.lower().endswith(".dist") and not f.lower().endswith(".py"): + if not os.path.isdir(os.path.join(directory, f)) and not f.lower().endswith(".py"): os.remove(os.path.join(directory, f)) - for f in os.listdir(directory): - if not os.path.isdir(f) and f.lower().endswith(".dist"): - copyfile(os.path.join(directory, f), os.path.join(directory, f[:-5])) - + for f in os.listdir(src_dir): + if not os.path.isdir(f) and not(f.lower().endswith(".py") or f.lower().endswith(".pyc")): + copyfile(os.path.join(src_dir, f), os.path.join(directory, f)) print("Starting clean.\n") @@ -21,6 +19,8 @@ def clean_dir(directory): DIST_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dist") CONFIG_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "config") SAMPLE_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "sample") +CONFIG_SRC_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient", "_config", "app") +SAMPLE_SRC_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient", "_config", "sample") # Remove the dist directory if it exists if os.path.exists(DIST_DIRECTORY): @@ -28,10 +28,10 @@ def clean_dir(directory): remove_tree(DIST_DIRECTORY, verbose=1) # Clean the config directory -clean_dir(CONFIG_DIRECTORY) +clean_dir(CONFIG_SRC_DIRECTORY, CONFIG_DIRECTORY) # Clean the samples directory -clean_dir(SAMPLE_DIRECTORY) +clean_dir(SAMPLE_SRC_DIRECTORY, SAMPLE_DIRECTORY) # Clean .pyc files print("Cleaning .pyc files") diff --git a/dist.py b/dist.py index c57df90..9fb228e 100644 --- a/dist.py +++ b/dist.py @@ -9,12 +9,6 @@ # Run clean import clean - -def remove_dist_files(directory): - for f in os.listdir(directory): - if f.lower().endswith(".dist"): - os.remove(os.path.join(directory, f)) - print("Starting dist.\n") VERSION = __import__('dxlciscopxgridclient').get_version() @@ -86,7 +80,6 @@ def remove_dist_files(directory): print("\nCopying sample into dist directory\n") copy_tree(os.path.join(DIST_PY_FILE_LOCATION, "sample"), SAMPLE_RELEASE_DIR) -remove_dist_files(SAMPLE_RELEASE_DIR) print("\nCopying dist to " + DIST_RELEASE_DIR + "\n") copy_tree(DIST_DIRECTORY, DIST_RELEASE_DIR) diff --git a/dxlciscopxgridclient/_config/__init__.py b/dxlciscopxgridclient/_config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dxlciscopxgridclient/_config/sample/__init__.py b/dxlciscopxgridclient/_config/sample/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sample/dxlclient.config.dist b/dxlciscopxgridclient/_config/sample/dxlclient.config similarity index 100% rename from sample/dxlclient.config.dist rename to dxlciscopxgridclient/_config/sample/dxlclient.config diff --git a/setup.py b/setup.py index a2eb809..7eb38be 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ # Requirements install_requires=[ - "dxlbootstrap", + "dxlbootstrap>=0.1.3", "dxlclient" ], @@ -37,7 +37,11 @@ # Packages packages=[ "dxlciscopxgridclient", - ], + "dxlciscopxgridclient._config", + "dxlciscopxgridclient._config.sample"], + + package_data={ + "dxlciscopxgridclient._config.sample" : ['*']}, # Details url="http://www.mcafee.com", From 235cd427daab1bdfb5b473f90c9fe88e98bfb285 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Wed, 14 Mar 2018 16:31:47 -0700 Subject: [PATCH 02/12] Automatic updates from running modernizer 0.6 --- clean.py | 6 ++++-- dist.py | 10 ++++++---- doc/conf.py | 1 + dxlciscopxgridclient/callbacks.py | 1 + dxlciscopxgridclient/client.py | 1 + .../basic_anc_apply_endpoint_policy_by_ip_example.py | 8 +++++--- .../basic_anc_apply_endpoint_policy_by_mac_example.py | 8 +++++--- ...c_anc_apply_endpoint_policy_notification_example.py | 6 ++++-- .../basic_anc_clear_endpoint_policy_by_ip_example.py | 8 +++++--- .../basic_anc_clear_endpoint_policy_by_mac_example.py | 8 +++++--- ...c_anc_clear_endpoint_policy_notification_example.py | 6 ++++-- .../basic_anc_create_policy_notification_example.py | 6 ++++-- .../basic_anc_delete_policy_notification_example.py | 6 ++++-- sample/basic/basic_anc_get_endpoint_by_ip_example.py | 8 +++++--- sample/basic/basic_anc_get_endpoint_by_mac_example.py | 8 +++++--- .../basic/basic_anc_retrieve_all_policies_example.py | 6 ++++-- .../basic/basic_anc_retrieve_policy_by_name_example.py | 8 +++++--- .../basic_anc_update_policy_notification_example.py | 6 ++++-- .../basic_eps_send_mitigation_action_by_ip_example.py | 8 +++++--- .../basic_eps_send_mitigation_action_by_mac_example.py | 6 ++++-- .../basic_identity_session_notification_example.py | 6 ++++-- sample/common.py | 1 + setup.py | 1 + 23 files changed, 87 insertions(+), 46 deletions(-) diff --git a/clean.py b/clean.py index 4b55dd7..5e1e922 100644 --- a/clean.py +++ b/clean.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os from distutils.dir_util import remove_tree from shutil import copyfile @@ -5,7 +7,7 @@ def clean_dir(src_dir, directory): if os.path.exists(directory): - print("Cleaning directory: " + directory + "\n") + print(("Cleaning directory: " + directory + "\n")) for f in os.listdir(directory): if not os.path.isdir(os.path.join(directory, f)) and not f.lower().endswith(".py"): os.remove(os.path.join(directory, f)) @@ -24,7 +26,7 @@ def clean_dir(src_dir, directory): # Remove the dist directory if it exists if os.path.exists(DIST_DIRECTORY): - print("Removing dist directory: " + DIST_DIRECTORY + "\n") + print(("Removing dist directory: " + DIST_DIRECTORY + "\n")) remove_tree(DIST_DIRECTORY, verbose=1) # Clean the config directory diff --git a/dist.py b/dist.py index 9fb228e..0adaca3 100644 --- a/dist.py +++ b/dist.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import subprocess from distutils.dir_util import copy_tree, remove_tree @@ -24,10 +26,10 @@ # Remove the dist directory if it exists if os.path.exists(DIST_DIRECTORY): - print("\nRemoving dist directory: " + DIST_DIRECTORY + "\n") + print(("\nRemoving dist directory: " + DIST_DIRECTORY + "\n")) remove_tree(DIST_DIRECTORY, verbose=1) -print("\nMaking dist directory: " + DIST_DIRECTORY + "\n") +print(("\nMaking dist directory: " + DIST_DIRECTORY + "\n")) os.makedirs(DIST_DIRECTORY) print("\nCalling sphinx-apidoc\n") @@ -81,7 +83,7 @@ print("\nCopying sample into dist directory\n") copy_tree(os.path.join(DIST_PY_FILE_LOCATION, "sample"), SAMPLE_RELEASE_DIR) -print("\nCopying dist to " + DIST_RELEASE_DIR + "\n") +print(("\nCopying dist to " + DIST_RELEASE_DIR + "\n")) copy_tree(DIST_DIRECTORY, DIST_RELEASE_DIR) print("\nRemoving build directory\n") @@ -93,5 +95,5 @@ print("\nMaking dist zip\n") make_archive(DIST_RELEASE_DIR, "zip", DIST_DIRECTORY, RELEASE_NAME) -print("\nRemoving " + DIST_RELEASE_DIR + "\n") +print(("\nRemoving " + DIST_RELEASE_DIR + "\n")) remove_tree(DIST_RELEASE_DIR) diff --git a/doc/conf.py b/doc/conf.py index fb68582..fc5b538 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # +from __future__ import absolute_import import sys import os diff --git a/dxlciscopxgridclient/callbacks.py b/dxlciscopxgridclient/callbacks.py index fd70f2b..399cd5a 100644 --- a/dxlciscopxgridclient/callbacks.py +++ b/dxlciscopxgridclient/callbacks.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from dxlbootstrap.util import MessageUtils from dxlclient.callbacks import EventCallback diff --git a/dxlciscopxgridclient/client.py b/dxlciscopxgridclient/client.py index c4119a2..cd76fa3 100644 --- a/dxlciscopxgridclient/client.py +++ b/dxlciscopxgridclient/client.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from dxlclient.message import Request from dxlbootstrap.util import MessageUtils from dxlbootstrap.client import Client diff --git a/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py b/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py index a1de766..714d75f 100644 --- a/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py +++ b/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -42,10 +44,10 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if the 'quarantine_policy' has already # been applied to the endpoint, the 'quarantine_policy' has not been # created, or if no session has been established for the endpoint. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py b/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py index 8596d12..ab8e48a 100644 --- a/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py +++ b/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -43,10 +45,10 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if the 'quarantine_policy' has already # been applied to the endpoint or the 'quarantine_policy' has not been # created. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py b/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py index c3beb5e..f988873 100644 --- a/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py +++ b/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys import time @@ -36,8 +38,8 @@ class MyAncApplyEndpointPolicyCallback(AncApplyEndpointPolicyCallback): def on_apply_endpoint_policy(self, apply_dict): - print("on_apply_endpoint_policy\n" + - MessageUtils.dict_to_json(apply_dict, pretty_print=True)) + print(("on_apply_endpoint_policy\n" + + MessageUtils.dict_to_json(apply_dict, pretty_print=True))) # Attach callback for 'apply policy' events client.anc.add_apply_endpoint_policy_callback( diff --git a/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py b/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py index 692f1f6..4b34e3a 100644 --- a/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py +++ b/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -41,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if a policy has not already been # associated with the endpoint. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py b/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py index f8eda61..dc58226 100644 --- a/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py +++ b/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -41,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception would be raised if a policy has not already been # associated with the endpoint. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py b/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py index 62756e2..9f4fe6d 100644 --- a/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py +++ b/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys import time @@ -36,8 +38,8 @@ class MyAncClearEndpointPolicyCallback(AncClearEndpointPolicyCallback): def on_clear_endpoint_policy(self, clear_dict): - print("on_clear_endpoint_policy\n" + - MessageUtils.dict_to_json(clear_dict, pretty_print=True)) + print(("on_clear_endpoint_policy\n" + + MessageUtils.dict_to_json(clear_dict, pretty_print=True))) # Attach callback for 'clear policy' events client.anc.add_clear_endpoint_policy_callback( diff --git a/sample/basic/basic_anc_create_policy_notification_example.py b/sample/basic/basic_anc_create_policy_notification_example.py index 4917237..84b53ae 100644 --- a/sample/basic/basic_anc_create_policy_notification_example.py +++ b/sample/basic/basic_anc_create_policy_notification_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys import time @@ -36,8 +38,8 @@ class MyAncCreatePolicyCallback(AncCreatePolicyCallback): def on_create_policy(self, create_dict): - print("on_create_policy\n" + - MessageUtils.dict_to_json(create_dict, pretty_print=True)) + print(("on_create_policy\n" + + MessageUtils.dict_to_json(create_dict, pretty_print=True))) # Attach callback for 'create policy' events client.anc.add_create_policy_callback(MyAncCreatePolicyCallback()) diff --git a/sample/basic/basic_anc_delete_policy_notification_example.py b/sample/basic/basic_anc_delete_policy_notification_example.py index 88494dc..cc4717a 100644 --- a/sample/basic/basic_anc_delete_policy_notification_example.py +++ b/sample/basic/basic_anc_delete_policy_notification_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys import time @@ -36,8 +38,8 @@ class MyAncDeletePolicyCallback(AncDeletePolicyCallback): def on_delete_policy(self, delete_dict): - print("on_delete_policy\n" + - MessageUtils.dict_to_json(delete_dict, pretty_print=True)) + print(("on_delete_policy\n" + + MessageUtils.dict_to_json(delete_dict, pretty_print=True))) # Attach callback for 'delete policy' events client.anc.add_delete_policy_callback(MyAncDeletePolicyCallback()) diff --git a/sample/basic/basic_anc_get_endpoint_by_ip_example.py b/sample/basic/basic_anc_get_endpoint_by_ip_example.py index 829b2ff..56fc5a7 100644 --- a/sample/basic/basic_anc_get_endpoint_by_ip_example.py +++ b/sample/basic/basic_anc_get_endpoint_by_ip_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -41,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if a policy has not already been # associated with the endpoint. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_get_endpoint_by_mac_example.py b/sample/basic/basic_anc_get_endpoint_by_mac_example.py index 29460b1..6c15e68 100644 --- a/sample/basic/basic_anc_get_endpoint_by_mac_example.py +++ b/sample/basic/basic_anc_get_endpoint_by_mac_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -41,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if a policy has not already been # associated with the endpoint. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_retrieve_all_policies_example.py b/sample/basic/basic_anc_retrieve_all_policies_example.py index c27f30b..9af1fc5 100644 --- a/sample/basic/basic_anc_retrieve_all_policies_example.py +++ b/sample/basic/basic_anc_retrieve_all_policies_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -37,5 +39,5 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) diff --git a/sample/basic/basic_anc_retrieve_policy_by_name_example.py b/sample/basic/basic_anc_retrieve_policy_by_name_example.py index 2c3a77a..d29cccb 100644 --- a/sample/basic/basic_anc_retrieve_policy_by_name_example.py +++ b/sample/basic/basic_anc_retrieve_policy_by_name_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -38,9 +40,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if the 'quarantine_policy' has not # already been created. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_anc_update_policy_notification_example.py b/sample/basic/basic_anc_update_policy_notification_example.py index 381ad6b..df06706 100644 --- a/sample/basic/basic_anc_update_policy_notification_example.py +++ b/sample/basic/basic_anc_update_policy_notification_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys import time @@ -36,8 +38,8 @@ class MyAncUpdatePolicyCallback(AncUpdatePolicyCallback): def on_update_policy(self, update_dict): - print("on_update_policy\n" + - MessageUtils.dict_to_json(update_dict, pretty_print=True)) + print(("on_update_policy\n" + + MessageUtils.dict_to_json(update_dict, pretty_print=True))) # Attach callback for 'update policy' events client.anc.add_update_policy_callback(MyAncUpdatePolicyCallback()) diff --git a/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py b/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py index 7a3bd42..437806d 100644 --- a/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py +++ b/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -44,8 +46,8 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) except Exception as ex: # An exception should be raised if no session exists for the endpoint. - print(str(ex)) + print((str(ex))) diff --git a/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py b/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py index eb5b8b4..7778e3c 100644 --- a/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py +++ b/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys @@ -43,5 +45,5 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True))) + print(("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) diff --git a/sample/basic/basic_identity_session_notification_example.py b/sample/basic/basic_identity_session_notification_example.py index c984ee8..b133a93 100644 --- a/sample/basic/basic_identity_session_notification_example.py +++ b/sample/basic/basic_identity_session_notification_example.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +from __future__ import print_function import os import sys import time @@ -36,8 +38,8 @@ class MyIdentitySessionCallback(IdentitySessionCallback): def on_session(self, session_dict): - print("on_session\n" + - MessageUtils.dict_to_json(session_dict, pretty_print=True)) + print(("on_session\n" + + MessageUtils.dict_to_json(session_dict, pretty_print=True))) # Attach callback for session events client.identity.add_session_callback(MyIdentitySessionCallback()) diff --git a/sample/common.py b/sample/common.py index 73f2aa3..60d414f 100644 --- a/sample/common.py +++ b/sample/common.py @@ -4,6 +4,7 @@ in addition to setting up the logger appropriately. """ +from __future__ import absolute_import import os import logging diff --git a/setup.py b/setup.py index 7eb38be..49fd674 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import os from setuptools import setup import distutils.command.sdist From 09ad778d3e43f7d8902b5a00449e8695d033615c Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Wed, 14 Mar 2018 16:27:08 -0700 Subject: [PATCH 03/12] Remove superfluous double-parentheses for print function calls --- .../basic/basic_anc_apply_endpoint_policy_by_ip_example.py | 6 +++--- .../basic/basic_anc_apply_endpoint_policy_by_mac_example.py | 6 +++--- .../basic_anc_apply_endpoint_policy_notification_example.py | 4 ++-- .../basic/basic_anc_clear_endpoint_policy_by_ip_example.py | 6 +++--- .../basic/basic_anc_clear_endpoint_policy_by_mac_example.py | 6 +++--- .../basic_anc_clear_endpoint_policy_notification_example.py | 4 ++-- .../basic/basic_anc_create_policy_notification_example.py | 4 ++-- .../basic/basic_anc_delete_policy_notification_example.py | 4 ++-- sample/basic/basic_anc_get_endpoint_by_ip_example.py | 6 +++--- sample/basic/basic_anc_get_endpoint_by_mac_example.py | 6 +++--- sample/basic/basic_anc_retrieve_all_policies_example.py | 4 ++-- sample/basic/basic_anc_retrieve_policy_by_name_example.py | 6 +++--- .../basic/basic_anc_update_policy_notification_example.py | 4 ++-- .../basic/basic_eps_send_mitigation_action_by_ip_example.py | 6 +++--- .../basic_eps_send_mitigation_action_by_mac_example.py | 4 ++-- sample/basic/basic_identity_session_notification_example.py | 4 ++-- 16 files changed, 40 insertions(+), 40 deletions(-) diff --git a/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py b/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py index 714d75f..178a3ab 100644 --- a/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py +++ b/sample/basic/basic_anc_apply_endpoint_policy_by_ip_example.py @@ -44,10 +44,10 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if the 'quarantine_policy' has already # been applied to the endpoint, the 'quarantine_policy' has not been # created, or if no session has been established for the endpoint. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py b/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py index ab8e48a..5db3975 100644 --- a/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py +++ b/sample/basic/basic_anc_apply_endpoint_policy_by_mac_example.py @@ -45,10 +45,10 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if the 'quarantine_policy' has already # been applied to the endpoint or the 'quarantine_policy' has not been # created. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py b/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py index f988873..30149a6 100644 --- a/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py +++ b/sample/basic/basic_anc_apply_endpoint_policy_notification_example.py @@ -38,8 +38,8 @@ class MyAncApplyEndpointPolicyCallback(AncApplyEndpointPolicyCallback): def on_apply_endpoint_policy(self, apply_dict): - print(("on_apply_endpoint_policy\n" + - MessageUtils.dict_to_json(apply_dict, pretty_print=True))) + print("on_apply_endpoint_policy\n" + + MessageUtils.dict_to_json(apply_dict, pretty_print=True)) # Attach callback for 'apply policy' events client.anc.add_apply_endpoint_policy_callback( diff --git a/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py b/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py index 4b34e3a..af4b505 100644 --- a/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py +++ b/sample/basic/basic_anc_clear_endpoint_policy_by_ip_example.py @@ -43,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if a policy has not already been # associated with the endpoint. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py b/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py index dc58226..63eeb7f 100644 --- a/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py +++ b/sample/basic/basic_anc_clear_endpoint_policy_by_mac_example.py @@ -43,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception would be raised if a policy has not already been # associated with the endpoint. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py b/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py index 9f4fe6d..9fe489e 100644 --- a/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py +++ b/sample/basic/basic_anc_clear_endpoint_policy_notification_example.py @@ -38,8 +38,8 @@ class MyAncClearEndpointPolicyCallback(AncClearEndpointPolicyCallback): def on_clear_endpoint_policy(self, clear_dict): - print(("on_clear_endpoint_policy\n" + - MessageUtils.dict_to_json(clear_dict, pretty_print=True))) + print("on_clear_endpoint_policy\n" + + MessageUtils.dict_to_json(clear_dict, pretty_print=True)) # Attach callback for 'clear policy' events client.anc.add_clear_endpoint_policy_callback( diff --git a/sample/basic/basic_anc_create_policy_notification_example.py b/sample/basic/basic_anc_create_policy_notification_example.py index 84b53ae..159e640 100644 --- a/sample/basic/basic_anc_create_policy_notification_example.py +++ b/sample/basic/basic_anc_create_policy_notification_example.py @@ -38,8 +38,8 @@ class MyAncCreatePolicyCallback(AncCreatePolicyCallback): def on_create_policy(self, create_dict): - print(("on_create_policy\n" + - MessageUtils.dict_to_json(create_dict, pretty_print=True))) + print("on_create_policy\n" + + MessageUtils.dict_to_json(create_dict, pretty_print=True)) # Attach callback for 'create policy' events client.anc.add_create_policy_callback(MyAncCreatePolicyCallback()) diff --git a/sample/basic/basic_anc_delete_policy_notification_example.py b/sample/basic/basic_anc_delete_policy_notification_example.py index cc4717a..6bcf35a 100644 --- a/sample/basic/basic_anc_delete_policy_notification_example.py +++ b/sample/basic/basic_anc_delete_policy_notification_example.py @@ -38,8 +38,8 @@ class MyAncDeletePolicyCallback(AncDeletePolicyCallback): def on_delete_policy(self, delete_dict): - print(("on_delete_policy\n" + - MessageUtils.dict_to_json(delete_dict, pretty_print=True))) + print("on_delete_policy\n" + + MessageUtils.dict_to_json(delete_dict, pretty_print=True)) # Attach callback for 'delete policy' events client.anc.add_delete_policy_callback(MyAncDeletePolicyCallback()) diff --git a/sample/basic/basic_anc_get_endpoint_by_ip_example.py b/sample/basic/basic_anc_get_endpoint_by_ip_example.py index 56fc5a7..00a4232 100644 --- a/sample/basic/basic_anc_get_endpoint_by_ip_example.py +++ b/sample/basic/basic_anc_get_endpoint_by_ip_example.py @@ -43,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if a policy has not already been # associated with the endpoint. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_get_endpoint_by_mac_example.py b/sample/basic/basic_anc_get_endpoint_by_mac_example.py index 6c15e68..7f6b02b 100644 --- a/sample/basic/basic_anc_get_endpoint_by_mac_example.py +++ b/sample/basic/basic_anc_get_endpoint_by_mac_example.py @@ -43,9 +43,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if a policy has not already been # associated with the endpoint. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_retrieve_all_policies_example.py b/sample/basic/basic_anc_retrieve_all_policies_example.py index 9af1fc5..0389066 100644 --- a/sample/basic/basic_anc_retrieve_all_policies_example.py +++ b/sample/basic/basic_anc_retrieve_all_policies_example.py @@ -39,5 +39,5 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) diff --git a/sample/basic/basic_anc_retrieve_policy_by_name_example.py b/sample/basic/basic_anc_retrieve_policy_by_name_example.py index d29cccb..189d587 100644 --- a/sample/basic/basic_anc_retrieve_policy_by_name_example.py +++ b/sample/basic/basic_anc_retrieve_policy_by_name_example.py @@ -40,9 +40,9 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if the 'quarantine_policy' has not # already been created. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_anc_update_policy_notification_example.py b/sample/basic/basic_anc_update_policy_notification_example.py index df06706..31f3985 100644 --- a/sample/basic/basic_anc_update_policy_notification_example.py +++ b/sample/basic/basic_anc_update_policy_notification_example.py @@ -38,8 +38,8 @@ class MyAncUpdatePolicyCallback(AncUpdatePolicyCallback): def on_update_policy(self, update_dict): - print(("on_update_policy\n" + - MessageUtils.dict_to_json(update_dict, pretty_print=True))) + print("on_update_policy\n" + + MessageUtils.dict_to_json(update_dict, pretty_print=True)) # Attach callback for 'update policy' events client.anc.add_update_policy_callback(MyAncUpdatePolicyCallback()) diff --git a/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py b/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py index 437806d..3a2a4ab 100644 --- a/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py +++ b/sample/basic/basic_eps_send_mitigation_action_by_ip_example.py @@ -46,8 +46,8 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) except Exception as ex: # An exception should be raised if no session exists for the endpoint. - print((str(ex))) + print(str(ex)) diff --git a/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py b/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py index 7778e3c..99d2e8b 100644 --- a/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py +++ b/sample/basic/basic_eps_send_mitigation_action_by_mac_example.py @@ -45,5 +45,5 @@ # Print out the response (convert dictionary to JSON for pretty # printing) - print(("Response:\n{0}".format( - MessageUtils.dict_to_json(resp_dict, pretty_print=True)))) + print("Response:\n{0}".format( + MessageUtils.dict_to_json(resp_dict, pretty_print=True))) diff --git a/sample/basic/basic_identity_session_notification_example.py b/sample/basic/basic_identity_session_notification_example.py index b133a93..161d0b5 100644 --- a/sample/basic/basic_identity_session_notification_example.py +++ b/sample/basic/basic_identity_session_notification_example.py @@ -38,8 +38,8 @@ class MyIdentitySessionCallback(IdentitySessionCallback): def on_session(self, session_dict): - print(("on_session\n" + - MessageUtils.dict_to_json(session_dict, pretty_print=True))) + print("on_session\n" + + MessageUtils.dict_to_json(session_dict, pretty_print=True)) # Attach callback for session events client.identity.add_session_callback(MyIdentitySessionCallback()) From 77d80852f117f8804914a93d84031fc2e26b3646 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Wed, 14 Mar 2018 16:37:33 -0700 Subject: [PATCH 04/12] Added pylint tasks and updated packaging for Python 3 --- .pylintrc | 559 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 17 +- clean.py | 24 +- dist.py | 27 +- doc/sdk/installation.rst | 5 +- setup.py | 73 ++++- 6 files changed, 664 insertions(+), 41 deletions(-) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..3e72172 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,559 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. +jobs=1 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + locally-enabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating, + unused-wildcard-import, + wildcard-import, + broad-except, + too-few-public-methods, + too-many-arguments, + missing-docstring, + protected-access + + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio).You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=optparse.Values,sys.exit + + +[BASIC] + +# Naming style matching correct argument names +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style +#argument-rgx= + +# Naming style matching correct attribute names +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style +#class-attribute-rgx= + +# Naming style matching correct class names +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming-style +#class-rgx= + +# Naming style matching correct constant names +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma +good-names=i, + j, + k, + ex, + Run, + _, + f, + fh, + logger, + running, + run_condition, + config_dir, + logging_config_path, + log_formatter, + console_handler + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# Naming style matching correct inline iteration names +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style +#inlinevar-rgx= + +# Naming style matching correct method names +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style +method-rgx=[a-z_][a-z0-9_]{2,}$ + +# Naming style matching correct module names +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style +#variable-rgx= + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^.*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in a if statement +max-bool-expr=5 + +# Maximum number of branch for function / method body +max-branches=12 + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of statements in function / method body +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub, + TERMIOS, + Bastion, + rexec + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/.travis.yml b/.travis.yml index 7dc96a5..54ad7a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ services: python: - "2.7" + - "3.4" + - "3.5" + - "3.6" before_install: - docker pull opendxl/opendxl-broker @@ -15,15 +18,15 @@ before_install: # command to install dependencies install: - - pip install dxlclient - - pip install . + - pip install .[test] + # Install through setup.py should be redundant because of the preceding pip + # install. Just doing this to try to catch any high-level errors. + - python setup.py install before_script: - - python -m dxlclient provisionconfig dxlclient/test 127.0.0.1 client -u admin -p password - - cp dxlclient/test/dxlclient.config dxlclient/test/client_config.cfg - - sed -i -e "s/external/unique_broker_id_1/g" -e "/local/d" dxlclient/test/client_config.cfg - - cat dxlclient/test/client_config.cfg + - python -m dxlclient provisionconfig sample 127.0.0.1 client -u admin -p password + - cat sample/dxlclient.config # command to run tests script: - - python setup.py install + - python setup.py ci diff --git a/clean.py b/clean.py index 5e1e922..cbe34f0 100644 --- a/clean.py +++ b/clean.py @@ -1,19 +1,23 @@ from __future__ import absolute_import from __future__ import print_function import os +# pylint: disable=no-name-in-module, import-error from distutils.dir_util import remove_tree from shutil import copyfile def clean_dir(src_dir, directory): if os.path.exists(directory): - print(("Cleaning directory: " + directory + "\n")) + print("Cleaning directory: " + directory + "\n") for f in os.listdir(directory): - if not os.path.isdir(os.path.join(directory, f)) and not f.lower().endswith(".py"): + target_file = os.path.join(directory, f) + if not os.path.isdir(target_file) and not f.lower().endswith(".py"): os.remove(os.path.join(directory, f)) for f in os.listdir(src_dir): - if not os.path.isdir(f) and not(f.lower().endswith(".py") or f.lower().endswith(".pyc")): - copyfile(os.path.join(src_dir, f), os.path.join(directory, f)) + src_file = os.path.join(src_dir, f) + if not os.path.isdir(src_file) and \ + not(f.lower().endswith(".py") or f.lower().endswith(".pyc")): + copyfile(src_file, os.path.join(directory, f)) print("Starting clean.\n") @@ -21,12 +25,14 @@ def clean_dir(src_dir, directory): DIST_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dist") CONFIG_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "config") SAMPLE_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "sample") -CONFIG_SRC_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient", "_config", "app") -SAMPLE_SRC_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient", "_config", "sample") +CONFIG_SRC_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient", + "_config", "app") +SAMPLE_SRC_DIRECTORY = os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient", + "_config", "sample") # Remove the dist directory if it exists if os.path.exists(DIST_DIRECTORY): - print(("Removing dist directory: " + DIST_DIRECTORY + "\n")) + print("Removing dist directory: " + DIST_DIRECTORY + "\n") remove_tree(DIST_DIRECTORY, verbose=1) # Clean the config directory @@ -38,7 +44,7 @@ def clean_dir(src_dir, directory): # Clean .pyc files print("Cleaning .pyc files") for root, dirs, files in os.walk(DIST_PY_FILE_LOCATION): - for file in files: - full_path = os.path.join(root, file) + for source_file in files: + full_path = os.path.join(root, source_file) if full_path.lower().endswith(".pyc"): os.remove(full_path) diff --git a/dist.py b/dist.py index 0adaca3..d8583f3 100644 --- a/dist.py +++ b/dist.py @@ -2,6 +2,8 @@ from __future__ import print_function import os import subprocess + +# pylint: disable=no-name-in-module, import-error from distutils.dir_util import copy_tree, remove_tree from distutils.file_util import copy_file, move_file from distutils.core import run_setup @@ -9,7 +11,7 @@ # Run clean -import clean +import clean # pylint: disable=unused-import print("Starting dist.\n") @@ -26,10 +28,10 @@ # Remove the dist directory if it exists if os.path.exists(DIST_DIRECTORY): - print(("\nRemoving dist directory: " + DIST_DIRECTORY + "\n")) + print("\nRemoving dist directory: " + DIST_DIRECTORY + "\n") remove_tree(DIST_DIRECTORY, verbose=1) -print(("\nMaking dist directory: " + DIST_DIRECTORY + "\n")) +print("\nMaking dist directory: " + DIST_DIRECTORY + "\n") os.makedirs(DIST_DIRECTORY) print("\nCalling sphinx-apidoc\n") @@ -41,11 +43,13 @@ os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient")]) print("\nCopying conf.py and sdk directory\n") -copy_file(os.path.join(DIST_PY_FILE_LOCATION, "doc", "conf.py"), os.path.join(DIST_DOCTMP_DIR, "conf.py")) +copy_file(os.path.join(DIST_PY_FILE_LOCATION, "doc", "conf.py"), + os.path.join(DIST_DOCTMP_DIR, "conf.py")) copy_tree(os.path.join(DIST_PY_FILE_LOCATION, "doc", "sdk"), DIST_DOCTMP_DIR) print("\nCalling sphinx-build\n") -subprocess.check_call(["sphinx-build", "-b", "html", DIST_DOCTMP_DIR, os.path.join(DIST_DIRECTORY, "doc")]) +subprocess.check_call(["sphinx-build", "-b", "html", DIST_DOCTMP_DIR, + os.path.join(DIST_DIRECTORY, "doc")]) # Delete .doctrees remove_tree(os.path.join(os.path.join(DIST_DIRECTORY, "doc"), ".doctrees"), verbose=1) @@ -66,24 +70,17 @@ "--dist-dir", DIST_LIB_DIRECTORY]) -print("\nRunning setup.py bdist_egg\n") -run_setup(SETUP_PY, - ["bdist_egg", - "--dist-dir", - DIST_LIB_DIRECTORY]) - print("\nRunning setup.py bdist_wheel\n") run_setup(SETUP_PY, ["bdist_wheel", "--dist-dir", DIST_LIB_DIRECTORY, - "--python-tag", - "py2.7"]) + "--universal"]) print("\nCopying sample into dist directory\n") copy_tree(os.path.join(DIST_PY_FILE_LOCATION, "sample"), SAMPLE_RELEASE_DIR) -print(("\nCopying dist to " + DIST_RELEASE_DIR + "\n")) +print("\nCopying dist to " + DIST_RELEASE_DIR + "\n") copy_tree(DIST_DIRECTORY, DIST_RELEASE_DIR) print("\nRemoving build directory\n") @@ -95,5 +92,5 @@ print("\nMaking dist zip\n") make_archive(DIST_RELEASE_DIR, "zip", DIST_DIRECTORY, RELEASE_NAME) -print(("\nRemoving " + DIST_RELEASE_DIR + "\n")) +print("\nRemoving " + DIST_RELEASE_DIR + "\n") remove_tree(DIST_RELEASE_DIR) diff --git a/doc/sdk/installation.rst b/doc/sdk/installation.rst index 045bf42..33e940f 100644 --- a/doc/sdk/installation.rst +++ b/doc/sdk/installation.rst @@ -13,6 +13,9 @@ Prerequisites * The DXL fabric to which the client will connect has been bridged to Cisco pxGrid. +* Python 2.7.9 or higher in the Python 2.x series or Python 3.4.0 or higher + in the Python 3.x series installed within a Windows or Linux environment. + Installation ************ @@ -20,7 +23,7 @@ Use ``pip`` to automatically install the library: .. parsed-literal:: - pip install dxlciscopxgridclient-\ |version|\-py2.7-none-any.whl + pip install dxlciscopxgridclient-\ |version|\-py2.py3-none-any.whl Or with: diff --git a/setup.py b/setup.py index 49fd674..0c881de 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,63 @@ +# pylint: disable=no-member, no-name-in-module, import-error + from __future__ import absolute_import +import glob import os -from setuptools import setup import distutils.command.sdist - +import distutils.log +import subprocess +from setuptools import Command, setup import setuptools.command.sdist # Patch setuptools' sdist behaviour with distutils' sdist behaviour setuptools.command.sdist.sdist.run = distutils.command.sdist.sdist.run -version_info = {} -cwd=os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(cwd, "dxlciscopxgridclient", "_version.py")) as f: - exec(f.read(), version_info) +VERSION_INFO = {} +CWD = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(CWD, "dxlciscopxgridclient", "_version.py")) as f: + exec(f.read(), VERSION_INFO) # pylint: disable=exec-used + + +class LintCommand(Command): + """ + Custom setuptools command for running lint + """ + description = 'run lint against project source files' + user_options = [] + def initialize_options(self): + pass + def finalize_options(self): + pass + def run(self): + self.announce("Running pylint for library source files and tests", + level=distutils.log.INFO) + subprocess.check_call(["pylint", "dxlciscopxgridclient"] + glob.glob("*.py")) + + +class CiCommand(Command): + """ + Custom setuptools command for running steps that are performed during + Continuous Integration testing. + """ + description = 'run CI steps (lint, test, etc.)' + user_options = [] + def initialize_options(self): + pass + def finalize_options(self): + pass + def run(self): + self.run_command("lint") -dist = setup( +TEST_REQUIREMENTS = ["pylint"] + +DEV_REQUIREMENTS = TEST_REQUIREMENTS + ["sphinx"] + +setup( # Package name: name="dxlciscopxgridclient", # Version number: - version=version_info["__version__"], + version=VERSION_INFO["__version__"], # Requirements install_requires=[ @@ -26,6 +65,13 @@ "dxlclient" ], + tests_require=TEST_REQUIREMENTS, + + extras_require={ + "dev": DEV_REQUIREMENTS, + "test": TEST_REQUIREMENTS + }, + # Package author details: author="McAfee LLC", @@ -55,7 +101,16 @@ "Development Status :: 4 - Beta", "Topic :: Software Development :: Libraries :: Python Modules", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", + "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6" ], + + cmdclass={ + "ci": CiCommand, + "lint": LintCommand + } ) From c5623b48687032e14e48d5f3aef83d4f073c1263 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Fri, 16 Mar 2018 10:13:21 -0700 Subject: [PATCH 05/12] Update pylint glob to parse all sample files --- .pylintrc.samples | 553 ++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 7 +- 2 files changed, 559 insertions(+), 1 deletion(-) create mode 100644 .pylintrc.samples diff --git a/.pylintrc.samples b/.pylintrc.samples new file mode 100644 index 0000000..89859c3 --- /dev/null +++ b/.pylintrc.samples @@ -0,0 +1,553 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. +jobs=1 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + locally-enabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating, + invalid-name, + wrong-import-position, + missing-docstring, + wildcard-import, + unused-wildcard-import, + broad-except, + too-few-public-methods, + redefined-outer-name, + undefined-variable, + logging-not-lazy, + import-error, + similarities + + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio).You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=optparse.Values,sys.exit + + +[BASIC] + +# Naming style matching correct argument names +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style +#argument-rgx= + +# Naming style matching correct attribute names +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style +#class-attribute-rgx= + +# Naming style matching correct class names +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming-style +#class-rgx= + +# Naming style matching correct constant names +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma +good-names=i, + j, + k, + ex, + Run, + _, + logger + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# Naming style matching correct inline iteration names +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style +#inlinevar-rgx= + +# Naming style matching correct method names +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style +#method-rgx= + +# Naming style matching correct module names +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style +#variable-rgx= + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in a if statement +max-bool-expr=5 + +# Maximum number of branch for function / method body +max-branches=12 + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of statements in function / method body +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=optparse,tkinter.tix + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/setup.py b/setup.py index 0c881de..1ca61c3 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,12 @@ def finalize_options(self): def run(self): self.announce("Running pylint for library source files and tests", level=distutils.log.INFO) - subprocess.check_call(["pylint", "dxlciscopxgridclient"] + glob.glob("*.py")) + subprocess.check_call(["pylint", "dxlciscopxgridclient"] + + glob.glob("*.py")) + self.announce("Running pylint for samples", level=distutils.log.INFO) + subprocess.check_call(["pylint"] + glob.glob("sample/*.py") + + glob.glob("sample/**/*.py") + + ["--rcfile", ".pylintrc.samples"]) class CiCommand(Command): From 42d7937cdbd6ff07e4c899cd41a033869b739335 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Fri, 16 Mar 2018 12:46:49 -0700 Subject: [PATCH 06/12] Add python_requires to setup.py --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 1ca61c3..1feb439 100644 --- a/setup.py +++ b/setup.py @@ -102,6 +102,8 @@ def run(self): long_description=open('README').read(), + python_requires='>=2.7.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', + classifiers=[ "Development Status :: 4 - Beta", "Topic :: Software Development :: Libraries :: Python Modules", From 5da04f35cb9609c7867bdfafa476f31bd57d6a01 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Mon, 26 Mar 2018 17:26:46 -0700 Subject: [PATCH 07/12] Disable smart quotes and dashes during Sphinx doc generation --- dist.py | 4 +++- doc/conf.py | 1 + doc/docutils.conf | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 doc/docutils.conf diff --git a/dist.py b/dist.py index d8583f3..79d38db 100644 --- a/dist.py +++ b/dist.py @@ -42,9 +42,11 @@ "--output-dir=" + DIST_DOCTMP_DIR, os.path.join(DIST_PY_FILE_LOCATION, "dxlciscopxgridclient")]) -print("\nCopying conf.py and sdk directory\n") +print("\nCopying conf.py, docutils.conf, and sdk directory\n") copy_file(os.path.join(DIST_PY_FILE_LOCATION, "doc", "conf.py"), os.path.join(DIST_DOCTMP_DIR, "conf.py")) +copy_file(os.path.join(DIST_PY_FILE_LOCATION, "doc", "docutils.conf"), + os.path.join(DIST_DOCTMP_DIR, "docutils.conf")) copy_tree(os.path.join(DIST_PY_FILE_LOCATION, "doc", "sdk"), DIST_DOCTMP_DIR) print("\nCalling sphinx-build\n") diff --git a/doc/conf.py b/doc/conf.py index fc5b538..fe33ed7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -63,3 +63,4 @@ modindex_common_prefix = ['dxlciscopxgridclient.'] +html_use_smartypants = False diff --git a/doc/docutils.conf b/doc/docutils.conf new file mode 100644 index 0000000..e337933 --- /dev/null +++ b/doc/docutils.conf @@ -0,0 +1,2 @@ +[parsers] +smart_quotes = False From 1fba4502cfd939e0e72ca4608f06f944e15f1c35 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Wed, 11 Apr 2018 09:10:00 -0700 Subject: [PATCH 08/12] Remove egg reference from README.html --- doc/sdk/README.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sdk/README.html b/doc/sdk/README.html index 6d1af73..01d8f36 100644 --- a/doc/sdk/README.html +++ b/doc/sdk/README.html @@ -15,7 +15,7 @@

Cisco pxGrid DXL Client Library

This distribution contains following directories:
  • doc
    • Cisco pxGrid DXL Client Library documentation
  • -
  • lib
    • Cisco pxGrid DXL Client Library libraries (.zip, .egg, .whl)
  • +
  • lib
    • Cisco pxGrid DXL Client Library libraries (.zip, .whl)
  • sample
    • Samples that demonstrate using the Cisco pxGrid DXL Client Library

From 7ffa879a3a08021fcc68c8b028ac71db4d0ec1b8 Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Thu, 12 Apr 2018 12:28:59 -0700 Subject: [PATCH 09/12] Update copyright year to 2018 --- README | 2 +- README.md | 2 +- doc/conf.py | 2 +- doc/sdk/README.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 0c2e03c..58eac26 100644 --- a/README +++ b/README @@ -30,7 +30,7 @@ For bugs, questions and discussions please use the LICENSE ------- -Copyright 2017 McAfee LLC +Copyright 2018 McAfee LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the diff --git a/README.md b/README.md index 61e53f1..4a73eab 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ For bugs, questions and discussions please use the ## LICENSE -Copyright 2017 McAfee, Inc. +Copyright 2018 McAfee, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the diff --git a/doc/conf.py b/doc/conf.py index fe33ed7..9079da7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -31,7 +31,7 @@ # General information about the project. project = "Cisco pxGrid DXL Client Library" -copyright = "2017 McAfee LLC" +copyright = "2018 McAfee LLC" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/doc/sdk/README.html b/doc/sdk/README.html index 01d8f36..a27c9ac 100644 --- a/doc/sdk/README.html +++ b/doc/sdk/README.html @@ -28,7 +28,7 @@

Cisco pxGrid DXL Client Library

From eb8d029171458f91b4311a45afdc2094fecbfddd Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Mon, 23 Apr 2018 15:47:21 -0700 Subject: [PATCH 10/12] Bump minimum bootstrap and client dependencies for Python 3 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1feb439..869a3bd 100644 --- a/setup.py +++ b/setup.py @@ -66,8 +66,8 @@ def run(self): # Requirements install_requires=[ - "dxlbootstrap>=0.1.3", - "dxlclient" + "dxlbootstrap>=0.2.0", + "dxlclient>=4.1.0.184" ], tests_require=TEST_REQUIREMENTS, From 357e65e1e8d63a337d584d8568051c8f430e548d Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Fri, 27 Apr 2018 17:22:58 -0700 Subject: [PATCH 11/12] Disable justification in Sphinx doc generation --- dist.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dist.py b/dist.py index 79d38db..1683743 100644 --- a/dist.py +++ b/dist.py @@ -2,6 +2,8 @@ from __future__ import print_function import os import subprocess +from tempfile import mkstemp +from shutil import move # pylint: disable=no-name-in-module, import-error from distutils.dir_util import copy_tree, remove_tree @@ -13,6 +15,19 @@ # Run clean import clean # pylint: disable=unused-import +def replace(file_path, pattern, subst): + # Create temp file + fh, abs_path = mkstemp() + with open(abs_path, 'w') as new_file: + with open(file_path) as old_file: + for line in old_file: + new_file.write(line.replace(pattern, subst)) + os.close(fh) + # Remove original file + os.remove(file_path) + # Move new file + move(abs_path, file_path) + print("Starting dist.\n") VERSION = __import__('dxlciscopxgridclient').get_version() @@ -53,6 +68,9 @@ subprocess.check_call(["sphinx-build", "-b", "html", DIST_DOCTMP_DIR, os.path.join(DIST_DIRECTORY, "doc")]) +replace(os.path.join(DIST_DIRECTORY, "doc", "_static", "classic.css"), + "text-align: justify", "text-align: none") + # Delete .doctrees remove_tree(os.path.join(os.path.join(DIST_DIRECTORY, "doc"), ".doctrees"), verbose=1) # Delete .buildinfo From e5b2831d08cd348997f8ece23692b9fc2048f3fb Mon Sep 17 00:00:00 2001 From: Jeremy Barlow Date: Fri, 27 Apr 2018 17:23:07 -0700 Subject: [PATCH 12/12] Bump version to 0.2.0 --- dxlciscopxgridclient/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dxlciscopxgridclient/_version.py b/dxlciscopxgridclient/_version.py index b3f4756..d3ec452 100644 --- a/dxlciscopxgridclient/_version.py +++ b/dxlciscopxgridclient/_version.py @@ -1 +1 @@ -__version__ = "0.1.2" +__version__ = "0.2.0"