Skip to content

Commit b53132d

Browse files
committed
nit
1 parent 256a54f commit b53132d

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

coListener/coListener.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def __init__(self):
196196
self.get_parameter("error_code_topic").get_parameter_value().string_value
197197
)
198198

199-
self.declare_parameter("waiting_data_minutes", 10)
199+
self.declare_parameter("waiting_data_minutes", 60)
200200
self.waiting_minutes = (
201201
self.get_parameter("waiting_data_minutes")
202202
.get_parameter_value()
@@ -216,9 +216,9 @@ def __init__(self):
216216
_log.info(
217217
f"[node params] bag_storage_path: {self.bag_storage_path}, "
218218
f"error_code_topic: {self.error_code_topic}, "
219-
f"waiting_data_minutes: {self.waiting_minutes},"
220-
f"use_service: {self.use_service},"
221-
f"cos_agent_path: {cos_agent_path},"
219+
f"waiting_data_minutes: {self.waiting_minutes}, "
220+
f"use_service: {self.use_service}, "
221+
f"cos_agent_path: {cos_agent_path}, "
222222
f"version: {self.version}"
223223
)
224224

@@ -550,9 +550,13 @@ def _write_upload_info_to_cos_state(
550550
json.dump(info.to_dict(), fp, indent=4)
551551

552552
def _collect_bag_files(self, trigger_time, cache_data):
553-
bag_interval_minutes = 2
554-
bags_to_upload = []
555553
bag_files = []
554+
bags_to_upload = []
555+
bag_interval_minutes = 2
556+
557+
if not os.path.exists(self.bag_storage_path):
558+
return False, bags_to_upload
559+
556560
files = os.listdir(self.bag_storage_path)
557561
for bag_file in files:
558562
bag_full_path = os.path.join(self.bag_storage_path, bag_file)
@@ -609,10 +613,14 @@ def _collect_bag_files(self, trigger_time, cache_data):
609613

610614
def _collect_log_files(self):
611615
log_files = []
616+
logs_to_upload = []
612617
log_directory = os.path.join(
613618
self.log_storage_path, datetime.datetime.now().strftime("%Y%m%d")
614619
)
615620

621+
if not os.path.exists(log_directory):
622+
return logs_to_upload
623+
616624
for node_name in os.listdir(log_directory):
617625
node_log_dir = os.path.join(log_directory, node_name)
618626
if node_name == "edge_gateway":
@@ -653,7 +661,6 @@ def _collect_log_files(self):
653661
if file_to_update != "":
654662
log_files.append(file_to_update)
655663

656-
logs_to_upload = []
657664
for log_file in log_files:
658665
logs_to_upload.append(
659666
{

coListener/rest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ def fetch_rules_version(self) -> Dict[str, int]:
9191
for project in projects:
9292
project_name = str(project["name"])
9393

94-
version_url = (f"{self.__api_url}/dataplatform/v1alpha2/"
95-
f"{project_name}/diagnosisRule/metadata")
94+
version_url = (
95+
"{self.__api_url}/dataplatform/v1alpha2/{project_name}/diagnosisRule/metadata"
96+
)
9697
ver = self._get_response(version_url, {}).get("currentVersion", -1)
9798
rules_version[project_name] = ver
9899
return rules_version

launch/coListener.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def generate_launch_description():
2222
log_storage_path = "/home/cos/files/logs"
2323
error_code_topic = "/error_code"
2424
use_service = False
25-
waiting_data_minutes = 60
25+
waiting_data_minutes = 10
2626

2727
return LaunchDescription(
2828
[

0 commit comments

Comments
 (0)