refactor: change backend as the pure API backend
This commit is contained in:
@@ -9,7 +9,7 @@ import utils
|
||||
import database
|
||||
|
||||
|
||||
def GetUsernamePassword():
|
||||
def GetUsernamePassword() -> tuple[str, str]:
|
||||
print("What is the first username of this calendar system?")
|
||||
cache = input()
|
||||
while not utils.IsValidUsername(cache):
|
||||
@@ -27,14 +27,19 @@ def GetUsernamePassword():
|
||||
return (username, password)
|
||||
|
||||
|
||||
def SetLoggingStyle(level: int) -> None:
|
||||
logging.basicConfig(format="[%(levelname)s] %(message)s", level=level)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Coconut-leaf")
|
||||
print("A self-host, multi-account calendar system.")
|
||||
print("Project: https://github.com/yyc12345/coconut-leaf")
|
||||
print("===================")
|
||||
# Set as INFO level in default first,
|
||||
# and we will change it once we load the configuration file.
|
||||
SetLoggingStyle(logging.INFO)
|
||||
|
||||
# Receive arguments
|
||||
parser = ArgumentParser(description="Coconut-leaf")
|
||||
parser = ArgumentParser(
|
||||
description="The server of light, self-host and multi-account calendar system."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--config",
|
||||
@@ -54,16 +59,22 @@ if __name__ == "__main__":
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Show splash
|
||||
logging.info("Coconut-leaf")
|
||||
logging.info("A light, self-host and multi-account calendar system")
|
||||
logging.info("Project: https://github.com/yyc12345/coconut-leaf")
|
||||
logging.info("===================")
|
||||
|
||||
# Load config file
|
||||
try:
|
||||
config.setup_config(cast(Path, args.config))
|
||||
except Exception as e:
|
||||
print(f"Error loading config file: {e}")
|
||||
logging.critical(f"Error loading config file: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
# Setup logging level
|
||||
# Change logging level again according to whether enable debug mode
|
||||
logging_level = logging.DEBUG if config.get_config().others.debug else logging.INFO
|
||||
logging.basicConfig(format='[%(levelname)s] %(message)s', level=logging_level)
|
||||
SetLoggingStyle(logging_level)
|
||||
|
||||
# Initialize the calendar system if needed
|
||||
if cast(bool, args.init):
|
||||
|
||||
Reference in New Issue
Block a user