Esempio n. 1
0
    def run(self):
        ## Setup scheduler
        scheduler = self.scheduler
        device = config.getint('Client', 'device')
        name = config.get('Client', 'name')

        ## Configure Device
        print "BacLog.run> configure", device
        table = service.InstanceTable(device, name)

        point = service.BinaryOutput(0, 'BO_0')
        point.presentValue._value = tagged.Boolean(True)
        table.add(point)

        point = service.BinaryOutput(1, 'BO_1')
        point.presentValue._value = tagged.Boolean(True)
        table.add(point)

        service.register(scheduler, self.mh, service.ReadProperty(table))
        service.register(scheduler, self.mh,
                         service.ReadPropertyMultiple(table))
        service.register(scheduler, self.mh, service.WriteProperty(table))

        cov = service.COV(table)
        scheduler.add(cov)

        service.register(scheduler, self.mh, service.SubscribeCOV(table, cov))

        print "BacLog.run> run"
        scheduler.run()

        ## Terminate
        self.shutdown()
Esempio n. 2
0
def main(argv):
    url = argv[1]
    test(url)
    while 1:
        asyncore.poll(scheduler.timeout())
        # print "\n\n asyncore.poll \n"
        scheduler.run()
Esempio n. 3
0
def main(argv):
    url = argv[1]
    test(url)
    while 1:
        asyncore.poll(scheduler.timeout())
        # print "\n\n asyncore.poll \n"
        scheduler.run()
Esempio n. 4
0
    def run(self):
        ## Setup scheduler
        scheduler=self.scheduler
        device=config.getint('Client','device')
        name=config.get('Client','name')
        
        ## Configure Device
        print "BacLog.run> configure", device
        table=service.InstanceTable(device,name)

        point=service.BinaryOutput(0,'BO_0')
        point.presentValue._value=tagged.Boolean(True)
        table.add(point)

        point=service.BinaryOutput(1,'BO_1')
        point.presentValue._value=tagged.Boolean(True)
        table.add(point)

        service.register(scheduler,self.mh,service.ReadProperty(table))
        service.register(scheduler,self.mh,service.ReadPropertyMultiple(table))
        service.register(scheduler,self.mh,service.WriteProperty(table))

        cov=service.COV(table)
        scheduler.add(cov)
        
        service.register(scheduler,self.mh,service.SubscribeCOV(table,cov))

        print "BacLog.run> run"
        scheduler.run()
       
        ## Terminate
        self.shutdown()
Esempio n. 5
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()
Esempio n. 6
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()
Esempio n. 7
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()
Esempio n. 8
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()
Esempio n. 9
0
def main():
    dp = updater.dispatcher

    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("subscribe", subscribe))
    dp.add_handler(CommandHandler("check", check_subscriptions))
    dp.add_handler(CommandHandler("unsubscribe", unsubscribe))
    dp.add_handler(CommandHandler("testerror", test_error))

    updater.start_polling()

    try:
        scheduler.run(updater.bot)
    except:
        handle_exception()

    updater.idle()
Esempio n. 10
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()
Esempio n. 11
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()
Esempio n. 12
0
    def run(self):
        from os import name
        """Run method that performs all the real work"""
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result:
            functions = []
            outputs = []

            # If os.name is posix, file structure uses forward slashes. Otherwise,
            # in Windows use back slashes.
            input_file = str(self.dlg.input_line.text())
            if input_file == "":
                print "NO OPTION SELECTED!"
                return

            if name == 'posix':
                input_file_name = input_file[input_file.rfind('/') + 1:]
                input_file_name = "/" + input_file_name[:-4]
            else:
                input_file_name = input_file[input_file.rfind('/') + 1:]
                input_file_name = "\\" + input_file_name[:-4]

            print "file name: ", input_file_name
            print "input file: ", input_file

            print input_file, " in cudaRaster"
            if self.dlg.slope_check.isChecked():
                functions.append("slope")
            if self.dlg.aspect_check.isChecked():
                functions.append("aspect")
            if self.dlg.hillshade_check.isChecked():
                functions.append("hillshade")
            for function in functions:
                outputs.append(str(self.dlg.output_line.text())\
                             + input_file_name\
                             + "_" + function + ".tif")

            # Run main code
            if scheduler.run(input_file, outputs, functions):
                print "Something went wrong."
                self.dlg2.show()
                self.dlg2.pushButton.clicked.connect(
                    (lambda: self.dlg2.close()))
Esempio n. 13
0
    def run(self):
        from os import name
        """Run method that performs all the real work"""
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result:
            functions = []
            outputs = []

            # If os.name is posix, file structure uses forward slashes. Otherwise,
            # in Windows use back slashes.
            input_file = str(self.dlg.input_line.text())
            if input_file == "":
                print "NO OPTION SELECTED!"
                return

            if name == 'posix':
                input_file_name = input_file[input_file.rfind('/')+1:]
                input_file_name = "/" + input_file_name[:-4]
            else:
                input_file_name = input_file[input_file.rfind('/')+1:]
                input_file_name = "\\" + input_file_name[:-4]

            print "file name: ", input_file_name
            print "input file: ", input_file

            print input_file, " in cudaRaster"
            if self.dlg.slope_check.isChecked():
                functions.append("slope")
            if self.dlg.aspect_check.isChecked():
                functions.append("aspect")
            if self.dlg.hillshade_check.isChecked():
                functions.append("hillshade")
            for function in functions:
                outputs.append(str(self.dlg.output_line.text())\
                             + input_file_name\
                             + "_" + function + ".tif") 

            # Run main code
            if scheduler.run(input_file, outputs, functions):
                print "Something went wrong."
                self.dlg2.show()
                self.dlg2.pushButton.clicked.connect((lambda: self.dlg2.close()))
Esempio n. 14
0
                work.bpp = bpp
                work.codec = args.codec
                work.runid = str(args.runid)
                work.set = args.set[0]
                work.filename = filename
                work.extra_options = extra_options
                work_items.append(work)
else:
    print('Unsupported -mode parameter.')
    sys.exit(1)

if len(slots) < 1:
    rd_print('All AWS machines are down.')
    sys.exit(1)

work_done = scheduler.run(work_items, slots)

if args.mode == 'metric':
    rd_print('Logging results...')
    work_done.sort(key=lambda work: work.quality)
    for work in work_done:
        if not work.failed:
            if args.individual:
                f = open((args.prefix + '/' + os.path.basename(work.filename) +
                          '.out').encode('utf-8'), 'a')
            else:
                f = open((args.prefix + '/' + work.filename +
                          '-daala.out').encode('utf-8'), 'a')
            f.write(str(work.quality) + ' ')
            f.write(str(work.pixels) + ' ')
            f.write(str(work.size) + ' ')
Esempio n. 15
0
 def test_run(self, mock_getproxies, mock_proxy, mock_voter):
     mock_proxy.proxy_nums.return_value = 26
     #mock_proxy.get_one_proxy.return_value = {"protocol":"http", "ip":"183.207.228.9","port":80}
     mock_proxy.get_one_proxy.return_value = {}
     scheduler.run()
Esempio n. 16
0
def _run_sid(arg):
   result = scheduler.run(arg[0], arg[1], arg[2])
   report(result)
   return result
Esempio n. 17
0
                work.bpp = bpp
                work.codec = args.codec
                work.runid = str(args.runid)
                work.set = args.set[0]
                work.filename = filename
                work.extra_options = extra_options
                work_items.append(work)
else:
    print('Unsupported -mode parameter.')
    sys.exit(1)

if len(slots) < 1:
    rd_print('All AWS machines are down.')
    sys.exit(1)

work_done = scheduler.run(work_items, slots)

if args.mode == 'metric':
    rd_print('Logging results...')
    work_done.sort(key=lambda work: work.quality)
    for work in work_done:
        if not work.failed:
            if args.individual:
                f = open((args.prefix+'/'+os.path.basename(work.filename)+'.out').encode('utf-8'),'a')
            else:
                f = open((args.prefix+'/'+work.filename+'-daala.out').encode('utf-8'),'a')
            f.write(str(work.quality)+' ')
            f.write(str(work.pixels)+' ')
            f.write(str(work.size)+' ')
            f.write(str(work.metric['psnr'][0])+' ')
            f.write(str(work.metric['psnrhvs'][0])+' ')
Esempio n. 18
0
    def run(self):
        from os import name
        """Run method that performs all the real work"""
        # get layers currently loaded in qgis
        self.dlg.input_layer_box.clear()
        self.layers = self.iface.legendInterface().layers()
        layer_list = []
        layer_list.append("None")
        for layer in self.layers:
            layer_list.append(layer.name())
        self.dlg.input_layer_box.addItems(layer_list)
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result:
            # Do something useful here - delete the line containing pass and
            # substitute with your code.
            functions = []
            outputs = []
            selected_index = self.dlg.input_layer_box.currentIndex()
            print "layer index: ", selected_index

            # Check if layer selected for input
            # If os.name is posix, file structure uses forward slashes. Otherwise,
            # in Windows use back slashes.
            if selected_index != 0:
                input_file = self.layers[selected_index - 1]
                input_file_name = input_file.name()
                print "file name: ", input_file_name
                if name == 'posix':
                    input_file_name = "/" + input_file_name
                else:
                    input_file_name = "\\" + input_file_name

            # If no layer already in QGIS was selected, check input from disk.
            else:
                input_file = str(self.dlg.input_line.text())
                if input_file == "":
                    print "NO OPTION SELECTED!"
                    return

                if name == 'posix':
                    input_file_name = input_file[input_file.rfind('/') + 1:]
                    input_file_name = "/" + input_file_name[:-4]
                else:
                    input_file_name = input_file[input_file.rfind('/') + 1:]
                    input_file_name = "\\" + input_file_name[:-4]

                print "file name: ", input_file_name
                print "input file: ", input_file

            print input_file, " in cudaRaster"
            if self.dlg.slope_check.isChecked():
                functions.append("slope")
            if self.dlg.aspect_check.isChecked():
                functions.append("aspect")
            if self.dlg.hillshade_check.isChecked():
                functions.append("hillshade")
            for function in functions:
                outputs.append(str(self.dlg.output_line.text())\
                             + input_file_name\
                             + "_" + function + ".tif")

            # Run main code
            if scheduler.run(input_file, outputs, functions):
                print "Something went wrong."
                self.dlg2.show()
                self.dlg2.pushButton.clicked.connect(
                    (lambda: self.dlg2.close()))

            # Load layer back into QGIS if requested
            if self.dlg.slope_check.isChecked(
            ) and self.dlg.qgis_slope_check.isChecked():
                for string in outputs:
                    if "_slope" in string:
                        fileInfo = QFileInfo(string)
                        baseName = fileInfo.baseName()
                        rlayer = QgsRasterLayer(string, baseName)
                        QgsMapLayerRegistry.instance().addMapLayer(rlayer)
            if self.dlg.aspect_check.isChecked(
            ) and self.dlg.qgis_aspect_check.isChecked():
                for string in outputs:
                    if "_aspect" in string:
                        fileInfo = QFileInfo(string)
                        baseName = fileInfo.baseName()
                        rlayer = QgsRasterLayer(string, baseName)
                        QgsMapLayerRegistry.instance().addMapLayer(rlayer)
            if self.dlg.hillshade_check.isChecked(
            ) and self.dlg.qgis_hillshade_check.isChecked():
                for string in outputs:
                    if "_hillshade" in string:
                        fileInfo = QFileInfo(string)
                        baseName = fileInfo.baseName()
                        rlayer = QgsRasterLayer(string, baseName)
                        QgsMapLayerRegistry.instance().addMapLayer(rlayer)
Esempio n. 19
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()
Esempio n. 20
0
# tak.cps.py, unvariablized by hand.

from scheduler import schedule, run

def cps_print(k, v):
    print(v)
    schedule(k)

def cps_tak (k, x, y, z):
    if y >= x:
        schedule (k, z)
    else:
        def kf2 (v8):
            schedule (k, v8)
        def kf5 (v9):
            def kf4 (v10):
                def kf3 (v11):
                    cps_tak (kf2, v9, v10, v11)
                cps_tak (kf3, z-1, x, y)
            cps_tak (kf4, y-1, z, x)
        cps_tak (kf5, x-1, y, z)
def kf0 ():
    pass
def kf1 (v0):
    cps_print (kf0, v0)
cps_tak (kf1, 18, 12, 6)

run()
Esempio n. 21
0
 def start(self):
     """
     Starts transmission to server.
     """
     scheduler.run(self.gather_data_and_send)
Esempio n. 22
0
    def run(self):
        from os import name
        """Run method that performs all the real work"""
        # get layers currently loaded in qgis
        self.dlg.input_layer_box.clear()
        self.layers = self.iface.legendInterface().layers()
        layer_list = []
        layer_list.append("None")
        for layer in self.layers:
             layer_list.append(layer.name())
        self.dlg.input_layer_box.addItems(layer_list)
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result:
            # Do something useful here - delete the line containing pass and
            # substitute with your code.
            functions = []
            outputs = []
            selected_index = self.dlg.input_layer_box.currentIndex()
            print "layer index: ", selected_index

            # Check if layer selected for input
            # If os.name is posix, file structure uses forward slashes. Otherwise,
            # in Windows use back slashes.
            if selected_index != 0:
                input_file = self.layers[selected_index-1]
                input_file_name = input_file.name()
                print "file name: ", input_file_name
                if name == 'posix':
                    input_file_name = "/" + input_file_name
                else:
                    input_file_name = "\\" + input_file_name

            # If no layer already in QGIS was selected, check input from disk.
            else:
                input_file = str(self.dlg.input_line.text())
                if input_file == "":
                    print "NO OPTION SELECTED!"
                    return
         
                if name == 'posix':
                    input_file_name = input_file[input_file.rfind('/')+1:]
                    input_file_name = "/" + input_file_name[:-4]
                else:
                    input_file_name = input_file[input_file.rfind('/')+1:]
                    input_file_name = "\\" + input_file_name[:-4]

                print "file name: ", input_file_name
                print "input file: ", input_file

            print input_file, " in cudaRaster"
            if self.dlg.slope_check.isChecked():
                functions.append("slope")
            if self.dlg.aspect_check.isChecked():
                functions.append("aspect")
            if self.dlg.hillshade_check.isChecked():
                functions.append("hillshade")
            for function in functions:
                outputs.append(str(self.dlg.output_line.text())\
                             + input_file_name\
                             + "_" + function + ".tif") 

            # Run main code
            if scheduler.run(input_file, outputs, functions):
                print "Something went wrong."
                self.dlg2.show()
                self.dlg2.pushButton.clicked.connect((lambda: self.dlg2.close()))

            # Load layer back into QGIS if requested
            if self.dlg.slope_check.isChecked() and self.dlg.qgis_slope_check.isChecked():
                for string in outputs:
                    if "_slope" in string:
                        fileInfo = QFileInfo(string)
                        baseName = fileInfo.baseName()            
                        rlayer = QgsRasterLayer(string, baseName)
                        QgsMapLayerRegistry.instance().addMapLayer(rlayer)
            if self.dlg.aspect_check.isChecked() and self.dlg.qgis_aspect_check.isChecked():
                for string in outputs:
                    if "_aspect" in string:
                        fileInfo = QFileInfo(string)
                        baseName = fileInfo.baseName()            
                        rlayer = QgsRasterLayer(string, baseName)
                        QgsMapLayerRegistry.instance().addMapLayer(rlayer)
            if self.dlg.hillshade_check.isChecked() and self.dlg.qgis_hillshade_check.isChecked():
                for string in outputs:
                    if "_hillshade" in string:
                        fileInfo = QFileInfo(string)
                        baseName = fileInfo.baseName()            
                        rlayer = QgsRasterLayer(string, baseName)
                        QgsMapLayerRegistry.instance().addMapLayer(rlayer)
Esempio n. 23
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()
Esempio n. 24
0
    if y >= x:
        schedule(k, z)
    else:

        def kf2(v8):
            schedule(k, v8)

        def kf5(v9):
            def kf4(v10):
                def kf3(v11):
                    cps_tak(kf2, v9, v10, v11)

                cps_tak(kf3, z - 1, x, y)

            cps_tak(kf4, y - 1, z, x)

        cps_tak(kf5, x - 1, y, z)


def kf0():
    pass


def kf1(v0):
    cps_print(kf0, v0)


cps_tak(kf1, 18, 12, 6)

run()
Esempio n. 25
0
    def run(self):
        ## Setup scheduler
        scheduler=self.scheduler
        device=config.getint('Network','device')
        name=config.get('Network','name')
        
        ## Object Discovery
        
        bootstrap=config.getboolean('Options','bootstrap')
        if bootstrap==False:
            ## Configure operation using scheduler task GetDevices
            task=database.GetDevices()
            self.scheduler.add(task)
            self.scheduler.run()
            devices=task.devices
            objectid=task.objectid
            deviceid=task.deviceid
            
        if bootstrap or (not devices):
            ## Use local.ini to get devices.
            db=console.Database()
            devices=db.getDevices();
            objects=FindObjects(devices)
            scheduler.add(objects)
            scheduler.run()
            objectid=objects.objectid
            deviceid=objects.deviceid


        print "BacLog.run>", devices
        if trace:
            for d in devices:
                print " ", d.objects

        ## Do an initial scan of values and exit
        if config.getboolean('Options','getinitialvalue'):
            for target in devices:
                scan=GetPresentValue()
                scan.target=target
                scheduler.add(scan)
            scheduler.run()
            scheduler.shutdown()
            return

        ## Configure Device
        print "BacLog.run> configure"

        table=service.InstanceTable(device,name)
        
        service.register(scheduler,self.mh,service.ReadProperty(device,name,table))
        service.register(scheduler,self.mh,service.ReadPropertyMultiple(device,name,table))
        service.register(scheduler,self.mh,service.WhoIs(device))

        cov_pid=scheduler.add(COVNotification())
        
        ## Applications
        
        if config.getboolean('Options','subscribeCOV'):
            lifetime=config.getint('Options','lifetime')
            for target in devices:
                cov=SubscribeCOV()
                cov.target=target
                cov.pid=cov_pid
                cov.lifetime=lifetime
                scheduler.add(cov)
                
        self.scheduler.add(Scheduler(self.dbh,self.dbs,deviceid,objectid))
                
        ## Run scheduler.
        print "BacLog.run> run"
        scheduler.run()
        
        ## Terminate
        self.shutdown()