Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ajil.k
test
Commits
903e9233
Commit
903e9233
authored
Jan 23, 2025
by
Ajil K
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added timeout and removed unwanted commented portions
parent
e4bc86c3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
83 deletions
+2
-83
requirements.txt
requirements.txt
+1
-1
scripts/logging/logger.py
scripts/logging/logger.py
+0
-81
scripts/utilities/communication_util.py
scripts/utilities/communication_util.py
+1
-1
No files found.
requirements.txt
View file @
903e9233
...
...
@@ -7,4 +7,4 @@ paho-mqtt==1.5.0
PyJWT
==2.4.0
ping3
==4.0.4
psutil
==5.9.6
httpx
~=0.28.1
\ No newline at end of file
httpx
==0.24.1
\ No newline at end of file
scripts/logging/logger.py
View file @
903e9233
# import logging
# import os
# from logging.handlers import RotatingFileHandler
#
#
# logger_topic = None
# logging.trace = logging.DEBUG - 5
# logging.addLevelName(logging.DEBUG - 5, "TRACE")
#
# class EngineLoggerClass(logging.getLoggerClass()):
# def __init__(self, name):
# super().__init__(name)
#
# def trace(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.trace):
# self._log(logging.trace, msg, args, **kwargs)
#
# def info(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.INFO):
# self._log(logging.INFO, msg, args, **kwargs)
#
# def debug(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.DEBUG):
# self._log(logging.DEBUG, msg, args, **kwargs)
#
# def warning(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.WARNING):
# self._log(logging.WARNING, msg, args, **kwargs)
#
# def error(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.ERROR):
# self._log(logging.ERROR, msg, args, **kwargs, extra={"__logger_topic__": logger_topic})
#
# def critical(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.CRITICAL):
# self._log(logging.CRITICAL, msg, args, **kwargs)
#
# def get_logger():
# """
# Creates a rotating log
# """
# logging.setLoggerClass(EngineLoggerClass)
# __logger__ = logging.getLogger('')
#
# # setting the logger level
# __logger__.setLevel("INFO")
#
# # creating the format for the log
# log_formatter = "%(asctime)s-%(levelname)-s-[%(funcName)5s():%(lineno)s]-%(message)s"
# time_format = "%Y-%m-%d %H:%M:%S"
#
# # getting the path for the logger
# file_path = "logs"
#
# # setting the format
# formatter = logging.Formatter(log_formatter, time_format)
#
# # creating the folder if not exist
# if not os.path.exists(file_path):
# os.makedirs(file_path)
#
# # joining the path
# log_file = os.path.join(f"{file_path}/redundancy.log")
#
# # creating rotating file handler with max byte as 1
# temp_handler = RotatingFileHandler(log_file,
# maxBytes=1000000000,
# backupCount=5)
#
# # setting the formatter
# temp_handler.setFormatter(formatter)
#
# # setting the handler
# __logger__.addHandler(temp_handler)
#
# return __logger__
#
#
# logger = get_logger()
import
json
import
logging
import
os
...
...
scripts/utilities/communication_util.py
View file @
903e9233
...
...
@@ -18,7 +18,7 @@ def post_data(json_data, logger, endpoint="receive_data"):
logger
.
trace
(
"Entered in post_data"
)
monitoring_endpoint
=
f
"http://{app_config.host_ip}:{app_config.port_no}/{endpoint}"
headers
=
{
'Content-Type'
:
'application/json'
}
response
=
httpx
.
post
(
monitoring_endpoint
,
data
=
json
.
dumps
(
json_data
),
headers
=
headers
)
response
=
httpx
.
post
(
monitoring_endpoint
,
data
=
json
.
dumps
(
json_data
),
headers
=
headers
,
timeout
=
60
)
if
response
.
status_code
==
200
:
response_data
=
response
.
content
.
decode
()
logger
.
trace
(
f
"response_data: {response_data}"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment