Skip to content

Commit 54407a9

Browse files
committed
Merge branch 'release/0.8.3'
2 parents 4550310 + 47659e6 commit 54407a9

22 files changed

+71
-262
lines changed

CHANGES.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 0.8.3 (2019-06-28)
2+
--------------------------
3+
Fix test_bytelimit test (#227)
4+
Initialize Celery in CeleryEmitter (#226)
5+
Allow non ascii characters to be encoded using Base64 (#194)
6+
Allow empty strings in string_or_none contract (#184)
7+
Fix on_failure param docstring description (#225)
8+
Bump max version requirement of redis (#223)
9+
Remove Vagrant & Ansible (#222)
10+
111
Version 0.8.2 (2018-12-01)
212
--------------------------
313
Fix date for 0.8.0 release in CHANGELOG (#183)

README.rst

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
======================================================
22
Python Analytics for Snowplow
33
======================================================
4-
.. image:: https://travis-ci.org/snowplow/snowplow-python-tracker.png?branch=master
4+
.. image:: https://travis-ci.org/snowplow/snowplow-python-tracker.svg?branch=master
55
:alt: Build Status
66
:target: https://travis-ci.org/snowplow/snowplow-python-tracker
7-
.. image:: https://badge.fury.io/py/snowplow-tracker.png
7+
.. image:: https://badge.fury.io/py/snowplow-tracker.svg
88
:target: http://badge.fury.io/py/snowplow-tracker
9-
.. image:: https://coveralls.io/repos/snowplow/snowplow-python-tracker/badge.png
10-
:target: https://coveralls.io/r/snowplow/snowplow-python-tracker
9+
.. image:: https://coveralls.io/repos/github/snowplow/snowplow-python-tracker/badge.svg?branch=master
10+
:target: https://coveralls.io/github/snowplow/snowplow-python-tracker?branch=master
1111
.. image:: http://img.shields.io/badge/license-Apache--2-blue.svg?style=flat
1212
:target: http://www.apache.org/licenses/LICENSE-2.0
1313

@@ -46,33 +46,25 @@ Find out more
4646
.. _`Roadmap`: https://github.com/snowplow/snowplow/wiki/Python-Tracker-Roadmap
4747
.. _`Contributing`: https://github.com/snowplow/snowplow/wiki/Python-Tracker-Contributing
4848

49-
Contributing quickstart
49+
Quickstart
5050
#######################
5151

52-
Assuming Git, Vagrant_ and VirtualBox_ are installed:
52+
Assuming pyenv_ is installed
5353

5454
::
5555

5656
host$ git clone [email protected]:snowplow/snowplow-python-tracker.git
57-
host$ vagrant up && vagrant ssh
58-
guest$ cd /vagrant
59-
guest$ ./run-tests.sh deploy
60-
guest$ ./run-tests.sh test
57+
host$ cd snowplow-python-tracker
58+
host$ pyenv install 2.7.15 && pyenv install 3.4.9 && pyenv install 3.5.2 && pyenv install 3.7.1
59+
host$ ./run-tests.sh deploy
60+
host$ ./run-tests.sh test
6161

62-
.. _Vagrant: http://docs.vagrantup.com/v2/installation/index.html
63-
.. _VirtualBox: https://www.virtualbox.org/wiki/Downloads
64-
65-
Publishing
66-
##########
67-
68-
::
69-
70-
host$ vagrant push
62+
.. _pyenv: https://github.com/pyenv/pyenv
7163

7264
Copyright and license
7365
#####################
7466

75-
The Snowplow Python Tracker is copyright 2013-2014 Snowplow Analytics Ltd.
67+
The Snowplow Python Tracker is copyright 2013-2019 Snowplow Analytics Ltd.
7668

7769
Licensed under the `Apache License, Version 2.0`_ (the "License");
7870
you may not use this software except in compliance with the License.

Vagrantfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
setup.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,7 +15,7 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2014 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

@@ -80,7 +80,7 @@
8080
"pycontracts>=1.7.6,<2.0",
8181
"celery>=4.0,<5.0",
8282
"gevent>=1.0.2,<2.0",
83-
"redis>=2.9.1,<3.0",
83+
"redis>=2.9.1,<4.0",
8484
"six>=1.9.0,<2.0"
8585
],
8686
)

snowplow_tracker/_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
_version.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,11 +15,11 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2016 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

2222

23-
__version_info__ = (0, 8, 2)
23+
__version_info__ = (0, 8, 3)
2424
__version__ = ".".join(str(x) for x in __version_info__)
2525
__build_version__ = __version__ + ''

snowplow_tracker/emitters.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
emitters.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,7 +15,7 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2014 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

@@ -51,16 +51,6 @@
5151

5252
new_contract("redis", lambda x: isinstance(x, (redis.Redis, redis.StrictRedis)))
5353

54-
try:
55-
# Check whether a custom Celery configuration module named "snowplow_celery_config" exists
56-
import snowplow_celery_config
57-
app = Celery()
58-
app.config_from_object(snowplow_celery_config)
59-
except ImportError:
60-
# Otherwise configure Celery with default settings
61-
snowplow_celery_config = None
62-
app = Celery("Snowplow", broker="redis://guest@localhost//")
63-
6454

6555
class Emitter(object):
6656
"""
@@ -84,7 +74,7 @@ def __init__(self, endpoint, protocol="http", port=None, method="get", buffer_si
8474
:param on_success: Callback executed after every HTTP request in a flush has status code 200
8575
Gets passed the number of events flushed.
8676
:type on_success: function | None
87-
:param on_failure: Callback executed if at least one HTTP request in a flush has status code 200
77+
:param on_failure: Callback executed if at least one HTTP request in a flush has status code other than 200
8878
Gets passed two arguments:
8979
1) The number of events which were successfully sent
9080
2) If method is "post": The unsent data in string form;
@@ -342,7 +332,7 @@ def __init__(
342332
:param on_success: Callback executed after every HTTP request in a flush has status code 200
343333
Gets passed the number of events flushed.
344334
:type on_success: function | None
345-
:param on_failure: Callback executed if at least one HTTP request in a flush has status code 200
335+
:param on_failure: Callback executed if at least one HTTP request in a flush has status code other than 200
346336
Gets passed two arguments:
347337
1) The number of events which were successfully sent
348338
2) If method is "post": The unsent data in string form;
@@ -385,30 +375,38 @@ def consume(self):
385375
self.queue.task_done()
386376

387377

388-
@app.task(bind=True, name='tasks.flush') # the self passed with bind can be used for on_fail/retrying
389-
def flush_emitter(self, emitter):
390-
try:
391-
emitter.flush()
392-
finally:
393-
logger.info("Flush called on emitter")
394-
395-
396378
class CeleryEmitter(Emitter):
397379
"""
398380
Uses a Celery worker to send HTTP requests asynchronously.
399381
Works like the base Emitter class,
400382
but on_success and on_failure callbacks cannot be set.
401383
"""
384+
celery_app = None
385+
402386
def __init__(self, endpoint, protocol="http", port=None, method="get", buffer_size=None, byte_limit=None):
403387
super(CeleryEmitter, self).__init__(endpoint, protocol, port, method, buffer_size, None, None, byte_limit)
404388

389+
try:
390+
# Check whether a custom Celery configuration module named "snowplow_celery_config" exists
391+
import snowplow_celery_config
392+
self.celery_app = Celery()
393+
self.celery_app.config_from_object(snowplow_celery_config)
394+
except ImportError:
395+
# Otherwise configure Celery with default settings
396+
self.celery_app = Celery("Snowplow", broker="redis://guest@localhost//")
397+
398+
self.async_flush = self.celery_app.task(self.async_flush)
399+
405400
def flush(self):
406401
"""
407402
Schedules a flush task
408403
"""
409-
flush_emitter.delay(self) # passes emitter (self - CeleryEmitter) to task
404+
self.async_flush.delay()
410405
logger.info("Scheduled a Celery task to flush the event queue")
411406

407+
def async_flush(self):
408+
super(CeleryEmitter, self).flush()
409+
412410

413411
class RedisEmitter(object):
414412
"""

snowplow_tracker/payload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
payload.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,7 +15,7 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2014 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

@@ -82,7 +82,7 @@ def add_json(self, dict_, encode_base64, type_when_encoded, type_when_not_encode
8282
json_dict = json.dumps(dict_, ensure_ascii=False)
8383

8484
if encode_base64:
85-
encoded_dict = base64.urlsafe_b64encode(json_dict.encode("ascii"))
85+
encoded_dict = base64.urlsafe_b64encode(json_dict.encode("utf-8"))
8686
if not isinstance(encoded_dict, str):
8787
encoded_dict = encoded_dict.decode("utf-8")
8888
self.add(type_when_encoded, encoded_dict)

snowplow_tracker/redis_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
redis_worker.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,7 +15,7 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2014 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

snowplow_tracker/self_describing_json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
self_describing_json.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,7 +15,7 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2014 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

snowplow_tracker/subject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
subject.py
33
4-
Copyright (c) 2013-2014 Snowplow Analytics Ltd. All rights reserved.
4+
Copyright (c) 2013-2019 Snowplow Analytics Ltd. All rights reserved.
55
66
This program is licensed to you under the Apache License Version 2.0,
77
and you may not use this file except in compliance with the Apache License
@@ -15,7 +15,7 @@
1515
language governing permissions and limitations there under.
1616
1717
Authors: Anuj More, Alex Dean, Fred Blundun
18-
Copyright: Copyright (c) 2013-2014 Snowplow Analytics Ltd
18+
Copyright: Copyright (c) 2013-2019 Snowplow Analytics Ltd
1919
License: Apache License Version 2.0
2020
"""
2121

0 commit comments

Comments
 (0)