MCPcopy Index your code
hub / github.com/WebODM/WebODM / update_node_info

Method update_node_info

nodeodm/models.py:69–96  ·  view source on GitHub ↗

Retrieves information and options from the node API and saves it into the database. :returns: True if information could be updated, False otherwise

(self)

Source from the content-addressed store, hash-verified

67 self.last_refreshed >= timezone.now() - timedelta(minutes=settings.NODE_OFFLINE_MINUTES)
68
69 def update_node_info(self):
70 """
71 Retrieves information and options from the node API
72 and saves it into the database.
73
74 :returns: True if information could be updated, False otherwise
75 """
76 api_client = self.api_client(timeout=5)
77 try:
78 info = api_client.info()
79
80 self.api_version = info.version
81 self.queue_count = info.task_queue_count
82
83 if isinstance(info.max_images, (int, float)):
84 self.max_images = max(0, info.max_images)
85 else:
86 self.max_images = None
87 self.engine_version = info.engine_version
88 self.engine = info.engine
89
90 options = list(map(lambda o: o.__dict__, api_client.options()))
91 self.available_options = options
92 self.last_refreshed = timezone.now()
93 self.save()
94 return True
95 except exceptions.GenericError:
96 return False
97
98 def api_client(self, timeout=30):
99 return Node(self.hostname, self.port, self.token, timeout)

Callers 7

update_nodes_infoFunction · 0.80
test_token_authMethod · 0.80
auto_update_node_infoFunction · 0.80
processing_nodeFunction · 0.80
listMethod · 0.80

Calls 4

api_clientMethod · 0.95
mapFunction · 0.50
optionsMethod · 0.45
saveMethod · 0.45

Tested by 3

test_token_authMethod · 0.64