Beispiel #1
0
def main(argv):
    url = argv[1]
    test(url)
    while 1:
        asyncore.poll(scheduler.timeout())
        # print "\n\n asyncore.poll \n"
        scheduler.run()
Beispiel #2
0
def main(argv):
    url = argv[1]
    test(url)
    while 1:
        asyncore.poll(scheduler.timeout())
        # print "\n\n asyncore.poll \n"
        scheduler.run()
Beispiel #3
0
def main(argv):
    server_url = argv[1]
    topic = "/what/chat"
    if len(argv) > 2:
        topic = argv[2]
    chat_client = chat(server_url, topic)
    while chat_client.running:
        asyncore.poll(scheduler.timeout())
        scheduler.run()
Beispiel #4
0
def main(argv):
    server_url = argv[1]
    topic = "/what/chat"
    if len(argv) > 2:
        topic = argv[2]
    chat_client = chat(server_url, topic)
    while chat_client.running:
        asyncore.poll(scheduler.timeout())
        scheduler.run()
Beispiel #5
0
def set_OSNR(osa, voa, osnr, wavelength=None):
    """
    Adjust a noise source controlled through the VOA until the OSA measures the target OSNR.
    """
    osnr = float(instruments.get_quantity(osnr, "dB"))

    if wavelength is not None:
        osa.center = wavelength
        voa.wavelength = wavelength
    voa.attenuation = "0.0 dB"
    return scheduler.timeout(_find_osnr, (osa, voa, osnr), timeout=600)
Beispiel #6
0
def main(argv):
    server_url = argv[1]
    if len(argv) > 2:
        topic = argv[2]
    if len(argv) > 3:
        payload_size = argv[3]
    if len(argv) > 4:
        expires = argv[4]
    publisher = publish_payload(server_url, topic, payload_size, expires)
    while publisher.running:
        asyncore.poll(scheduler.timeout())
        scheduler.run()
Beispiel #7
0
def main(argv):
    server_url = "http://www.mod-pubsub.org:9000/kn"
    if len(argv) > 1:
        server_url = argv[1]
    topic = "/what/apps/blogchatter/pings"
    if len(argv) > 2:
        topic = argv[2]
    do_max_n = "10"
    if len(argv) > 3:
        do_max_n = argv[3]
    sub(server_url, topic, do_max_n)
    while 1:
        asyncore.poll(scheduler.timeout())
        scheduler.run()
Beispiel #8
0
def main(argv):

    print "Starting SiteWatch Sensor."

    w = wakeup.Wakeup()

    if len(argv) < 2:
        print "Usage: ./sitewatch_sensor.py server_url"
        return -1
    else:
        server_url = argv[1]
    """Note: replace these sample sites with sites you want to watch."""

    hbeat = Heartbeat(server_url, "/what/sitewatch/1", "sales.knownow.com")
    Monitor(hbeat, "http://sales.knownow.com/kn?do_method=noop")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/2", "showcase.knownow.com")
    Monitor(hbeat, "http://showcase.knownow.com:8000/kn?do_method=noop")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/3", "knrouter.knownow.com")
    Monitor(hbeat, "http://knrouter.developer.knownow.com/kn?do_method=noop")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/4", "www.knownow.com")
    Monitor(hbeat, "http://www.knownow.com/")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/5", "developer.knownow.com")
    Monitor(hbeat, "http://developer.knownow.com/")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/6",
                      "cvs.developer.knownow.com")
    Monitor(hbeat, "http://cvs.developer.knownow.com/index.cgi/")()
    hbeat()

    while 1:
        asyncore.poll(scheduler.timeout())
        # print "\n\n asyncore.poll \n"
        scheduler.run()
Beispiel #9
0
def main(argv):

    print "Starting SiteWatch Sensor."
 
    w = wakeup.Wakeup()

    if len(argv) < 2:
        print "Usage: ./sitewatch_sensor.py server_url"
        return -1
    else:
        server_url = argv[1]

    """Note: replace these sample sites with sites you want to watch."""
    
    hbeat = Heartbeat(server_url, "/what/sitewatch/1", "sales.knownow.com")
    Monitor(hbeat, "http://sales.knownow.com/kn?do_method=noop")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/2", "showcase.knownow.com")
    Monitor(hbeat, "http://showcase.knownow.com:8000/kn?do_method=noop")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/3", "knrouter.knownow.com")
    Monitor(hbeat, "http://knrouter.developer.knownow.com/kn?do_method=noop")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/4", "www.knownow.com")
    Monitor(hbeat, "http://www.knownow.com/")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/5", "developer.knownow.com")
    Monitor(hbeat, "http://developer.knownow.com/")()
    hbeat()

    hbeat = Heartbeat(server_url, "/what/sitewatch/6", "cvs.developer.knownow.com")
    Monitor(hbeat, "http://cvs.developer.knownow.com/index.cgi/")()
    hbeat()

    while 1:
        asyncore.poll(scheduler.timeout())
        # print "\n\n asyncore.poll \n"
        scheduler.run()
Beispiel #10
0
def main(argv):

    bridge = 0
    recursive = 0
    verbose = 0
    repeat_style = "do_max_n"
    repeat_value = "10"

    optlist, argv[1:] = getopt.getopt(argv[1:], "hbrv",
                                      ["help", "bridge", "recursive", "max-n=", "max-age=", "verbose"])
    for opt, val in optlist:
        if opt in ('-h', '--help'):
            print (
                "Usage: %s [ options ... ] from-server to-server topic [ topic ... ]\n"
                % (argv[0]) + "\n"
                "  -h, --help          print this message and exit\n"
                "  -b, --bridge        repeat from to-server to from-server also\n"
                "  -r, --recursive     recursively repeat non-\"kn_\" subtopics\n"
                "  -v, --verbose       write diagnostics to stderr (repeat to increase verbosity)\n"
                "  --max-n=N           try to replay the last N previous events on startup\n"
                "  --max-age=AGE       try to replay the last AGE seconds on startup\n"
                "  --max-age=\"infinity\"  try to replay all old events on startup\n"
                "\n"
                "Default is to try to replay the most recent 10 events from each topic on from-server\n"
                "into the corresponding topic on to-server.\n"
                )
            return
        elif opt in ('-b', '--bridge'):
            bridge = 1
        elif opt in ('-r', '--recursive'):
            recursive = 1
        elif opt in ('-v', '--verbose'):
            verbose += 1
        elif opt in ('--max-n'):
            repeat_style = "do_max_n"
            repeat_value = val
        elif opt in ('--max-age'):
            repeat_style = "do_max_age"
            repeat_value = val

    try:
        topic = argv[3]
    except:    
        sys.stderr.write(
            "Usage: %s [ --help ] [ options ... ] from-server to-server topic [ topic ... ]\n"
            % argv[0]
            )
        sys.stderr.flush()
        sys.exit(1)
        
    client1_url = argv[1]
    client2_url = argv[2]
    
    ua = pubsublib.HTTPUserAgent()
    client1 = pubsublib.SimpleClient(ua, client1_url)
    client2 = pubsublib.SimpleClient(ua, client2_url)
    for topic in argv[3:]:
        Repeater(verbose, recursive, client1, client2, topic, { repeat_style: repeat_value })
        if bridge:
            Repeater(verbose, recursive, client2, client1, topic, { repeat_style: repeat_value })

    while 1:
        asyncore.poll(scheduler.timeout())
        scheduler.run()
Beispiel #11
0
def main(argv):

    bridge = 0
    recursive = 0
    verbose = 0
    repeat_style = "do_max_n"
    repeat_value = "10"

    optlist, argv[1:] = getopt.getopt(
        argv[1:], "hbrv",
        ["help", "bridge", "recursive", "max-n=", "max-age=", "verbose"])
    for opt, val in optlist:
        if opt in ('-h', '--help'):
            print(
                "Usage: %s [ options ... ] from-server to-server topic [ topic ... ]\n"
                % (argv[0]) + "\n"
                "  -h, --help          print this message and exit\n"
                "  -b, --bridge        repeat from to-server to from-server also\n"
                "  -r, --recursive     recursively repeat non-\"kn_\" subtopics\n"
                "  -v, --verbose       write diagnostics to stderr (repeat to increase verbosity)\n"
                "  --max-n=N           try to replay the last N previous events on startup\n"
                "  --max-age=AGE       try to replay the last AGE seconds on startup\n"
                "  --max-age=\"infinity\"  try to replay all old events on startup\n"
                "\n"
                "Default is to try to replay the most recent 10 events from each topic on from-server\n"
                "into the corresponding topic on to-server.\n")
            return
        elif opt in ('-b', '--bridge'):
            bridge = 1
        elif opt in ('-r', '--recursive'):
            recursive = 1
        elif opt in ('-v', '--verbose'):
            verbose += 1
        elif opt in ('--max-n'):
            repeat_style = "do_max_n"
            repeat_value = val
        elif opt in ('--max-age'):
            repeat_style = "do_max_age"
            repeat_value = val

    try:
        topic = argv[3]
    except:
        sys.stderr.write(
            "Usage: %s [ --help ] [ options ... ] from-server to-server topic [ topic ... ]\n"
            % argv[0])
        sys.stderr.flush()
        sys.exit(1)

    client1_url = argv[1]
    client2_url = argv[2]

    ua = pubsublib.HTTPUserAgent()
    client1 = pubsublib.SimpleClient(ua, client1_url)
    client2 = pubsublib.SimpleClient(ua, client2_url)
    for topic in argv[3:]:
        Repeater(verbose, recursive, client1, client2, topic,
                 {repeat_style: repeat_value})
        if bridge:
            Repeater(verbose, recursive, client2, client1, topic,
                     {repeat_style: repeat_value})

    while 1:
        asyncore.poll(scheduler.timeout())
        scheduler.run()