Ejemplo n.º 1
0
def writePidToFile(pidfile):
    if path.isfile(pidfile):
        info(pidfile + " already exists, exiting")
        with open(pidfile, 'r') as file:
            pid = int(file.read())
            if ProcessInfo.IsRunning(pid) and pid != getpid():
                Daemon.Exit()
                return
    pid = str(getpid())
    with open(pidfile, 'w') as file:
        file.write(pid)
Ejemplo n.º 2
0
 def CheckSubscription(self):
     inviteCode = self.config.get('Agent', 'InviteCode')
     cayenneApiClient = CayenneApiClient(self.CayenneApiHost)
     authId = cayenneApiClient.loginDevice(inviteCode)
     if authId == None:
         error(
             'Registration failed for invite code {}, closing the process'.
             format(inviteCode))
         Daemon.Exit()
     else:
         info('Registration succeeded for invite code {}, auth id = {}'.
              format(inviteCode, authId))
         self.config.set('Agent', 'Initialized', 'true')
         self.MachineId = authId