Skip to content
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

Allow UpdateTitleStats to emit events instead of rewriting the console #3264

Merged
merged 1 commit into from Aug 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pokemongo_bot/cell_workers/update_title_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def __init__(self, bot, config):
self.min_interval = self.DEFAULT_MIN_INTERVAL
self.displayed_stats = self.DEFAULT_DISPLAYED_STATS

self.bot.event_manager.register_event('update_title', parameters=('title'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion to move the task's specific event registration to inside the task itself. I think we should follow this everywhere, @TheSavior.

@MMnsgo feel free to open another PR moving the registration of all events used only inside a task to the task class itself.


self._process_config()

def initialize(self):
Expand Down Expand Up @@ -109,6 +111,15 @@ def _update_title(self, title, platform):
:rtype: None
:raise: RuntimeError: When the given platform isn't supported.
"""

self.emit_event(
'update_title',
formatted="{title}",
data={
'title': title
}
)

if platform == "linux" or platform == "linux2" or platform == "cygwin":
stdout.write("\x1b]2;{}\x07".format(title))
stdout.flush()
Expand Down