윤영준 윤영준 05-27
preparing to connect with the main server
@7b00ed44c99660c5da9b9a5bb43fd6c570ff2e17
.gitignore
--- .gitignore
+++ .gitignore
@@ -1,1 +1,2 @@
 /hls_streaming/captured_frame_/
+/config_files/MAIN_DB_ENDPOINT.json
(파일 끝에 줄바꿈 문자 없음)
 
config_files/MAIN_DB_ENDPOINT.json (added)
+++ config_files/MAIN_DB_ENDPOINT.json
@@ -0,0 +1,19 @@
+{
+  "address" : "210.180.118.83",
+  "port" : "5423",
+  "id" : "takensoft",
+  "password" : "tts96314728!@",
+  "table_name" : "flooding_detect_event",
+  "columns" : [
+    "ocrn_dt",
+    "eqpmn_id",
+    "flooding_result",
+    "flooding_per",
+    "image",
+    "image_seg",
+    "eqpmn_lat",
+    "eqpmn_lon",
+    "flooding_y",
+    "flooding_x"
+  ]
+}(파일 끝에 줄바꿈 문자 없음)
postprocess_draft.py
--- postprocess_draft.py
+++ postprocess_draft.py
@@ -33,10 +33,22 @@
 
 class StreamSources():
     def __init__(self, buffer_size, normal_send_interval, failure_mode_thres, failure_mode_check_past_n, normal_mode_thres, normal_mode_check_past_n):
-        assert failure_mode_thres <= failure_mode_check_past_n, f"failure_mode checker condition is invaild!, failure_mode needs {failure_mode_thres} fails in {failure_mode_check_past_n}, which is not possible!"
-        assert normal_mode_thres <= normal_mode_check_past_n, f"normal_mode checker condition is invaild!, normal_mode needs {normal_mode_thres} fails in {normal_mode_check_past_n}, which is not possible!"
-        assert buffer_size >= failure_mode_check_past_n, f"'buffer_size' is smaller then failure_mode_thres! This is not possible! This will cause program to never enter failure mode!! \nPrinting relevent args and shutting down!\n buffer_size : {buffer_size}\n failure_mode_thres : {failure_mode_thres}"
-        assert buffer_size >= normal_mode_check_past_n, f"'buffer_size' is smaller then normal_mode_thres! This is will cause the program to never revert back to normal mode!! \nPrinting relevent args and shutting down!\n buffer_size : {buffer_size}\n normal_mode_thres : {normal_mode_thres}"
+        assert failure_mode_thres <= failure_mode_check_past_n,\
+            (f"failure_mode checker condition is invaild!,"
+             f" failure_mode needs {failure_mode_thres} fails in {failure_mode_check_past_n}, which is not possible!")
+        assert normal_mode_thres <= normal_mode_check_past_n,\
+            (f"normal_mode checker condition is invaild!,"
+             f" normal_mode needs {normal_mode_thres} fails in {normal_mode_check_past_n}, which is not possible!")
+        assert buffer_size >= failure_mode_check_past_n,\
+            (f"'buffer_size' is smaller then failure_mode_thres! This is not possible!"
+             f" This will cause program to never enter failure mode!! \n"
+             f"Printing relevent args and shutting down!\n"
+             f" buffer_size : {buffer_size}\n failure_mode_thres : {failure_mode_thres}")
+        assert buffer_size >= normal_mode_check_past_n,\
+            (f"'buffer_size' is smaller then normal_mode_thres!"
+             f" This is will cause the program to never revert back to normal mode!! \n"
+             f"Printing relevent args and shutting down!\n"
+             f" buffer_size : {buffer_size}\n normal_mode_thres : {normal_mode_thres}")
     
         self.sources = {}
         self.buffer_size = buffer_size
@@ -84,7 +96,8 @@
         return self.sources
 
     def add_status(self, source, status):
-        assert status in ["OK", "FAIL"], f"Invalid status was given!, status must be one of 'OK' or 'FAIL', but given '{status}'!"
+        assert status in ["OK", "FAIL"],\
+            f"Invalid status was given!, status must be one of 'OK' or 'FAIL', but given '{status}'!"
         
         if source not in self.sources:
             raise ValueError(f"No key found for source. Did you forgot to add it? \n source : {source}")
@@ -125,6 +138,7 @@
                 flag_send_event = True
                 self.sources[source]["normal_to_failure_mode_change_alert"] = True
 
+            # regular interval message logic
             if self.sources[source]["last_send_before"] > self.normal_send_interval:
                 flag_send_event =True
             else :
 
streaming_url_updator.py (added)
+++ streaming_url_updator.py
@@ -0,0 +1,40 @@
+import requests
+from ITS.api import gather_cctv_list
+
+from flask import Flask
+from flask_restx import Api
+from apscheduler.schedulers.background import BackgroundScheduler
+from apscheduler.triggers.interval import IntervalTrigger
+
+API_ENDPOINT = ""
+
+app = Flask(__name__)
+print("ITS API Updater START")
+
+api = Api(app,
+          version='0.1',
+          title="monitoring",
+          description="API Server",
+          terms_url="/",
+          contact="",
+          )
+
+
+def url_list_sender():
+    df = gather_cctv_list(129.2, 129.3, 35.9, 36.07, 1, "its", 1)
+    df = df.drop("roadsectionid", axis=1)
+    df = df.drop("cctvresolution", axis=1)
+    df = df.drop("filecreatetime", axis=1)
+    payload = df.T.to_json()
+    requests.post(API_ENDPOINT, json=payload)
+
+url_list_sender()
+scheduler = BackgroundScheduler()
+scheduler.start()
+scheduler.add_job(
+    func=url_list_sender,
+    trigger=IntervalTrigger(hours=10),
+    id='weather_data_update',
+    name='update weather time every 6 hours',
+    replace_existing=True
+)
Add a comment
List