mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2025-02-14 10:40:57 +01:00
* added twitter error handling * added facebook tests * added header format test * added multiple newlines check * added test list command * fixed commands structure * fixed event retry * fixed publication retry * added publication tests * removed unused option * fixed list begin/end window * added test retry failures * linting * refactored sender * added timezone freeze * fixed facebook-sdk and beatifulsoup errors
43 lines
848 B
Python
43 lines
848 B
Python
import asyncio
|
|
import logging
|
|
import traceback
|
|
from logging.config import dictConfig
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
from mobilizon_reshare.config.config import get_settings
|
|
from mobilizon_reshare.storage.db import tear_down, MoReDB
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def graceful_exit():
|
|
await tear_down()
|
|
|
|
|
|
async def init():
|
|
settings = get_settings()
|
|
dictConfig(settings["logging"])
|
|
db_path = Path(settings.db_path)
|
|
db = MoReDB(db_path)
|
|
await db.setup()
|
|
|
|
|
|
async def _safe_execution(f):
|
|
await init()
|
|
|
|
return_code = 1
|
|
try:
|
|
return_code = await f()
|
|
except Exception:
|
|
traceback.print_exc()
|
|
finally:
|
|
logger.debug("Closing")
|
|
await graceful_exit()
|
|
return return_code
|
|
|
|
|
|
def safe_execution(f):
|
|
code = asyncio.run(_safe_execution(f))
|
|
sys.exit(code)
|