def sendNotification(to, service, message):
    db = couchdb_config_parser.get_db()
    doc = {}
    doc['to'] = to
    doc['service'] = service
    doc['status'] = 'pending'
    doc['body'] = message
    doc['collection'] = 'request_notification'
    res = db.save_doc(doc)
    return res
Exemple #2
0
#!/usr/bin/env python

from couchdbkit import *
from Queue import Queue
import threading
from datetime import datetime
import couchdb_config_parser
import subprocess
import change_notification
import os
import add_history
import edit_wifi

db = couchdb_config_parser.get_db()
db_info = db.info()


class WifiListener(threading.Thread):
    def __init__(self, threadName, queue):
        threading.Thread.__init__(self, name=threadName)
        self.shared_object = queue
        self.since = db_info['update_seq']

    def run(self):
        changeStream = ChangesStream(db, feed="continuous", heartbeat=True, since=self.since, filter="homework-remote/wifi")
        for change in changeStream:
            self.shared_object.put(change)


class WifiProcessor(threading.Thread):
    def __init__(self, threadName, queue):
 def __init__(self, threadName, queue):
     threading.Thread.__init__(self, name=threadName)
     self.shared_object = queue
     self.db = couchdb_config_parser.get_db()