diff --git a/rattail/commands/core.py b/rattail/commands/core.py index d66e37a6693c054ebfe94904e04ad577db20a32d..d758c693ed207265b53239c5fd5726291ca9a41e 100644 --- a/rattail/commands/core.py +++ b/rattail/commands/core.py @@ -683,7 +683,7 @@ class FileMonitorCommand(Subcommand): stop = subparsers.add_parser('stop', help="Stop service") stop.set_defaults(subcommand='stop') - if sys.platform == 'linux2': + if sys.platform in ('linux', 'linux2'): parser.add_argument('-p', '--pidfile', help="Path to PID file.", metavar='PATH') parser.add_argument('--daemonize', action='store_true', default=True, # TODO: should default to False @@ -709,7 +709,7 @@ class FileMonitorCommand(Subcommand): uninstall.set_defaults(subcommand='remove') def run(self, args): - if sys.platform == 'linux2': + if sys.platform in ('linux', 'linux2'): from rattail.filemon import linux as filemon if args.subcommand == 'start': diff --git a/rattail/filemon/actions.py b/rattail/filemon/actions.py index 2251c15cf4f07ac5af6f6591e685e9793dd7640d..e39ce3fca1275d327bae8aa2d9900a481a667129 100644 --- a/rattail/filemon/actions.py +++ b/rattail/filemon/actions.py @@ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import import os import sys import time -import Queue +from six.moves import queue import socket import logging from traceback import format_exception @@ -89,7 +89,7 @@ def perform_actions(profile): try: path = profile.queue.get_nowait() - except Queue.Empty: + except queue.Empty: pass except StopProcessing: stop = True diff --git a/rattail/filemon/config.py b/rattail/filemon/config.py index 474d9fe4e5549ee615c318b90795c15f6463916c..a431b0af60e04b8739e0dcaa7c2d249531217649 100644 --- a/rattail/filemon/config.py +++ b/rattail/filemon/config.py @@ -199,7 +199,7 @@ class Profile(object): action.args = self._config_list(u'action.{0}.args'.format(name)) action.kwargs = {} - pattern = re.compile(ur'^{0}\.action\.{1}\.kwarg\.(?P\w+)$'.format(self.key, name), re.IGNORECASE) + pattern = re.compile(r'^{0}\.action\.{1}\.kwarg\.(?P\w+)$'.format(self.key, name), re.IGNORECASE) for option in self.config.options(u'rattail.filemon'): match = pattern.match(option) if match: diff --git a/rattail/filemon/linux.py b/rattail/filemon/linux.py index 5ee782d91dd17c80e86bc4b8c0bdaf8f05b97efe..ce8acacd3b1b94371cabf83322b5e924a97e1bc7 100644 --- a/rattail/filemon/linux.py +++ b/rattail/filemon/linux.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2017 Lance Edgar +# Copyright © 2010-2018 Lance Edgar # # This file is part of Rattail. # @@ -24,9 +24,9 @@ File Monitor for Linux """ -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import -import Queue +from six.moves import queue import logging import pyinotify @@ -100,7 +100,7 @@ class FileMonitorDaemon(Daemon): for key, profile in monitored.items(): # Create a file queue for the profile. - profile.queue = Queue.Queue() + profile.queue = queue.Queue() # Perform setup for each of the watched folders. for path in profile.dirs: diff --git a/rattail/filemon/win32.py b/rattail/filemon/win32.py index e9fe45225da537f3180e2c65c7524301b73c1f87..b0383772019bd323a9cc604878cd11c9eef0b649 100644 --- a/rattail/filemon/win32.py +++ b/rattail/filemon/win32.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2017 Lance Edgar +# Copyright © 2010-2018 Lance Edgar # # This file is part of Rattail. # @@ -24,12 +24,12 @@ File Monitor for Windows """ -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import import os import time import datetime -import Queue +from six.moves import queue import logging from rattail.win32.service import Service @@ -71,7 +71,7 @@ class RattailFileMonitor(Service): for key, profile in self.monitored.items(): # Create a file queue for the profile. - profile.queue = Queue.Queue() + profile.queue = queue.Queue() # Perform setup for each of the watched folders. for i, path in enumerate(profile.dirs, 1): diff --git a/rattail/sil/writer.py b/rattail/sil/writer.py index 69bb077e1312324d07001a4416be281ee11214fd..a1906ed47ae8826f6251ef8d85479a90806bcc4a 100644 --- a/rattail/sil/writer.py +++ b/rattail/sil/writer.py @@ -51,7 +51,7 @@ class Writer(Object): self.fileobj = self.get_fileobj() def get_fileobj(self): - return open(self.sil_path, 'w') + return open(self.sil_path, 'wb') def close(self): self.fileobj.close() diff --git a/rattail/tests/filemon/test_actions.py b/rattail/tests/filemon/test_actions.py index 905485d3ca4363cd9cec63811bce7ec276f8cdd1..232d2670045f5aff6c968047ea05e939860e1ae5 100644 --- a/rattail/tests/filemon/test_actions.py +++ b/rattail/tests/filemon/test_actions.py @@ -1,10 +1,10 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import import os import time -import Queue +from six.moves import queue from unittest import TestCase from mock import Mock, patch, call @@ -40,7 +40,7 @@ class TestPerformActions(TestCase): profile.stop_on_error = stop_on_error profile.queue = Mock() profile.queue.get_nowait.side_effect = [ - Queue.Empty, # for coverage sake; will be effectively skipped + queue.Empty, # for coverage sake; will be effectively skipped self.tmp.putfile(u'file1', u''), self.tmp.putfile(u'file2', u''), self.tmp.putfile(u'file3', u''), diff --git a/rattail/tests/filemon/test_linux.py b/rattail/tests/filemon/test_linux.py index 7b1aa08b6b3feaa547bc18adb509f8dc249695cb..4b3a578409315b9f9e3992d41eb8f6372a12955d 100644 --- a/rattail/tests/filemon/test_linux.py +++ b/rattail/tests/filemon/test_linux.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import -import Queue +from six.moves import queue from unittest import TestCase from mock import Mock @@ -23,7 +23,7 @@ class TestEventHandler(TestCase): self.config.set(u'rattail.filemon', u'foo.actions', u'noop') self.config.set(u'rattail.filemon', u'foo.action.noop.func', u'rattail.filemon.actions:noop') self.profile = Profile(self.config, u'foo') - self.profile.queue = Queue.Queue() + self.profile.queue = queue.Queue() self.handler = linux.EventHandler() self.handler.my_init(self.profile) diff --git a/rattail/tests/filemon/test_util.py b/rattail/tests/filemon/test_util.py index 50f05f40dacf62f894f16d8ca81d15ac61bb3bcc..ee7e94aec8efcce7afe7e28c47ae620716c4f6e7 100644 --- a/rattail/tests/filemon/test_util.py +++ b/rattail/tests/filemon/test_util.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import -import Queue +from six.moves import queue from unittest import TestCase from fixture import TempIO @@ -22,7 +22,7 @@ class TestQueueExisting(TestCase): self.config.set(u'rattail.filemon', u'foo.actions', u'noop') self.config.set(u'rattail.filemon', u'foo.action.noop.func', u'rattail.filemon.actions:noop') self.profile = Profile(self.config, u'foo') - self.profile.queue = Queue.Queue() + self.profile.queue = queue.Queue() def test_nothing_queued_if_no_files_exist(self): util.queue_existing(self.profile, self.tmp) diff --git a/rattail/vendors/catalogs.py b/rattail/vendors/catalogs.py index 48274164e7f6c2b81f41d2e533a771a38ea19788..48bc43014f778281afb3426c078a29220185ed73 100644 --- a/rattail/vendors/catalogs.py +++ b/rattail/vendors/catalogs.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2017 Lance Edgar +# Copyright © 2010-2018 Lance Edgar # # This file is part of Rattail. # @@ -75,8 +75,11 @@ class CatalogParser(object): return None # No reason to convert integers, really. - if isinstance(value, (Decimal, int, long)): + if isinstance(value, six.integer_types): return value + if isinstance(value, Decimal): + return value + if isinstance(value, float): value = "{{0:0.{0}f}}".format(scale).format(value) else: