def main(self):
     os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                           "PyScadaServer.settings")
     import django
     django.setup()
     from pyscada.modbus import Handler
     from pyscada.utils import daemon_run
     daemon_run(label='pyscada.modbus.daemon', handlerClass=Handler)
Exemplo n.º 2
0
    def start(self, context, daemon_name):
        if not context.pidfile.is_locked():
            try:
                mod = __import__('pyscada.%s.handler' % daemon_name,
                                 fromlist=['Handler'])
                handlerClass = getattr(mod, 'Handler')
            except:
                self.stdout.write("no such daemon")
                var = traceback.format_exc()
                log.error("exeption while initialisation of %s:%s %s" %
                          (daemon_name, os.linesep, var))

            context.open()
            daemon_run(label='pyscada.%s.daemon' % daemon_name,
                       handlerClass=handlerClass)
        else:
            self.stdout.write("process is already runnging")