-
Notifications
You must be signed in to change notification settings - Fork 141
Misc fixes and cosmetics #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e31e750
We most likely want simplejson first
EvaSDK 2e991ef
Simplify check for string in record formating
EvaSDK 954f823
Use dict.get instead of ternary statement
EvaSDK 35a3d2c
Drop unused imports
EvaSDK 0895338
bytes is a reserved keyword
EvaSDK 405d4dd
Fix more pylint recommendations
EvaSDK ca47ab2
PEP8/misc fixes
EvaSDK 66ea812
Increase conformance to Handler subclassing rules
EvaSDK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 9 additions & 6 deletions
fluent/event.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| from fluent import sender | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import time | ||
|
|
||
| from fluent import sender | ||
|
|
||
|
|
||
| class Event(object): | ||
| def __init__(self, label, data, **kwargs): | ||
| if not isinstance(data, dict) : | ||
| raise Exception("data must be dict") | ||
| s = kwargs['sender'] if ('sender' in kwargs) else sender.get_global_sender() | ||
| timestamp = kwargs['time'] if ('time' in kwargs) else int(time.time()) | ||
| s.emit_with_time(label, timestamp, data) | ||
| assert isinstance(data, dict), 'data must be a dict' | ||
| sender_ = kwargs.get('sender', sender.get_global_sender()) | ||
| timestamp = kwargs.get('time', int(time.time())) | ||
| sender_.emit_with_time(label, timestamp, data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
tests/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from tests.test_event import * | ||
| from tests.test_sender import * | ||
| from tests.test_handler import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
tests/test_event.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,23 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import unittest | ||
| import time | ||
|
|
||
| import fluent | ||
| from fluent import event, sender | ||
|
|
||
|
|
||
| sender.setup(server='localhost', tag='app') | ||
|
|
||
|
|
||
| class TestHandler(unittest.TestCase): | ||
| def testLogging(self): | ||
| # send event with tag app.follow | ||
| event.Event('follow', { | ||
| 'from': 'userA', | ||
| 'to': 'userB' | ||
| 'from': 'userA', | ||
| 'to': 'userB' | ||
| }) | ||
|
|
||
| # send event with tag app.follow, with timestamp | ||
| event.Event('follow', { | ||
| 'from': 'userA', | ||
| 'to': 'userB' | ||
| 'from': 'userA', | ||
| 'to': 'userB' | ||
| }, time=int(0)) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.