Changeset - cdbb6d29d98e
[Not reviewed]
0 10 0
Lance Edgar (lance) - 7 years ago 2018-02-15 12:47:20
lance@edbob.org
More tweaks for python 3
10 files changed with 33 insertions and 30 deletions:
0 comments (0 inline, 0 general)
rattail/commands/core.py
Show inline comments
 
@@ -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':
rattail/filemon/actions.py
Show inline comments
 
@@ -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
rattail/filemon/config.py
Show inline comments
 
@@ -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<keyword>\w+)$'.format(self.key, name), re.IGNORECASE)
 
        pattern = re.compile(r'^{0}\.action\.{1}\.kwarg\.(?P<keyword>\w+)$'.format(self.key, name), re.IGNORECASE)
 
        for option in self.config.options(u'rattail.filemon'):
 
            match = pattern.match(option)
 
            if match:
rattail/filemon/linux.py
Show inline comments
 
# -*- 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:
rattail/filemon/win32.py
Show inline comments
 
# -*- 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):
rattail/sil/writer.py
Show inline comments
 
@@ -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()
rattail/tests/filemon/test_actions.py
Show inline comments
 
# -*- 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''),
rattail/tests/filemon/test_linux.py
Show inline comments
 
# -*- 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)
 

	
rattail/tests/filemon/test_util.py
Show inline comments
 
# -*- 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)
rattail/vendors/catalogs.py
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)