fix(ocpp-server): silence linter
[e-mobility-charging-stations-simulator.git] / tests / ocpp-server / server.py
index 5738c7e33ce778fcf401c1bdb7ac501f9944c3d1..034218d2503738fa3d56713923cd340393fc1d6e 100644 (file)
@@ -2,7 +2,6 @@ import argparse
 import asyncio
 import logging
 from datetime import datetime, timezone
-from functools import partial
 from threading import Timer
 
 import ocpp.v201
@@ -124,8 +123,7 @@ class ChargePoint(ocpp.v201.ChargePoint):
         if response.status == ReportBaseType.accepted:
             logging.info("%s successful", Action.GetBaseReport)
         else:
-            logging.info("%s filed", Action.GetBaseReport)
-
+            logging.info("%s failed", Action.GetBaseReport)
 
 
 # Function to send OCPP command
@@ -138,16 +136,18 @@ async def send_ocpp_command(cp, command_name, delay=None, period=None):
             case Action.GetBaseReport:
                 logging.info("%s Send:", Action.GetBaseReport)
                 await cp.send_get_base_report()
-            case _:
-                logging.warning(f"Unsupported command {command_name}")
     except Exception:
-        logging.exception(f"Failure while processing command {command_name}")
+        logging.exception(
+            f"Not supported or Failure while processing command {command_name}"
+        )
 
     if delay:
         await asyncio.sleep(delay)
 
     if period:
-        my_timer = RepeatTimer(period, asyncio.create_task, [cp.send_ocpp_command(command_name)])
+        my_timer = RepeatTimer(
+            period, asyncio.create_task, [cp.send_ocpp_command(command_name)]
+        )
         my_timer.start()
 
 
@@ -184,6 +184,7 @@ async def on_connect(websocket, path):
         ChargePoints.remove(cp)
         logging.debug("Connected ChargePoint(s): %d", len(ChargePoints))
 
+
 # Main function to start the WebSocket server.
 async def main():
     # Define argument parser
@@ -192,7 +193,6 @@ async def main():
     parser.add_argument("--delay", type=int, help="Delay in seconds")
     parser.add_argument("--period", type=int, help="Period in seconds")
 
-
     # Create the WebSocket server and specify the handler for new connections.
     server = await websockets.serve(
         on_connect,
@@ -202,14 +202,6 @@ async def main():
     )
     logging.info("WebSocket Server Started")
 
-    args = parser.parse_args()
-
-    if args.command:
-        for cp in ChargePoints:
-            asyncio.create_task(
-                send_ocpp_command(cp, args.command, args.delay, args.period)
-                )
-
     # Wait for the server to close (runs indefinitely).
     await server.wait_closed()