Conversation
Use it to test notify_abort.
|
|
||
| def notify(self, to, message, title, smtp_host, smtp_port, smtp_username=None, smtp_password=None, smtp_tls=None, | ||
| smtp_ssl=None, html=None, **kwargs): | ||
| def notify(self, title, message, config): |
There was a problem hiding this comment.
This is how I initially did it, by passing config dict. @paranoidi advised me to pass it a literal params for clarity's sake. I can't say I disagree
There was a problem hiding this comment.
But... it wasn't passing in literal params, it was passing in a config dict, with other stuff added to it, which was being keyword argument expanded. This way we are passing in our actual literal params, which are the ones generated by the notification system, title, message, and the config, as specified and validated by the schema of the plugin, like we do for our other plugin methods. The difference is that these parameters are all the discrete ones that the caller knows about, and doesn't mix in the ones the callee is defining in its own schema.
There was a problem hiding this comment.
@liiight What you had was different, it was a single dict called "data" and contained message and configuration in same dict. This is what I proposed as first ideal solution but there were some challenges with that at the time. This is fine.
flexget/plugins/notifiers/notify.py
Outdated
|
|
||
| title = template_renderer(title) | ||
| except RenderError as e: | ||
| log.error('Error rendering notification title: %s', e) |
There was a problem hiding this comment.
So you got rid of falling back to default in case of render error?
There was a problem hiding this comment.
It falls back to the non rendered jinja string.
There was a problem hiding this comment.
I liked having a fallback dict, but it's no biggie I guess
There was a problem hiding this comment.
I sorta feel like having the unrendered string will be a better indication of error when debugging why their config isn't working rather than getting some string that isn't to do with the title/message they defined.
| '{{ title }}' | ||
| '{% endif %}' | ||
| }, | ||
| 'template': {'type': 'string'}, |
There was a problem hiding this comment.
I used file_templates to differentiate this from template plugin
There was a problem hiding this comment.
Hmm, I guess we do have a couple different kinds of templates, not sure if file_template really helps clarify things much or not though.
There was a problem hiding this comment.
notification template maybe? seems long and too verbose
| return | ||
| # If a file template is defined, it overrides message | ||
| if config.get('template'): | ||
| body = get_template(config['template'], 'entry') |
There was a problem hiding this comment.
Good point. Need to catch that.
|
I was also wondering if 'via' might be more appropriate for the list of notifier outputs than 'to', e.g.: notify_task:
via:
- email:
to: blah@blah.comEliminates the double nested 'to' option in the email case. I think it's a bit more accurate description as well, i.e. the notification is being sent 'via' one of the transport plugins, and 'to' a recipient defined in that transport plugin config. (BTW, maybe need some more consistent terminology to discuss these plugins. What do we call the message generators, (notify_task, notify_abort, etc.,) vs the transport ones, (email, pushbullet, etc.?) similar to the problem of 'list plugins' (list_match, list_add, etc.) vs 'list_plugins' (imdb_list, trakt_list, etc.)) |
|
I like using |
I think the terminology should be the same, and I don't mean necessarily for user facing docs. We have a pattern of defining an api the plugins in a certain group should implement. We then have plugins in that group, and plugins that use plugins in that group. This applies both to the list plugins, and the notification plugins. I just want to figure out what the hell to call things when discussing. 😛 |
|
I'd say making |
|
@liiight I wanted to comment on the "no other output plugins" consideration since I was the one to raise this concern. Although I agree its probably not common, the email plugin used to be just a normal output so there was nothing wrong with this configuration. I raised the concern to address the changes in the behavior resulting from introduction of the notify phase and discuss how to best maintain the previous functionality while still implementing the improvements. As a result of the changes associated with the notify_phase, a task that only has a notification output will no longer retry sending the notification if the notification fails. I think that if the notification is the only output, and the notification fails, it should consider that entry to be failed As an alterantive, I'm not sure if this was considered, but the best way of handling may be to create a notification queue. This way, regardless of the output, any failed notifications could be retried on the next run of the task and would be sent to the user without the program re-downloading |
# Conflicts: # flexget/plugins/notifiers/email.py
|
@gazpachoking notifyosd is a crappy name but it's not original name https://wiki.ubuntu.com/NotifyOSD |
Oh hmm. It works with this too, right? https://wiki.archlinux.org/index.php/Desktop_notifications 'notify osd' seems to be just one implementation for unity. |
|
Speaking of which, should we change it to this https://pypi.python.org/pypi/notify2 , instead of requiring gtk as the dependency? |
|
Yeah, looks better |
|
Sweet, windows osd. Works on 7 and up I suppose? |
Works on 10 at least, (though not optimal integration with the new action center,) not sure how far back it goes, I assume it works fine on 7. |
|
What should we call the osd notifier now that it's a bit more generic? Would 'popup' or 'desktop' or something be more appropriate? |
|
|
|
Hmm,got this crash while testing it: |
|
I'm not so sure anymore about the notify:
task:
via:
- on_screen_display: {}This feels too much to me... |
Very tough to read that traceback. Looks like maybe the gobject introspection doesn't support python 3? I'm thinking of reverting the changes to osd for now and dealing with that in a separate PR. Maybe include the rename, and allow for bool schema, that way we could upgrade it outside of next branch. |
Dunno what there is to be done about that. We could move the via to directly under notify, but that would mean you couldn't configure e.g. aborts to notify via a different method than entries. |
Allow boolean configuration for toast.
Update toast plugin registration to use interfaces # Conflicts: # flexget/plugins/notifiers/notify.py # flexget/plugins/notifiers/notify_osd.py # flexget/plugins/notifiers/sns.py
NOTE:
Everything here is still a draft, mostly untested, and meant for discussion still.Getting mostly up to snuff at this point, though still open for other changes.Motivation for changes:
Further separate the different types of notification generation plugins for simplification, and easier customization of each message type. Simplify the framework to not need advanced knowledge about the context of a message.
Detailed changes:
(title, message, config)with all templates already rendered. title and message will be the message as constructed by one of the notification message generator plugins (notify_abort, notify_task, etc.), and config is the config for the transport plugin (email, prowl, etc.) as specified and validated by its schema (any text fields in the config will have jinja templates rendered against the appropriate context before being passed to transport plugin though)(title, message, outputs, [template_renderer])where outputs is a list of configured notifier output plugins. template_renderer should be a function that renders jinja strings or templates against the appropriate context for the message. It will be applied to title, message, and any string keys in the output plugin configs.notifyphase. Add a way to suppress task aborts from this phase. (Is the way I did this okay? Is there something nicer?)Breaking changes
I've changed some names that I thought made sense, but we could backtrack if they don't seem worth it to break backwards compatibility in places.
notify_entries -> notify_entry ? I feel this has more parity with the singular notify_task, plus it sends a notification per entry like notify_task does per taskThings to finish before merging
notification_frameworkso that the task plugin can be namednotify. Not great, but it's only used from other plugins, not user facing.Consider whether the notification framework should provide 'url' as a default field. There are several notifiers which all support 'url', but it wouldn't be 100%. 'subject' is already included though, and that isn't used 100% either, so url might be just as appropriate.Leaning to 'no' on this.