コード例 #1
0
ファイル: bacnode.py プロジェクト: mtim/BacLog
    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()
コード例 #2
0
ファイル: bacnode.py プロジェクト: MiddelkoopT/BacLog
    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()
コード例 #3
0
ファイル: app.py プロジェクト: mzp/radikocast
            def scope():
                p = program

                def f(*args):
                    agent = Type[p["type"]](storage=storage, **p)
                    t = threading.Thread(target=lambda: agent(*args))
                    t.start()

                scheduler.add(
                    time=program["time"],
                    airtime=program["airtime"],
                    at=program.get("at", None),
                    repeat=program.get("repeat", None),
                    callback=f,
                )
コード例 #4
0

    def print(self):
        # Debug prints
        for item, doc in self.documents.items():
            print(item, ":", doc)

def run_backup():
    print("Running backup function")
    p = subprocess.run(['/usr/local/bin/s3_backup.sh'], capture_output=True)
    if p.returncode!=0:
        print("[Error] backup: \n STDERR:" + str(p.stderr) + "\nSTDOUT: "+str(p.stdout))
    else:
        print("[Success] backup: \n STDERR:" + str(p.stderr) + "\nSTDOUT: "+str(p.stdout))

if __name__=="__main__":
    builder = WpDockerBuilder('/etc/wp-docker-config.yml')
    builder.build_lamp()
    if os.environ.get('PORT') is None:
        os.environ['PORT'] = '80'

    p=subprocess.Popen (["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"], stdout=sys.stdout, stderr=sys.stderr)
    builder.setup_wordpress()

    if builder.backup_schedule is not None:
        scheduler = scheduler.Scheduler(60)
        scheduler.add("backup", builder.backup_schedule, run_backup)
        scheduler.start()
    p.wait()

コード例 #5
0
ファイル: qatest.py プロジェクト: pruan/TestDepot
	def schedule(self, delay, cb):
		"""Schedule a callback to run 'delay' seconds in the future."""
		return scheduler.add(delay, callback=cb)
コード例 #6
0
def register(scheduler, mh, servicehandler, Service=None):
    if Service == None:
        Service = servicehandler._service
    print "service.register>", Service
    scheduler.add(servicehandler)
    mh.addService(servicehandler, Service)
コード例 #7
0
ファイル: service.py プロジェクト: mtim/BacLog
def register(scheduler,mh,servicehandler,Service=None):
    if Service==None:
        Service=servicehandler._service
    print "service.register>", Service
    scheduler.add(servicehandler)
    mh.addService(servicehandler,Service)
コード例 #8
0
ファイル: baclog.py プロジェクト: MiddelkoopT/BacLog
    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()