def init_db_device_refresh_devices(self, url): """ Args: url: Returns: """ worker_hostname = REFRESH_WORKER_HOST devs = url.get('devices') db_device = { "devices": verify.create_dev_dict(devs), "unprocess": len(devs), "created_time": datetime.now(), "_id": self.dev_id } # dev_id = db.device.insert(db_device) url["dev_id"] = self.dev_id # db_update(db.url, {"_id": ObjectId(url.get("id"))}, {"$set": {"dev_id": self.dev_id}}) db_update(db.url, {"_id": ObjectId(url.get("id"))}, { "$set": { "dev_id": self.dev_id, "worker_host": worker_hostname, "recev_host": url.get("recev_host", "") } }) logger.debug( "dir_init_db_device successed ,url_id : %s ,dev_id = %s " % (url.get("id"), self.dev_id)) return db_device
def init_db_device(self, urls): """ 从RCMS获取需要的设备,更新url表,将dev_id加入表中 :param urls: :return: """ worker_hostname = REFRESH_WORKER_HOST devs = rcmsapi.getDevices(urls[0].get("channel_code")) logger.debug('init_db_device:%s' % urls[0].get("layer_type")) if urls[0].get("layer_type") != "one": devs += rcmsapi.getFirstLayerDevices(urls[0].get("channel_code")) db_device = { "devices": verify.create_dev_dict(devs), "unprocess": len(devs), "created_time": datetime.now(), "_id": self.dev_id } for url in urls: url["dev_id"] = self.dev_id db_update(db.url, {"_id": ObjectId(url.get("id"))}, { "$set": { "dev_id": self.dev_id, "worker_host": worker_hostname, "recev_host": url.get("recev_host", "") } }) logger.debug( "url_init_db_device successed ,worker_id: %s ,dev_id: %s " % (self.get_id_in_requestofwork(), self.dev_id)) return db_device
def init_db_device_refresh_device(self, urls): """ 设备列表全部存在于urls Args: urls: Returns: """ worker_hostname = REFRESH_WORKER_HOST devs = urls[0].get('devices') db_device = { "devices": verify.create_dev_dict(devs), "unprocess": len(devs), "created_time": datetime.now(), "_id": self.dev_id } for url in urls: url["dev_id"] = self.dev_id db_update(db.url, {"_id": ObjectId(url.get("id"))}, { "$set": { "dev_id": self.dev_id, "worker_host": worker_hostname, "recev_host": url.get("recev_host", "") } }) logger.debug( "url_init_db_device successed ,worker_id: %s ,dev_id: %s " % (self.get_id_in_requestofwork(), self.dev_id)) return db_device
def init_db_device(self, url): worker_hostname = REFRESH_WORKER_HOST devs = rcmsapi.getDevices(url.get("channel_code")) if url.get("layer_type") != "one": devs += rcmsapi.getFirstLayerDevices(url.get("channel_code")) db_device = { "devices": verify.create_dev_dict(devs), "unprocess": len(devs), "created_time": datetime.now(), "_id": self.dev_id } # dev_id = db.device.insert(db_device) url["dev_id"] = self.dev_id #db_update(db.url, {"_id": ObjectId(url.get("id"))}, {"$set": {"dev_id": self.dev_id}}) db_update(db.url, {"_id": ObjectId(url.get("id"))}, { "$set": { "dev_id": self.dev_id, "worker_host": worker_hostname, "recev_host": url.get("recev_host", "") } }) logger.debug( "dir_init_db_device successed ,url_id : %s ,dev_id = %s " % (url.get("id"), self.dev_id)) return db_device
finally: self.save_device_results(url) def init_db_device(self, url): worker_hostname = REFRESH_WORKER_HOST devs = rcmsapi.getDevices(url.get("channel_code")) if url.get("layer_type") != "one": devs += rcmsapi.getFirstLayerDevices(url.get("channel_code")) try: devs += rcmsapi.getGrayDevices(url.get("channel_code")) except Exception, e: logger.debug(traceback.format_exc()) db_device = { "devices": verify.create_dev_dict(devs), "unprocess": len(devs), "created_time": datetime.now(), "_id": self.dev_id } # dev_id = db.device.insert(db_device) url["dev_id"] = self.dev_id # db_update(db.url, {"_id": ObjectId(url.get("id"))}, {"$set": {"dev_id": self.dev_id}}) db_update(db.url, {"_id": ObjectId(url.get("id"))}, { "$set": { "dev_id": self.dev_id, "worker_host": worker_hostname, "recev_host": url.get("recev_host", "") } }) logger.debug(