def updateData(self): if self.status == 'Stopped' and self.handle: db = simpleDB(self.handle) user = db.select(self.ctid) data = dict() param = FTPDownload.parameter param['host'] = user['labip'] param['ctid'] = user['ctid'] fd = ftpDownload(param) addr = fd.getAddr() if addr and (len(addr)>0): user['status'] = 'Stopped' user['addr'] = addr else: user['status'] = 'Failure' data[self.ctid] = user db.update(data)
def updateData(self): if self.status == 'Stopped' and self.handle: db = simpleDB(self.handle) item = db.select(self.ctid) data = dict() param = FTPDownload.parameter param['host'] = item['labip'] param['ctid'] = item['ctid'] fd = ftpDownload(param) addr = fd.getAddr() if addr and (len(addr)>0): item['status'] = 'Stopped' item['addr'] = addr else: item['status'] = 'Failure' db.add(item) db.close()
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 = FTPDownload.parameter param['host'] = value['labip'] param['ctid'] = value['ctid'] fd = ftpDownload(param) addr = fd.getAddr() if addr and (len(addr)>0): value['status'] = 'Stopped' value['addr'] = addr else: value['status'] = 'Failure' data[key] = value data[key] = value self.save(data) return data