From b340ea15add30d136eb46b8998aee0ffb1a72115 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 23 Jan 2017 20:06:18 -0700 Subject: Update the pep8 goodness and test with circle and flake8 --- .flake8 | 6 ++ bin/logwatcher.py | 2 +- circle.yml | 5 +- docs/conf.py | 109 +++++++++++++++++------------------ eventmq/client/jobs.py | 2 +- eventmq/client/messages.py | 5 +- eventmq/conf.py | 2 +- eventmq/jobmanager.py | 14 ++--- eventmq/log.py | 4 +- eventmq/pub.py | 10 +--- eventmq/publisher.py | 4 +- eventmq/receiver.py | 1 + eventmq/router.py | 40 +++++++------ eventmq/scheduler.py | 18 +++--- eventmq/subscriber.py | 4 +- eventmq/tests/test_client_jobs.py | 1 + eventmq/tests/test_jobmanager.py | 4 +- eventmq/tests/test_receiver.py | 6 +- eventmq/tests/test_router.py | 11 ++-- eventmq/tests/test_scheduler.py | 5 +- eventmq/tests/test_sender.py | 2 - eventmq/tests/test_utils.py | 4 +- eventmq/tests/test_utils_encoding.py | 1 + eventmq/tests/utils.py | 3 +- eventmq/utils/classes.py | 2 +- eventmq/utils/encoding.py | 2 - eventmq/utils/functions.py | 2 +- eventmq/utils/messages.py | 2 +- eventmq/utils/timeutils.py | 2 +- eventmq/worker.py | 6 +- requirements_.txt | 19 ------ setup.py | 17 +++++- 32 files changed, 151 insertions(+), 164 deletions(-) create mode 100644 .flake8 delete mode 100644 requirements_.txt diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..657b97b --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +# Packages that should be considered local to the app. These need to be in the last group +application-import-names=eventmq + +# Same as pep8 but enforces alphabetical ordering +import-order-style=google \ No newline at end of file diff --git a/bin/logwatcher.py b/bin/logwatcher.py index f83c905..dd2860f 100644 --- a/bin/logwatcher.py +++ b/bin/logwatcher.py @@ -13,4 +13,4 @@ while True: if events.get(s) == zmq.POLLIN: msg = s.recv_multipart() - print msg + print msg # noqa diff --git a/circle.yml b/circle.yml index 6a8652b..8ad95de 100644 --- a/circle.yml +++ b/circle.yml @@ -5,8 +5,9 @@ machine: - redis test: override: - - pip install --upgrade -r requirements_.txt + - pip install -e .[testing] - nosetests-2.7 --with-coverage --cover-inclusive --cover-package=eventmq --cover-tests - - pip3.5 install --upgrade -r requirements_.txt + - pip3.5 install -e .[testing] - /opt/circleci/python/3.5.2/bin/nosetests-3.4 + - find . -name \*.py -print | xargs flake8 --show-source --statistics - coverage html -d "$CIRCLE_ARTIFACTS/coverage" diff --git a/docs/conf.py b/docs/conf.py index 1e28fa9..7cc2c14 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,21 +11,16 @@ # # All configuration values have a default; values that are commented out # serve to show the default. - -import sys -import os -import shlex - import eventmq # for __version__ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -46,7 +41,7 @@ templates_path = ['_templates'] source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' @@ -74,9 +69,9 @@ language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -84,27 +79,27 @@ exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -119,26 +114,26 @@ html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -148,62 +143,62 @@ html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +# html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} +# html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +# html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'EventMQdoc' @@ -211,17 +206,17 @@ htmlhelp_basename = 'EventMQdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', -# Latex figure (float) alignment -#'figure_align': 'htbp', + # Latex figure (float) alignment + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples @@ -234,23 +229,23 @@ latex_documents = [ # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- @@ -263,7 +258,7 @@ man_pages = [ ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -278,16 +273,16 @@ texinfo_documents = [ ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. diff --git a/eventmq/client/jobs.py b/eventmq/client/jobs.py index 0278ccd..2f4f784 100644 --- a/eventmq/client/jobs.py +++ b/eventmq/client/jobs.py @@ -19,9 +19,9 @@ import logging import os +from . import messages from ..constants import ENV_BROKER_ADDR from ..sender import Sender -from . import messages logger = logging.getLogger(__name__) diff --git a/eventmq/client/messages.py b/eventmq/client/messages.py index 02ef2d9..1963e6e 100644 --- a/eventmq/client/messages.py +++ b/eventmq/client/messages.py @@ -16,13 +16,14 @@ :mod:`messages` -- Client Messaging =================================== """ -import logging from json import dumps as serialize +import logging + from past.builtins import basestring from .. import conf -from ..utils.messages import send_emqp_message from ..utils.functions import name_from_callable, split_callable_name +from ..utils.messages import send_emqp_message logger = logging.getLogger(__name__) diff --git a/eventmq/conf.py b/eventmq/conf.py index 6a0b3a4..cec0249 100644 --- a/eventmq/conf.py +++ b/eventmq/conf.py @@ -86,6 +86,6 @@ RQ_PORT = 6379 RQ_DB = 0 RQ_PASSWORD = '' -MAX_JOB_COUNT=1024 +MAX_JOB_COUNT = 1024 # }}} diff --git a/eventmq/jobmanager.py b/eventmq/jobmanager.py index ed48e0d..9d0afbc 100644 --- a/eventmq/jobmanager.py +++ b/eventmq/jobmanager.py @@ -17,25 +17,25 @@ ================================ Ensures things about jobs and spawns the actual tasks """ -import sys +from json import loads as deserializer import logging +from multiprocessing import Queue as mp_queue import signal -import zmq +import sys -from json import loads as deserializer +import zmq +from eventmq.log import setup_logger from . import conf from .constants import KBYE from .poller import Poller, POLLIN from .sender import Sender from .utils.classes import EMQPService, HeartbeatMixin -from .utils.settings import import_settings from .utils.devices import generate_device_name -from .utils.messages import send_emqp_message as sendmsg from .utils.functions import get_timeout_from_headers +from .utils.messages import send_emqp_message as sendmsg +from .utils.settings import import_settings from .worker import MultiprocessWorker as Worker -from eventmq.log import setup_logger -from multiprocessing import Queue as mp_queue if sys.version[0] == '2': import Queue diff --git a/eventmq/log.py b/eventmq/log.py index 325aa16..2c5919d 100644 --- a/eventmq/log.py +++ b/eventmq/log.py @@ -53,8 +53,8 @@ def setup_logger(base_name, formatter=FORMAT_STANDARD, logger.setLevel(logging.DEBUG) # remove handlers we don't want - #for h in logger.handlers: - # logger.removeHandler(h) + # for h in logger.handlers: + # logger.removeHandler(h) if handler == handlers.PUBLISH_HANDLER: _handler_sock = zmq.Context.instance().socket(zmq.PUB) diff --git a/eventmq/pub.py b/eventmq/pub.py index 2a27c40..3918580 100644 --- a/eventmq/pub.py +++ b/eventmq/pub.py @@ -17,17 +17,13 @@ ======================= Publishes messages to subscribers """ -import zmq - import logging -from . import conf, receiver, poller, publisher +from eventmq.log import setup_logger +from . import conf, poller, publisher, receiver +from .constants import STATUS from .utils.classes import HeartbeatMixin -from .utils.timeutils import monotonic, timestamp -from .constants import (STATUS, CLIENT_TYPE, PROTOCOL_VERSION, KBYE, - DISCONNECT) -from eventmq.log import setup_logger from .utils.settings import import_settings logger = logging.getLogger(__name__) diff --git a/eventmq/publisher.py b/eventmq/publisher.py index 23eb04e..2e77bcd 100644 --- a/eventmq/publisher.py +++ b/eventmq/publisher.py @@ -17,11 +17,11 @@ ======================= Publishes messages to subscribers """ -import zmq import logging -from . import constants +import zmq +from . import constants from .utils.devices import generate_device_name logger = logging.getLogger(__name__) diff --git a/eventmq/receiver.py b/eventmq/receiver.py index 2d28594..4450e2e 100644 --- a/eventmq/receiver.py +++ b/eventmq/receiver.py @@ -18,6 +18,7 @@ The receiver is responsible for receiveing messages """ import logging + import zmq from . import constants diff --git a/eventmq/router.py b/eventmq/router.py index 71f40d3..2943e3c 100644 --- a/eventmq/router.py +++ b/eventmq/router.py @@ -22,22 +22,22 @@ import json # deserialize queues in on_inform. should be refactored import logging import signal +from eventmq.log import setup_logger from . import conf, constants, exceptions, poller, receiver from .constants import ( - STATUS, CLIENT_TYPE, PROTOCOL_VERSION, KBYE, DISCONNECT, - ROUTER_SHOW_SCHEDULERS, ROUTER_SHOW_WORKERS + CLIENT_TYPE, DISCONNECT, KBYE, PROTOCOL_VERSION, ROUTER_SHOW_SCHEDULERS, + ROUTER_SHOW_WORKERS, STATUS ) +from .utils import tuplify from .utils.classes import EMQdeque, HeartbeatMixin +from .utils.devices import generate_device_name from .utils.messages import ( - send_emqp_router_message as sendmsg, fwd_emqp_router_message as fwdmsg, - parse_router_message + parse_router_message, + send_emqp_router_message as sendmsg, ) -from .utils import tuplify from .utils.settings import import_settings -from .utils.devices import generate_device_name from .utils.timeutils import monotonic, timestamp -from eventmq.log import setup_logger logger = logging.getLogger(__name__) @@ -111,12 +111,12 @@ class Router(HeartbeatMixin): self.schedulers = {} #: Latency tracking dictionary - #: Key: msgid of message each REQUEST received and forwarded to a worker + #: Key: msgid of msg each REQUEST received and forwarded to a worker #: Value: (timestamp, queue_name) self.job_latencies = {} #: Excecuted function tracking dictionary - #: Key: msgid of message each REQUEST received and forwarded to a worker + #: Key: msgid of msg each REQUEST received and forwarded to a worker #: Value: (function_name, queue_name) self.executed_functions = {} @@ -186,7 +186,8 @@ class Router(HeartbeatMixin): if len(msg) > 4: if msg[3] == DISCONNECT: logger.info('Received DISCONNECT from administrator') - self.send_ack(self.administrative_socket, msg[0], msg[4]) + self.send_ack( + self.administrative_socket, msg[0], msg[4]) self.on_disconnect(msg[4], msg) elif msg[3] == 'STATUS': sendmsg(self.administrative_socket, msg[0], 'REPLY', @@ -334,11 +335,13 @@ class Router(HeartbeatMixin): sender, msgid, orig_msgid)) if orig_msgid in self.job_latencies: + elapsed_secs = (monotonic() + - self.job_latencies[orig_msgid][0]) * 1000.0 logger.info("Completed {queue} job with msgid: {msgid} in " - "{time:.2f}ms".\ - format(queue=self.job_latencies[orig_msgid][1], - msgid=orig_msgid, - time=(monotonic()-self.job_latencies[orig_msgid][0])*1000.0)) + "{time:.2f}ms".format( + queue=self.job_latencies[orig_msgid][1], + msgid=orig_msgid, + time=elapsed_secs)) del self.job_latencies[orig_msgid] def on_disconnect(self, msgid, msg): @@ -400,7 +403,8 @@ class Router(HeartbeatMixin): fwdmsg(self.outgoing, sender, msg) self.waiting_messages[queue_name].popleft() except exceptions.PeerGoneAwayError: - # Cleanup a worker that cannot be contacted, leaving the message in queue + # Cleanup a workerg that cannot be contacted, leaving the + # message in queue self.workers[sender]['hb'] = 0 self.clean_up_dead_workers() @@ -460,8 +464,8 @@ class Router(HeartbeatMixin): # Set queue limit to be 75% of total memory with ~100 byte # messages limit = int((total_mem / 100) * 0.75) - self.waiting_messages[queue_name] = \ - EMQdeque(full=limit, on_full=router_on_full) + self.waiting_messages[queue_name] = EMQdeque( + full=limit, on_full=router_on_full) else: self.waiting_messages[queue_name] = \ EMQdeque(full=conf.HWM, @@ -922,4 +926,4 @@ def router_on_full(): # Entry point for pip console scripts def router_main(): - r = Router() + Router() diff --git a/eventmq/scheduler.py b/eventmq/scheduler.py index ab542cc..7f19d84 100644 --- a/eventmq/scheduler.py +++ b/eventmq/scheduler.py @@ -18,26 +18,26 @@ Handles cron and other scheduled tasks """ import json +from json import dumps as serialize +from json import loads as deserialize import logging -import redis from croniter import croniter +import redis from six import next +from eventmq.log import setup_logger + from . import conf, constants +from .client.messages import send_request from .constants import KBYE -from .sender import Sender from .poller import Poller, POLLIN +from .sender import Sender from .utils.classes import EMQPService, HeartbeatMixin -from json import loads as deserialize -from json import dumps as serialize from .utils.messages import send_emqp_message as sendmsg from .utils.settings import import_settings -from .utils.timeutils import IntervalIter -from .utils.timeutils import seconds_until, timestamp, monotonic -from .client.messages import send_request +from .utils.timeutils import IntervalIter, monotonic, seconds_until, timestamp -from eventmq.log import setup_logger logger = logging.getLogger(__name__) CRON_CALLER_ID = -1 @@ -463,4 +463,4 @@ def scheduler_main(): def test_job(): - print("hello!") + print("hello!") # noqa diff --git a/eventmq/subscriber.py b/eventmq/subscriber.py index 5976856..f585572 100644 --- a/eventmq/subscriber.py +++ b/eventmq/subscriber.py @@ -2,7 +2,7 @@ derp subscriber """ import zmq -import sys + if __name__ == "__main__": sockets = [] @@ -18,4 +18,4 @@ if __name__ == "__main__": # block until something comes in. normally you'd do something with # this in another thread or something for s in sockets: - print s.recv_multipart() + print s.recv_multipart() # noqa diff --git a/eventmq/tests/test_client_jobs.py b/eventmq/tests/test_client_jobs.py index 45e6a90..6a7d054 100644 --- a/eventmq/tests/test_client_jobs.py +++ b/eventmq/tests/test_client_jobs.py @@ -19,6 +19,7 @@ from testfixtures import LogCapture from ..client import jobs + class TestCase(unittest.TestCase): BROKER_ADDR = 'tcp://127.0.0.1:3748' diff --git a/eventmq/tests/test_jobmanager.py b/eventmq/tests/test_jobmanager.py index d36a7db..d0497bc 100644 --- a/eventmq/tests/test_jobmanager.py +++ b/eventmq/tests/test_jobmanager.py @@ -89,7 +89,9 @@ class TestCase(unittest.TestCase): def test_on_request_with_timeout_and_reply(self): timeout = 3 _msgid = 'aaa0j8-ac40jf0-04tjv' - _msg = ['a', 'timeout:{},reply-requested'.format(timeout), '["run", {"a": 1}]'] + _msg = ['a', + 'timeout:{},reply-requested'.format(timeout), + '["run", {"a": 1}]'] jm = jobmanager.JobManager() diff --git a/eventmq/tests/test_receiver.py b/eventmq/tests/test_receiver.py index 90e1d3b..4ee7170 100644 --- a/eventmq/tests/test_receiver.py +++ b/eventmq/tests/test_receiver.py @@ -15,12 +15,8 @@ import unittest import zmq -import signal -import os -from .. import router -from .. import receiver -from .. import sender +from .. import receiver, router, sender class TestCase(unittest.TestCase): diff --git a/eventmq/tests/test_router.py b/eventmq/tests/test_router.py index 0832a7d..fdb02d0 100644 --- a/eventmq/tests/test_router.py +++ b/eventmq/tests/test_router.py @@ -14,7 +14,6 @@ # along with eventmq. If not, see . import json import unittest -import uuid from freezegun import freeze_time import mock @@ -344,7 +343,7 @@ class TestCase(unittest.TestCase): } } self.router.queues = { - queue: [(10, worker_id),] + queue: [(10, worker_id), ] } # Router accepts job for 1 available slot @@ -715,7 +714,7 @@ class TestCase(unittest.TestCase): } self.router.process_worker_message((w2, '', constants.PROTOCOL_VERSION, - command, msgid) + msg) + command, msgid) + msg) self.assertNotIn( w2, self.router.queues[queue1_id], "Worker not removed from {}".format(queue1_id)) @@ -780,9 +779,9 @@ class TestCase(unittest.TestCase): 'job_latencies': self.router.job_latencies, 'executed_functions': self.router.executed_functions, 'waiting_message_counts': [ - '{}: {}'.format(q, - len(self.router.waiting_messages[q])) - for q in self.router.waiting_messages] + '{}: {}'.format( + q, + len(self.router.waiting_messages[q])) for q in self.router.waiting_messages] # noqa })), json.loads(self.router.get_status())) diff --git a/eventmq/tests/test_scheduler.py b/eventmq/tests/test_scheduler.py index df3779f..eb52dec 100644 --- a/eventmq/tests/test_scheduler.py +++ b/eventmq/tests/test_scheduler.py @@ -12,12 +12,9 @@ # # You should have received a copy of the GNU Lesser General Public License # along with eventmq. If not, see . -import time import unittest -import mock - -from .. import conf, constants, scheduler +from .. import constants, scheduler ADDR = 'inproc://pour_the_rice_in_the_thing' diff --git a/eventmq/tests/test_sender.py b/eventmq/tests/test_sender.py index 8178e30..b2570a3 100644 --- a/eventmq/tests/test_sender.py +++ b/eventmq/tests/test_sender.py @@ -15,8 +15,6 @@ import unittest import zmq -import signal -import os from .. import sender diff --git a/eventmq/tests/test_utils.py b/eventmq/tests/test_utils.py index 478a997..03da18a 100644 --- a/eventmq/tests/test_utils.py +++ b/eventmq/tests/test_utils.py @@ -22,9 +22,7 @@ import mock from .. import constants from .. import exceptions -from ..utils import messages -from ..utils import classes -from ..utils import settings +from ..utils import classes, messages, settings class SettingsTestCase(unittest.TestCase): diff --git a/eventmq/tests/test_utils_encoding.py b/eventmq/tests/test_utils_encoding.py index bcc0be2..a02ce96 100644 --- a/eventmq/tests/test_utils_encoding.py +++ b/eventmq/tests/test_utils_encoding.py @@ -37,6 +37,7 @@ class TestCase(unittest.TestCase): (b'one', 1, (b'two', 2, [b'three', 3], {'asdf': 90, 'bp': b'adam'}))) + def test_encodify_dict(self): test_dict = { 'key1': 1, diff --git a/eventmq/tests/utils.py b/eventmq/tests/utils.py index 4bbbb51..23f34c0 100644 --- a/eventmq/tests/utils.py +++ b/eventmq/tests/utils.py @@ -12,13 +12,12 @@ # # You should have received a copy of the GNU General Public License # along with eventmq. If not, see . -import time import uuid import zmq from .. import conf, constants -from ..utils.classes import ZMQSendMixin, ZMQReceiveMixin +from ..utils.classes import ZMQReceiveMixin, ZMQSendMixin from ..utils.devices import generate_device_name diff --git a/eventmq/utils/classes.py b/eventmq/utils/classes.py index 7233498..d1ca275 100644 --- a/eventmq/utils/classes.py +++ b/eventmq/utils/classes.py @@ -17,12 +17,12 @@ ================================= Defines some classes to use when implementing ZMQ devices """ +from collections import deque import json import logging import zmq.error -from collections import deque from .. import conf, constants, exceptions, poller, utils from ..utils.encoding import encodify from ..utils.messages import send_emqp_message as sendmsg diff --git a/eventmq/utils/encoding.py b/eventmq/utils/encoding.py index 1b7c936..d45624e 100644 --- a/eventmq/utils/encoding.py +++ b/eventmq/utils/encoding.py @@ -12,8 +12,6 @@ # # You should have received a copy of the GNU Lesser General Public License # along with eventmq. If not, see . -from copy import copy -from codecs import encode from past.builtins import basestring from .. import conf diff --git a/eventmq/utils/functions.py b/eventmq/utils/functions.py index f0e6366..0d64725 100644 --- a/eventmq/utils/functions.py +++ b/eventmq/utils/functions.py @@ -1,7 +1,7 @@ -import json import hashlib import importlib import inspect +import json from .. import log from ..exceptions import CallableFromPathError diff --git a/eventmq/utils/messages.py b/eventmq/utils/messages.py index 32bf2ce..02ac129 100644 --- a/eventmq/utils/messages.py +++ b/eventmq/utils/messages.py @@ -18,8 +18,8 @@ """ import logging -from .. import conf, constants, exceptions from . import random_characters +from .. import conf, constants, exceptions logger = logging.getLogger(__name__) diff --git a/eventmq/utils/timeutils.py b/eventmq/utils/timeutils.py index 0f777a6..b33e18d 100644 --- a/eventmq/utils/timeutils.py +++ b/eventmq/utils/timeutils.py @@ -17,7 +17,7 @@ ================================= """ try: - from time import monotonic as _monotonic # Python3 + from time import monotonic as _monotonic # Python3 except ImportError: from monotonic import monotonic as _monotonic from time import time as _time diff --git a/eventmq/worker.py b/eventmq/worker.py index 29814f4..7729120 100644 --- a/eventmq/worker.py +++ b/eventmq/worker.py @@ -18,12 +18,12 @@ Defines different short-lived workers that execute jobs """ from importlib import import_module +import logging from multiprocessing import Process +import os from threading import Thread -from . import conf -import logging -import os +from . import conf logger = logging.getLogger(__name__) diff --git a/requirements_.txt b/requirements_.txt deleted file mode 100644 index dd252bc..0000000 --- a/requirements_.txt +++ /dev/null @@ -1,19 +0,0 @@ -pyzmq==15.4.0 -six==1.10.0 -monotonic==0.4 # A clock who's time is not changed. used for scheduling -croniter==0.3.10 -redis==2.10.3 -future==0.15.2 -psutil==5.0.0 - -# Documentation -sphinxcontrib-napoleon==0.4.3 -Sphinx==1.3.1 # must come after napoleon to get the latest version - -# Testing -nose==1.3.6 -coverage==4.0.3 -testfixtures==4.7.0 # To test that logging exists -mock==1.3.0 -freezegun==0.3.7 -tl.testing==0.5 diff --git a/setup.py b/setup.py index 31c35c7..115e102 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ EventMQ setup.py file for distribution """ -from setuptools import setup, find_packages +from setuptools import find_packages, setup setup( name='eventmq', @@ -18,6 +18,19 @@ setup( 'future==0.15.2', 'psutil==5.0.0', 'python-dateutil>=2.1,<3.0.0'], + extras_require={ + 'docs': ['Sphinx==1.5.2', ], + 'testing': [ + 'flake8==3.2.1', + 'flake8-import-order==0.11', + 'flake8-print==2.0.2', + 'nose', + 'coverage==4.0.3', + 'testfixtures==4.7.0', + 'freezegun==0.3.7', + 'tl.testing==0.5', + 'mock==1.3.0'], + }, author='EventMQ Contributors', url='https://github.com/enderlabs/eventmq/', @@ -34,7 +47,7 @@ setup( 'Topic :: System :: Distributed Computing', # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)', + 'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)', # noqa 'Operating System :: OS Independent', # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. -- cgit v1.2.1