Fix folder creation
This commit is contained in:
parent
f90e69a979
commit
a2b8dd76b7
3 changed files with 14 additions and 15 deletions
|
@ -1,5 +1,6 @@
|
||||||
import datetime
|
import datetime
|
||||||
from os.path import getmtime, isfile
|
from os import mkdir
|
||||||
|
from os.path import getmtime, isfile, isdir
|
||||||
|
|
||||||
import ics
|
import ics
|
||||||
import requests
|
import requests
|
||||||
|
@ -7,6 +8,10 @@ from aiogram.utils import markdown
|
||||||
from ics.parse import ParseError, string_to_container
|
from ics.parse import ParseError, string_to_container
|
||||||
from ics.timeline import Timeline
|
from ics.timeline import Timeline
|
||||||
|
|
||||||
|
|
||||||
|
if not isdir("calendars"):
|
||||||
|
mkdir("calendars")
|
||||||
|
|
||||||
URL = "http://adelb.univ-lyon1.fr/jsp/custom/modules/plannings/anonymous_cal.jsp"
|
URL = "http://adelb.univ-lyon1.fr/jsp/custom/modules/plannings/anonymous_cal.jsp"
|
||||||
EMPTY_CALENDAR = "BEGIN:VCALENDAR\r\nPRODID:ics.py - http://git.io/lLljaA\r\nVERSION:2.0\r\nEND:VCALENDAR"
|
EMPTY_CALENDAR = "BEGIN:VCALENDAR\r\nPRODID:ics.py - http://git.io/lLljaA\r\nVERSION:2.0\r\nEND:VCALENDAR"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import datetime
|
from os.path import isfile
|
||||||
import logging
|
|
||||||
from os import mkdir
|
|
||||||
from os.path import isdir, isfile
|
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
from aiogram import Bot, Dispatcher, types
|
from aiogram import Bot, Dispatcher, types
|
||||||
|
@ -14,14 +11,7 @@ from TelegramEDT.EDTcalendar import Calendar
|
||||||
from TelegramEDT.base import Base, User
|
from TelegramEDT.base import Base, User
|
||||||
from TelegramEDT.lang import lang
|
from TelegramEDT.lang import lang
|
||||||
from TelegramEDT.logger import logger
|
from TelegramEDT.logger import logger
|
||||||
|
from TelegramEDT.modules import load_module, load_cmd, unload_cmd
|
||||||
tables = False
|
|
||||||
if not isdir("logs"):
|
|
||||||
mkdir("logs")
|
|
||||||
if not isdir("calendars"):
|
|
||||||
mkdir("calendars")
|
|
||||||
if not isfile("edt.db"):
|
|
||||||
tables = True
|
|
||||||
|
|
||||||
if not isfile("token.ini"):
|
if not isfile("token.ini"):
|
||||||
logger.critical("No token specified, impossible to start the bot !")
|
logger.critical("No token specified, impossible to start the bot !")
|
||||||
|
@ -36,7 +26,7 @@ dp = Dispatcher(bot)
|
||||||
engine = create_engine("sqlite:///edt.db")
|
engine = create_engine("sqlite:///edt.db")
|
||||||
Session = sessionmaker(bind=engine)
|
Session = sessionmaker(bind=engine)
|
||||||
session = Session()
|
session = Session()
|
||||||
if tables:
|
if not isfile("edt.db"):
|
||||||
Base.metadata.create_all(engine)
|
Base.metadata.create_all(engine)
|
||||||
dbL = RLock()
|
dbL = RLock()
|
||||||
|
|
||||||
|
@ -57,7 +47,6 @@ def check_id(user: types.User):
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
from TelegramEDT.modules import load_module, load_cmd, unload_cmd
|
|
||||||
dp.register_message_handler(load_cmd, commands="load")
|
dp.register_message_handler(load_cmd, commands="load")
|
||||||
dp.register_message_handler(unload_cmd, commands="unload")
|
dp.register_message_handler(unload_cmd, commands="unload")
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import logging
|
import logging
|
||||||
from logging import handlers
|
from logging import handlers
|
||||||
|
from os import mkdir
|
||||||
|
from os.path import isdir
|
||||||
|
|
||||||
|
if not isdir("logs"):
|
||||||
|
mkdir("logs")
|
||||||
|
|
||||||
log_format = "{%(levelname)s}[%(asctime)s]: %(name)s | %(message)s"
|
log_format = "{%(levelname)s}[%(asctime)s]: %(name)s | %(message)s"
|
||||||
|
|
||||||
|
|
Reference in a new issue