-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
""" | ||
|
||
# Copyright (C) 2015 ZetaOps Inc. | ||
# | ||
# This file is licensed under the GNU General Public License v3 | ||
# (GPLv3). See LICENSE.txt for details. | ||
import pika | ||
|
||
|
||
class BaseUser(object): | ||
connection = None | ||
channel = None | ||
|
||
|
||
def _connect_mq(self): | ||
if not self.connection is None or self.connection.is_closed: | ||
self.connection = pika.BlockingConnection(BLOCKING_MQ_PARAMS) | ||
self.channel = selfconnection.channel() | ||
return self.channel | ||
|
||
|
||
def send_message(self, title, message, sender=None, url=None, typ=1): | ||
channel = self._connect_mq() | ||
mq_msg = json.dumps(dict(sender=sender, body=message, msg_title=title, url=url, typ=typ)) | ||
channel.basic_publish(exchange=self.key, body=mq_msg) |
This file contains 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 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 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