Basic app and config was created
This commit is contained in:
32
src/main.py
32
src/main.py
@@ -1,5 +1,31 @@
|
||||
from config_manager import Configmanager
|
||||
|
||||
from config_manager.config_manager import ConfigManager
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import os
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class MailOrderBot(ConfigManager):
|
||||
def __init__(self, *agrs, **kwargs):
|
||||
super().__init__(*agrs, **kwargs)
|
||||
|
||||
def execute(self):
|
||||
print("run")
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
print("Hello, World!")
|
||||
async def main():
|
||||
app = MailOrderBot("config.yaml") # Можно config.json или config.yaml
|
||||
task = asyncio.create_task(app.start())
|
||||
await asyncio.sleep(5)
|
||||
app.stop()
|
||||
await task
|
||||
logger.info("Work finished.")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user