Пример #1
0
 def setUp(self):
     self.test_poll = Poller()
     self.test_poll._candidates = [
         Candidate("candidate1"),
         Candidate("candidate2")
     ]
     self.test_poll._miscast = deepcopy(self.test_poll._candidates)
Пример #2
0
 def Run(self):
     logger = logging.getLogger()
     logger.info("PullClient starting...")
     self.poller = Poller(self.pollerStop)
     self.poller.start()
     logger.info("PullClient started.")
     self.stopEvent.Wait()
Пример #3
0
 def run(self):
     if self.args.debug:
         logging.basicConfig(level=logging.DEBUG)
     else:
         logging.basicConfig(level=logging.WARN)
     p = Poller(self.args)
     p.run()
Пример #4
0
    def __init__(self, token, vk_client_id):
        self.poller = Poller()
        self.updater = Updater(token=token)
        self.vk = Vk(vk_client_id)
        self.clients = Client.all_from_db()

        self.reg_actions()
        self.restore()
Пример #5
0
 def __init__(self):
     self.p = Poller()
     self.fd = None
     self.base_timeout = 10
     self.timeout = 10
     self.disable()
     self.disable_timeout()
     self.sensores = None
     self.placa = None
Пример #6
0
 def __init__(self, ip_port):
     listener = socket.socket()
     listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
     listener.bind(ip_port)
     listener.listen(NEW_CLIENTS)
     self.listener = listener
     poller = Poller()
     poller.add(listener)
     self.poller = poller
Пример #7
0
    def butcmdacquire(self):
        """
        Acquire check button command to manage the acquisition thread to read the DSP data.
        If the button is not selected the thread is lunched.
        If the button is selected the thread is stopped.

        """
        if self.ivaracquire.get():
            if not self.isconnected():
                self.ivaracquire.set(0)
                return
            self.scope.resetpoints()
            self.strtme = time()
            self.poller = Poller(self.ivaracquire, self.dvarsecsmp,
                                 self.updatefields)
        else:
            self.poller.wake()
Пример #8
0
 def run(self):
     p = Poller(self.args.port)
     p.unimplementedMethods = ['HEAD','PUT','POST','DELETE','LINK','UNLINK']
     p.hosts = dict()
     p.media_types = dict()
     p.timeout = 0
     with open('web.conf', 'r') as f:
         for line in f:
             if not line in ['\n','\r\n']:
                 words = line.split()
                 if words[0] == 'host':
                     p.hosts[words[1]] = words[2]
                 if words[0] == 'media':
                     p.media_types[words[1]] = words[2]
                 if words[0] == 'parameter':
                     if words[1] == 'timeout':
                         p.timeout = int(words[2])
     p.run()
Пример #9
0
 def run(self, debug=False):
     
     #
     # load up the poller
     #
     poller = Poller()
     
     
     #
     # using sched here since I think its thread safer then a lame while loop
     # with a sleep.
     #
     s = sched.scheduler(time.time, time.sleep)
     poller.runChecks(s, True)
     
     try:
         s.run()
     except (KeyboardInterrupt, SystemExit):
         poller.shutdown()
Пример #10
0
def do_poll():
    """ Create a poll of candidates, and a menu screen to allow a user to view
        the poll or add a vote
    """

    # Some intial setup to get a MVP, will do this dynamically later
    candidates = [
        "Candidate 1", "Candidate 2", "Candidate 3", "Candidate 4",
        "Candidate 5"
    ]

    poll = Poller()

    # Generate our list of candidates
    for candidate in candidates:
        poll.add_candidate(candidate)

    menu = OrderedDict([])
    menu['P/p'] = "Print current poll status"
    menu['V/v'] = "Vote"
    menu['A/a'] = "Auto vote with x votes"
    menu['Q/q'] = "Quit"
    while True:
        print "\nMain Menu"
        print "-----------------------------"
        options = menu.keys()
        for entry in options:
            print entry, menu[entry]

        selection = raw_input("Selection:").lower()
        if selection == 'p':
            start = timer()
            print(poll)
            stop = timer()
            print "\nPoll displayed in %.2f seconds" % (stop - start)
        elif selection == 'v':
            manual_vote(poll)
        elif selection == 'a':
            auto_vote(poll)
        elif selection == 'q':
            quit()
        else:
            print "\nUnknown Option Selected - please try again"
Пример #11
0
    def setUp(self):
        context = zmq.Context()
        worker_socket = context.socket(zmq.REP)
        worker_socket.bind("ipc:///tmp/worker")
        frontend_socket = context.socket(zmq.REP)
        frontend_socket.bind("ipc:///tmp/frontend")

        sockets = {
            "worker": {
                "socket": worker_socket,
                "receive": worker_socket.recv_json,
                "send": worker_socket.send_json
            },
            "frontend": {
                "socket": frontend_socket,
                "receive": frontend_socket.recv_json,
                "send": worker_socket.send_json
            },
        }
        time = TimeStub()

        self.poller = Poller(sockets, time)
Пример #12
0
 def run(self):
     p = Poller(self.args.port, self.conf)
     p.run()
Пример #13
0
from poller import Poller
from app import App
from client import CoapClient

UDP_IP = "localhost"
UDP_PORT = 5683
PATH = "ptc"

if __name__ == '__main__':
    poller = Poller()
    app = App(placa="placaA", sensores=["sensorA", "sensorB"])
    coap = CoapClient(UDP_IP, UDP_PORT, PATH)

    app._lower = coap
    coap._upper = app

    poller.adiciona(app)
    poller.adiciona(coap)

    poller.despache()
Пример #14
0
 def run(self):
     p = Poller(self.args.port)  #so now my
     p.run()
Пример #15
0
                   action=EnvDefault,
                   envvar="SLACK_WEBHOOK_URL",
                   type=str,
                   default=None,
                   required=False,
                   help="Slack webhook URL for sending scaling alerts")
    p.add_argument("--slack-channel",
                   dest="slack_channel",
                   action=EnvDefault,
                   envvar="SLACK_CHANNEL",
                   type=str,
                   default='#deploy',
                   required=False,
                   help="Slack channel to scaling alerts")
    return p.parse_args()


def add_args_to_settings(cli_args):
    for name, value in vars(cli_args).iteritems():
        setattr(settings, name, value)


if __name__ == "__main__":
    args = parse_cli_args()
    add_args_to_settings(args)
    setup_logging(args)
    logging.info(args)
    poller = Poller(args)
    poller.start()
    sys.exit(0)
Пример #16
0
    def __init__(self):
        self._influx = None
        self._poller = Poller()

        self._database_name = DEFAULT_DATABASE
        self._num_polling_threads = DEFAULT_NUM_POLLING_THREADS
Пример #17
0
#! /usr/bin/env python

from config import Config  # this is a subdir
from listener import Listener
from poller import Poller
import sys

if __name__ == "__main__":
    """Run the monitor. The listener class waits for requests. The
    poller class polls the PIDs that were input and forwards output
    to the output class."""
    parpid = sys.argv[1]
    cfg = Config()
    cfg.add_item('parentpid', parpid)
    lst = Listener(cfg)
    lst.start()
    print "listener started"
    # Where is the output class?

    pol = Poller(cfg)
    pol.start()
    print "Poller started"
 def run(self):
     p = Poller(self.args.port)
     p.run()
Пример #19
0
def handler(name, hostname, username, password, timeout, port):
    _poller = Poller(name, hostname, username, password, timeout, port)
    if _poller.open():
        thread = Thread(target= _poller.read)
    else: