diff --git a/.travis.yml b/.travis.yml index cfecf48..c4db70e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,14 @@ language: python -python: 3.4 +dist: precise +python: + - "2.7" + - "3.4" + - "pypy" services: - mysql - redis-server -env: - - TOXENV=flake8 - - TOXENV=py27 - - TOXENV=py33 - - TOXENV=py34 - - TOXENV=pypy before_install: - - pip install tox + - pip install tox==1.9.2 before_script: # enable row-based binlog - sudo touch /etc/mysql/conf.d/replication.cnf diff --git a/examples/repl_db/repl.py b/examples/repl_db/repl.py index 9b9592c..72d3145 100644 --- a/examples/repl_db/repl.py +++ b/examples/repl_db/repl.py @@ -75,7 +75,7 @@ def _update_by_pk(name, pk): for col in columns: try: val = getattr(obj, col) - except AttributeError as e: + except AttributeError: continue setattr(s_obj, col, val) diff --git a/meepo/apps/eventsourcing/event_store.py b/meepo/apps/eventsourcing/event_store.py index 500630f..790549d 100644 --- a/meepo/apps/eventsourcing/event_store.py +++ b/meepo/apps/eventsourcing/event_store.py @@ -121,7 +121,7 @@ class RedisEventStore(EventStore): end """.split()) - def __init__(self, redis_dsn, namespace=None, ttl=3600*24*3, + def __init__(self, redis_dsn, namespace=None, ttl=3600 * 24 * 3, socket_timeout=1, **kwargs): super(RedisEventStore, self).__init__() diff --git a/meepo/apps/eventsourcing/prepare_commit.py b/meepo/apps/eventsourcing/prepare_commit.py index d30954a..fc513b6 100644 --- a/meepo/apps/eventsourcing/prepare_commit.py +++ b/meepo/apps/eventsourcing/prepare_commit.py @@ -85,7 +85,7 @@ class RedisPrepareCommit(PrepareCommit): :param socket_timeout: redis socket timeout :param kwargs: kwargs to be passed to redis instance init func. """ - def __init__(self, redis_dsn, strict=False, namespace=None, ttl=3600*24, + def __init__(self, redis_dsn, strict=False, namespace=None, ttl=3600 * 24, socket_timeout=1, **kwargs): super(RedisPrepareCommit, self).__init__() diff --git a/meepo/apps/eventsourcing/sub.py b/meepo/apps/eventsourcing/sub.py index 34e9350..5010699 100644 --- a/meepo/apps/eventsourcing/sub.py +++ b/meepo/apps/eventsourcing/sub.py @@ -15,7 +15,7 @@ def redis_es_sub(session, tables, redis_dsn, strict=False, - namespace=None, ttl=3600*24*3, socket_timeout=1): + namespace=None, ttl=3600 * 24 * 3, socket_timeout=1): """Redis EventSourcing sub. This sub should be used together with sqlalchemy_es_pub, it will @@ -52,7 +52,7 @@ def _es_event_sub(pk, event): logger.error("event sourcing failed: %s" % pk) events = ("%s_%s" % (tb, action) for tb, action in - itertools.product(*[tables, ["write", "update", "delete"]])) + itertools.product(*[tables, ["write", "update", "delete"]])) for event in events: sub_func = functools.partial(_es_event_sub, event=event) signal(event).connect(sub_func, weak=False) diff --git a/meepo/signals.py b/meepo/signals.py index 1b0b9cd..9c8a402 100644 --- a/meepo/signals.py +++ b/meepo/signals.py @@ -21,6 +21,8 @@ def hashable_identity(obj): import blinker.base blinker.base.hashable_identity = hashable_identity + + _monkey_patch_hashable_func() diff --git a/meepo/sub/statsd.py b/meepo/sub/statsd.py index 5c3065f..bc64d82 100644 --- a/meepo/sub/statsd.py +++ b/meepo/sub/statsd.py @@ -43,7 +43,7 @@ def statsd_sub(statsd_dsn, tables, prefix="meepo.stats", rate=1): itertools.product(*[tables, ["write", "update", "delete"]])) for event in events: signal(event).connect( - lambda _, e=event: c.incr(_key(*e.rsplit('_', 1)), rate=rate), + lambda _, e=event: c.incr(_key(*e.rsplit('_', 1)), rate=rate), weak=False ) diff --git a/meepo/utils.py b/meepo/utils.py index 1a6c5c1..dc08631 100644 --- a/meepo/utils.py +++ b/meepo/utils.py @@ -51,6 +51,8 @@ def cast_bytes(s, encoding='utf8', errors='strict'): return s.encode(encoding, errors) else: raise TypeError("Expected unicode or bytes, got %r" % s) + + b = cast_bytes @@ -62,6 +64,8 @@ def cast_str(s, encoding='utf8', errors='strict'): return s else: raise TypeError("Expected unicode or bytes, got %r" % s) + + s = cast_str @@ -71,4 +75,6 @@ def cast_datetime(ts, fmt=None): if fmt: return dt.strftime(fmt) return dt + + d = cast_datetime diff --git a/setup.py b/setup.py index 80ce894..9ab041d 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ install_requires = [ "SQLAlchemy>=0.9.0,<1.1.0", "blinker>=1.3,<2.0", - "mysql-replication>=0.5,<0.6.0", + "mysql-replication>=0.5", "pyketama>=0.2.0", "pyzmq>=14.3.1,<15.0.0", "redis>=2.10.3,<2.11.0", diff --git a/tests/test_eventsourcing/test_sqlalchemy_es_pub.py b/tests/test_eventsourcing/test_sqlalchemy_es_pub.py index 876d61b..22440cd 100644 --- a/tests/test_eventsourcing/test_sqlalchemy_es_pub.py +++ b/tests/test_eventsourcing/test_sqlalchemy_es_pub.py @@ -199,7 +199,7 @@ def test_sa_mixed_write_update_delete_and_multi_flushes(session, model_cls): 5. commit """ t_b, t_c = session.query(model_cls). \ - filter(model_cls.data.in_(('b', 'c'))).all() + filter(model_cls.data.in_(('b', 'c'))).all() t_e = model_cls(data='e') session.add(t_e) t_b.data = "x" diff --git a/tests/test_mysql_pub.py b/tests/test_mysql_pub.py index d80ca42..14f735b 100644 --- a/tests/test_mysql_pub.py +++ b/tests/test_mysql_pub.py @@ -31,7 +31,7 @@ def test_sg(sg_list): signal("test_delete_raw").connect(test_sg(t_raw_deletes), weak=False) # connect mysql binlog pos signal - signal("mysql_binlog_pos").connect(test_sg(t_binlogs), weak=False) + signal("mysql_binlog_pos").connect(test_sg(t_binlogs), weak=False) @pytest.fixture(scope="module") diff --git a/tests/test_sqlalchemy_pub.py b/tests/test_sqlalchemy_pub.py index f4b5be0..f3ce97f 100644 --- a/tests/test_sqlalchemy_pub.py +++ b/tests/test_sqlalchemy_pub.py @@ -140,7 +140,7 @@ def test_sa_mixed_write_update_delete_and_multi_flushes(session, model_cls): 5. commit """ t_b, t_c = session.query(model_cls).\ - filter(model_cls.data.in_(('b', 'c'))).all() + filter(model_cls.data.in_(('b', 'c'))).all() t_e = model_cls(data='e') session.add(t_e) t_b.data = "x" diff --git a/tox.ini b/tox.ini index e2b5725..5f5d628 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,15 @@ -[tox] -envlist = flake8, py27, py33, py34, pypy - [testenv] -basepython = - py27: python2.7 - py33: python3.3 - py34: python3.4 - pypy: pypy deps = mysql-replication>=0.5 - pytest>=2.6.4 + pytest>=2.6.4,<3.0.0 redis>=2.10.3 teamcity-messages>=1.8 + PyMySQL>0.7.0,<0.8.0 + flake8>=2.2.5 commands = python --version + flake8 . py.test {posargs} -[testenv:flake8] -basepython = python -deps = - flake8 >=2.2.5 -commands = - flake8 . +[flake8] +ignore = E402, E731 \ No newline at end of file