toxicnotifications package¶
Submodules¶
toxicnotifications.base module¶
- class toxicnotifications.base.MetaNotification(name, bases, attrs)[source]¶
Bases:
PluginMeta,TopLevelDocumentMetaclassMetaclass that sets name to the class definition as mongo fields while keeping the interface of setting your notification’s name as string in definition time.
- class toxicnotifications.base.Notification(*args, **kwargs)[source]¶
Bases:
LoggerMixin,Plugin,DocumentBase class for notifications. It creates 3 fields:
repository_id: The id of the repository that sends notifications.branches: A list of branches that may send notifications. If no branch, all branches may send messages.statuses: A list of statuses that may send notifications. If no status, all statuses may send notifications.
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- branches¶
- description = 'Base for notifications'¶
- events = ['buildset-started', 'buildset-finished']¶
- classmethod get_repo_notifications(repository_id, event=None)[source]¶
Returns a queryset with the notifications for a given repository and event.
- Parameters:
repository_id – The id of the repository that sent an event.
event – The event that will trigger notifications.
- classmethod get_schema(to_serialize=False)[source]¶
Returns a dictionary with the schema of the plugin.
- id¶
A field wrapper around MongoDB’s ObjectIds.
- name = 'BaseNotification'¶
- no_list = False¶
- objects¶
The default QuerySet Manager.
Custom QuerySet Manager functions can extend this class and users can add extra queryset functionality. Any custom manager methods must accept a
Documentclass as its first argument, and aQuerySetas its second argument.The method function should return a
QuerySet, probably the same one that was passed in, but modified in some way.
- pretty_name = ''¶
- repository_id¶
A field wrapper around MongoDB’s ObjectIds.
- async run(buildset_info)[source]¶
Executed when a notification about a build arrives. Reacts to buildsets that started or finished.
- Parameters:
buildset_info – A dictionary with information about a buildset.
- async send_finished_message(buildset_info)[source]¶
Sends a message when a buildset is finished. You must override it.
- async send_started_message(buildset_info)[source]¶
Sends a message when a buildset is started. You must override it.
- statuses¶
toxicnotifications.cmds module¶
- class toxicnotifications.cmds.SettingsPatcher[source]¶
Bases:
MonkeyPatcherPatches the settings from pyrocumulus to use the same settings as toxibuild.
- toxicnotifications.cmds.create(root_dir)[source]¶
Creates a new toxicnotifications environment.
- Parameters:
--root_dir – Root directory for toxicnotifications.
- toxicnotifications.cmds.create_token(workdir, conffile=None)[source]¶
Creates an access token for the notifications api.
- Parameters:
workdir – Work directory for server.
--conffile (-c,) – path to config file. Defaults to None. If not conffile, will look for a file called
toxicnotifications.confinsideworkdir.
- toxicnotifications.cmds.notifications_init(addr, port, use_ssl, certfile, keyfile, loglevel)[source]¶
- toxicnotifications.cmds.restart(workdir, pidfile='toxicnotifications.pid', loglevel='info')[source]¶
Restarts toxicnotifications
The instance of toxicnotifications in
workdirwill be restarted. :param workdir: Workdir for instance to be killed. :param –pidfile: Name of the file to use as pidfile. :param –loglevel: Level for logging messages.
- toxicnotifications.cmds.start(workdir, daemonize=False, stdout='./toxicnotifications.log', stderr='./toxicnotifications.log', conffile=None, loglevel='info', pidfile='toxicnotifications.pid')[source]¶
Starts toxicnotifications.
- Parameters:
workdir – Work directory for server.
--daemonize – Run as daemon. Defaults to False
--stdout – stdout path. Defaults to /dev/null
--stderr – stderr path. Defaults to /dev/null
--conffile (-c,) – path to config file. Defaults to None. If not conffile, will look for a file called
toxicnotifications.confinsideworkdir--loglevel – Level for logging messages. Defaults to info.
--pidfile – Name of the file to use as pidfile. Defaults to
toxicnotifications.pid
toxicnotifications.custom_webhook module¶
- class toxicnotifications.custom_webhook.CustomWebhookNotification(*args, **kwargs)[source]¶
Bases:
NotificationSends a POST request to a custom URL. The request content type is application/json and the body of the request has a json with information about a buildset.
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- description = 'Sends messages to a custom webhook.'¶
- name = 'custom-webhook'¶
- no_list = False¶
- pretty_name = 'Custom Webhook'¶
- async send_finished_message(buildset_info)[source]¶
Sends a message when a buildset is finished. You must override it.
- async send_started_message(buildset_info)[source]¶
Sends a message when a buildset is started. You must override it.
- webhook_url¶
toxicnotifications.fields module¶
- class toxicnotifications.fields.PrettyFieldMixin(*args, **kwargs)[source]¶
Bases:
objectA field with a descriptive name for humans
- class toxicnotifications.fields.PrettyListField(*args, **kwargs)[source]¶
Bases:
PrettyFieldMixin,ListField
- class toxicnotifications.fields.PrettyStringField(*args, **kwargs)[source]¶
Bases:
PrettyFieldMixin,StringField
- class toxicnotifications.fields.PrettyURLField(*args, **kwargs)[source]¶
Bases:
PrettyFieldMixin,URLField
toxicnotifications.mail module¶
- class toxicnotifications.mail.EmailNotification(*args, **kwargs)[source]¶
Bases:
NotificationSends notification about buildsets through email
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- description = 'Sends email messages'¶
- name = 'email-notification'¶
- no_list = False¶
- pretty_name = 'Email'¶
- recipients¶
toxicnotifications.server module¶
- class toxicnotifications.server.NotificationsProtocol(loop, connection_lost_cb=None)[source]¶
Bases:
BaseToxicProtocol- actions = {'disable-notification', 'enable-notification', 'list-notifications', 'send-email', 'update-notification'}¶
- async client_connected()[source]¶
Coroutine that handles connections. You must implement this in your sub-classes. When this method is called,
self.data, containing a dictionary with the data passed in the request andself.action, a string indicating which action to take are already available.
- property encrypted_token¶
The type of the None singleton.
- class toxicnotifications.server.NotificationsServer(*args, **kwargs)[source]¶
Bases:
ToxicServer- PROTOCOL_CLS¶
alias of
NotificationsProtocol
- class toxicnotifications.server.OutputMessageHandler(loop=None)[source]¶
Bases:
LoggerMixinFetchs messages from notification queues and dispatches the needed output methods.
- EXCHANGE = <toxiccommon.exchange.Exchange object>¶
toxicnotifications.slack module¶
- class toxicnotifications.slack.SlackNotification(*args, **kwargs)[source]¶
Bases:
NotificationPlugin that send notifications about builds to slack.
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- channel_name¶
- description = 'Sends messages to a slack channel'¶
- name = 'slack-notification'¶
- no_list = False¶
- pretty_name = 'Slack'¶
- async send_finished_message(buildset_info)[source]¶
Sends a message when a buildset is finished. You must override it.
- async send_started_message(buildset_info)[source]¶
Sends a message when a buildset is started. You must override it.
- webhook_url¶