Beispiel #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()
Beispiel #2
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()
Beispiel #3
0
            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,
                )

    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()

Beispiel #5
0
	def schedule(self, delay, cb):
		"""Schedule a callback to run 'delay' seconds in the future."""
		return scheduler.add(delay, callback=cb)
Beispiel #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)
Beispiel #7
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)
Beispiel #8
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()