def run_zephyr(): zephyr.init() subs = zephyr.Subscriptions() logging.info("Subscribing to: " + ','.join(zephyr_classes.keys())) for c in zephyr_classes.keys(): subs.add((c, '*', '')) while not SHUTDOWN: while True: try: m = from_jabber_q.get(False) except Queue.Empty: break (src, sender, msg) = m if src not in jabber_chats: continue note = zephyr.ZNotice() note.fields = [src, msg] note.sender = sender note.auth = False note.cls = jabber_chats[src] note.instance = '' note.opcode = 'jabber' note.send() note = zephyr.receive(False) if note: body = note.fields[1] if len(note.fields) > 1 else '' logging.debug("ZEPHYR: %s/%s[%s]: %s", note.sender, note.cls, note.opcode, body) if note.opcode.lower() not in ('jabber', 'ping'): from_zephyr_q.put((note.cls, note.sender.split('@')[0], body)) else: select.select([zephyr._z.getFD()], [], [], 1)
def __init__(self, c = "dodona-test"): """ Initializes the python-zephyr utilities. """ self.cls = c # initialize zephyr zephyr.init() # subscribe to the specified cls zephyr.Subscriptions().add((self.cls, '*', '*')) # send an initialization message self.send(custom_fill('Dodona is now running. If you find that a topic you wish answered is not accounted for, please send mail to dodona AT mit DOT edu'))
def main(): zephyr.init() zephyrThread = threading.Thread(target=listen_zephyr) zephyrThread.daemon = True zephyrThread.start() slackThread = threading.Thread(target=listen_slack) slackThread.daemon = True slackThread.start() log('Slack <-> Zephyr started') while True: time.sleep(10000)
def __init__(self, c="dodona-test"): """ Initializes the python-zephyr utilities. """ self.cls = c # initialize zephyr zephyr.init() # subscribe to the specified cls zephyr.Subscriptions().add((self.cls, '*', '*')) # send an initialization message self.send( custom_fill( 'Dodona is now running. If you find that a topic you wish answered is not accounted for, please send mail to dodona AT mit DOT edu' ))
def zephyr_setup(classes, personals=True): zephyr.init() subs = zephyr.Subscriptions() for c in classes: subs.add((c, '*', '*')) if personals: subs.add(('message', '*', '%me%')) else: # The zephyrd's give you personals by default # Unfortunately, the subscriptions object doesn't reflect this # To get rid of them, explicitly *sub* (so the subscription object # knows), and then unsub. default_personals = ('message', 'personal', '%me%') subs.add(default_personals) subs.remove(default_personals)
def main(): zephyr.init() subs = zephyr.Subscriptions() subs.add(('broder-test', '*', '*')) subs.add(('debathena', '*', '*')) subs.add(('undebathena', '*', '*')) while True: zgram = zephyr.receive(True) if not zgram: continue if zgram.opcode.lower() == 'kill': sys.exit(0) messages = [] for tracker, ticket in find_ticket_info(zgram): fetcher = fetchers.get(tracker) if fetcher: if (zgram.opcode.lower() != 'auto' and last_seen.get((tracker, ticket, zgram.cls), 0) < time.time() - seen_timeout): if zgram.cls == 'undebathena': u, t = undebathena_fun() else: u, t = fetcher(ticket) if not t: t = 'Unable to identify ticket %s' % ticket messages.append('%s ticket %s: %s' % (tracker, ticket, t)) last_seen[(tracker, ticket, zgram.cls)] = time.time() if messages: z = zephyr.ZNotice() z.cls = zgram.cls z.instance = zgram.instance z.recipient = zgram.recipient z.opcode = 'auto' z.sender = 'debothena' z.fields = [u, '\n'.join(messages)] z.send()
def __init__(self, name, clss): self.name = name zephyr.init() for cls in clss: for i in range(0,10): zephyr.Subscriptions().add((("un" * i) + cls, '*', '*'))
def zephyr_setup(classes): zephyr.init() subs = zephyr.Subscriptions() for c in classes: subs.add((c, '*', '*')) subs.add(('message', '*', '%me%'))
def init(): getVars() zephyr.init() zephyr.Subscriptions().add(('messages', 'personal', '%me%'))
import os, subprocess, threading # Utility libraries import datetime, time import math import simplejson import sys # Logging and debugging import traceback import email, smtplib # Zephyr Libraries import zephyr import loadZephyrs zephyr.init() # Django Library os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from models import Zephyr, Subscription, Account import django.conf LOGFILE_NAME = django.conf.settings.TORNADO_LOGFILE_NAME class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): #username = self.get_secure_cookie("user", max_age_days=31) username = self.get_secure_cookie("user") if username is not None: account, created = Account.objects.get_or_create(username=username) if created:
# Utility libraries import datetime, time import math import simplejson import sys # Logging and debugging import traceback import email, smtplib # Zephyr Libraries import zephyr import loadZephyrs zephyr.init() # Django Library os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from models import Zephyr, Subscription, Account import django.conf LOGFILE_NAME = django.conf.settings.TORNADO_LOGFILE_NAME class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): #username = self.get_secure_cookie("user", max_age_days=31) username = self.get_secure_cookie("user") if username is not None: account, created = Account.objects.get_or_create(username=username)
def setup(): zephyr.init() subs = zephyr.Subscriptions() subs.add(('message', '*', '%me%')) subs.add(('zscore', '*', '*'))