Skip to content

Commit

Permalink
feat: change directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
keivanipchihagh committed Mar 19, 2024
1 parent b50965a commit b5774af
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
##########################################################

# Third-party imports
from src.athena.server import AthenaServer
from src.rpc.athena.server import AthenaServer


if __name__ == '__main__':
Expand Down
Binary file modified requirements.txt
Binary file not shown.
Empty file removed src/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/athena/server.py → src/rpc/athena/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import grpc

# Third-party imports
from src.base_server import BaseServer
from src.rpc.base_server import BaseServer
from protos.athena import athena_pb2
from protos.athena import athena_pb2_grpc

Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/base_server.py → src/rpc/base_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import grpc
from concurrent import futures

# Third-party imports
from src.utils import logger


class BaseServer(object):

Expand Down Expand Up @@ -41,5 +44,6 @@ def start(self) -> None:
"""
Starts the server in blocking mode.
"""
logger.debug(f"Starting server on {self.target}")
self.server.start()
self.server.wait_for_termination()
46 changes: 46 additions & 0 deletions src/utils/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
##########################################################
#
# Copyright (C) 2023-PRESENT: Keivan Ipchi Hagh
#
# Email: [email protected]
# GitHub: https://github.com/keivanipchihagh
#
##########################################################

from colorama import Fore
from pytz import timezone
from datetime import datetime
from colorama import init as colorama_init

colorama_init()
TZ = timezone('Asia/Tehran') # Timezone


def __now() -> str:
""" Returns the current datetime as string """
return datetime.now(TZ).strftime('%Y-%m-%d %H:%M:%S')


def debug(message: str) -> None:
""" Prints a message as debug """
print(f"[{Fore.MAGENTA}DEBUG{Fore.BLUE} - {Fore.BLACK}{__now()}{Fore.RESET}]\t{message}")


def info(message: str) -> None:
""" Prints a message as info """
print(f"[{Fore.BLUE}INFO{Fore.BLUE} - {Fore.BLACK}{__now()}{Fore.RESET}]\t{message}")


def success(message: str) -> None:
""" Prints a message as success """
print(f"[{Fore.GREEN}SUCCESS{Fore.RESET} - {Fore.BLACK}{__now()}{Fore.RESET}]\t{message}")


def error(message: str) -> None:
""" Prints a message as error """
print(f"[{Fore.RED}ERROR{Fore.RESET} - {Fore.BLACK}{__now()}{Fore.RESET}]\t{message}")


def warning(message: str) -> None:
""" Prints a message as warning """
print(f"[{Fore.YELLOW}WARNING{Fore.RESET} - {Fore.BLACK}{__now()}{Fore.RESET}]\t{message}")

0 comments on commit b5774af

Please sign in to comment.