|
@@ -35,9 +35,7 @@ from email.mime.multipart import MIMEMultipart
|
|
|
from email.mime.text import MIMEText
|
|
|
|
|
|
from lib_stov import subscription
|
|
|
-from lib_stov import configuration
|
|
|
from lib_stov import stov_exceptions
|
|
|
-from lib_stov import database
|
|
|
from lib_stov import helpers
|
|
|
|
|
|
|
|
@@ -48,47 +46,7 @@ ARGUMENTS = PARSER.parse_args()
|
|
|
helpers.create_lock()
|
|
|
CONF = helpers.setup_configuration(ARGUMENTS)
|
|
|
LOGGER = logging.getLogger("stov")
|
|
|
-
|
|
|
-
|
|
|
-# Create the initial connection to the database
|
|
|
-
|
|
|
-if os.access(CONF.dbpath, os.F_OK):
|
|
|
- try:
|
|
|
- DB = database.Db(path=CONF.dbpath, version=CONF.values["db_version"])
|
|
|
- except stov_exceptions.DBConnectionFailedException as error:
|
|
|
- LOGGER.error(error)
|
|
|
- sys.exit(1)
|
|
|
-else:
|
|
|
- try:
|
|
|
- DB = database.Db(path=CONF.dbpath, version=CONF.values["db_version"])
|
|
|
- except stov_exceptions.DBConnectionFailedException as error:
|
|
|
- LOGGER.error(error)
|
|
|
- sys.exit(1)
|
|
|
- else:
|
|
|
- try:
|
|
|
- DB.populate()
|
|
|
- except stov_exceptions.DBWriteAccessFailedException as error:
|
|
|
- LOGGER.error(error)
|
|
|
- sys.exit(1)
|
|
|
- else:
|
|
|
- LOGGER.debug(_("Created initial database tables."))
|
|
|
-
|
|
|
-try:
|
|
|
- CONF = configuration.Conf()
|
|
|
- LOGGER.debug(_("Comparing current and running database version."))
|
|
|
- if not CONF.check_db():
|
|
|
- LOGGER.info(_("Your database needs to be updated, performing update "
|
|
|
- "now."))
|
|
|
- DB.update()
|
|
|
- CONF.values["db_version"] = DB.get_version()
|
|
|
- LOGGER.debug("Opening configuration file.")
|
|
|
- try:
|
|
|
- CONF.write_config()
|
|
|
- except stov_exceptions.ConfigFileWriteErrorException as error:
|
|
|
- LOGGER.error(error)
|
|
|
-except stov_exceptions.DBWriteAccessFailedException as error:
|
|
|
- LOGGER.error(error)
|
|
|
- sys.exit(1)
|
|
|
+DB = helpers.setup_database(CONF)
|
|
|
|
|
|
# youtube-dl is really a dependency but the program will run with limited
|
|
|
# functionality without it so we need to check that here
|