Example #1
0
 def updateData(self):
     if self.status == 'Stopped' and self.handle:
         db = simpleDB(self.handle)
         user = db.select(self.ctid)
         data = dict()
         param = SimpleFTP.parameter
         param['local'] = LOCAL
         param['labip'] = user['labip']
         param['ctid'] = user['ctid']
         addr = SimpleFTP.addr(param=param)
         if addr and len(addr)<120:
             user['status'] = 'Stopped'
             user['addr'] = addr
         else:
             user['status'] = 'Failure'
         data[self.ctid] = user
         db.update(data)
Example #2
0
 def filter(self, expires=7200):
     old = dict(self.load())
     data = {}
     if old:
         for key, value in old.items():
             alt = int(time.time()-value['time'])
             exp = int(value['duration'])*60
             if alt <= expires:
                 if alt >= exp and value['status'] == 'Started':
                     param = SimpleFTP.parameter
                     param['labip'] = value['labip']
                     param['ctid'] = value['ctid']
                     param['local'] = LOCAL
                     addr = SimpleFTP.addr(param=param, duration=24)
                     if addr and (len(addr)>0) and (len(addr)<120):
                         value['status'] = 'Stopped'
                         value['addr'] = addr
                     else:
                         value['status'] = 'Failure'
                         data[key] = value
                 data[key] = value
     self.save(data)
     return data