# Path: app/config/cplog.py
# class CPLog():
# 
#     context = ''
# 
#     def __init__(self, context = ''):
#         self.context = context
#         self.logger = cherrypy.log
# 
#     def info(self, msg):
#         self.log(msg, severity = logging.INFO)
# 
#     def debug(self, msg):
#         self.log(msg, severity = logging.DEBUG)
# 
#     def error(self, msg):
#         self.log(msg, severity = logging.ERROR)
# 
#     def log(self, msg = '', severity = logging.INFO):
#         try:
#             self.logger.error(msg = app.latinToAscii(msg), context = self.context, severity = severity)
#         except:
#             self.logger.error(msg = msg, context = self.context, severity = severity)
# 
#     def config(self, logPath, debug = False):
# 
#         level = logging.DEBUG if debug else logging.INFO
# 
#         # Overwrite functions
#         self.logger.time = self.time
#         self.logger.error = self.logError
#         self.logger.access = self.access
# 
#         # Set screen and level
#         self.logger.screen = debug
#         self.logger.error_log.setLevel(level)
# 
#         # Create log dir
#         if not os.path.isdir(logPath):
#             os.mkdir(logPath)
# 
#         self.logger.error_file = ""
# 
#         # Create RotatingFileHandler
#         h = handlers.RotatingFileHandler(os.path.join(logPath, 'CouchPotato.log'), 'a', 500000, 4)
#         h.setLevel(level)
#         h.setFormatter(logging.Formatter('%(asctime)s %(levelname)-5.5s %(message)s', '%H:%M:%S'))
#         self.logger.error_log.addHandler(h)
# 
#     def access(self):
#         pass
# 
#     def logError(self, msg = '', context = '', severity = logging.INFO, traceback = False):
# 
#         if traceback:
#             msg += _cperror.format_exc()
# 
#         context = context if context else self.context
#         self.logger.error_log.log(severity, '[%+25.25s] %s' % (context[-25:], msg))
# 
#     def time(self):
#         now = datetime.datetime.now()
#         return ('[%02d:%02d:%02d]' % (now.hour, now.minute, now.second))


from app.config.cplog import CPLog
from sqlalchemy import create_engine
from sqlalchemy.exc import OperationalError, NoSuchTableError
from sqlalchemy.ext.sqlsoup import SqlSoup
from sqlalchemy.orm import mapper, relation, scoped_session
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.schema import MetaData, Table, Column, ForeignKey
from sqlalchemy.sql.expression import and_, desc
from sqlalchemy.types import Integer, DateTime, String, Boolean, Text
    from app.lib.qualities import Qualities
import datetime
import os
import sys
import app.config
    def __repr__(self):
        return "<moviequeue: %s active=%s complete=%s quality=%s" % (self.Movie.name, self.active, self.complete, self.qualityType)

class MovieETA(object):
    dvd = 0
    theater = 0
    bluray = 0
    lastCheck = 0

    def __repr__(self):
        return "<movieeta: %s" % self.videoEtaId

class MovieExtra(object):
    movieId = None
    name = None
    def __repr__(self):
        return "<movieextra: %s, %s" % (self.name, self.value)

class RenameHistory(object):
    def __repr__(self):
        return "<renamehistory: %s" % self.movieQueue

class History(object):
    movie = None
    status = None
    value = None

    def __repr__(self):
        return "<history: value=%s status=%s" % (self.value, self.status)


# Path: app/config/cplog.py
# class CPLog():
# 
#     context = ''
# 
#     def __init__(self, context = ''):
#         self.context = context
#         self.logger = cherrypy.log
# 
#     def info(self, msg):
#         self.log(msg, severity = logging.INFO)
# 
#     def debug(self, msg):
#         self.log(msg, severity = logging.DEBUG)
# 
#     def error(self, msg):
#         self.log(msg, severity = logging.ERROR)
# 
#     def log(self, msg = '', severity = logging.INFO):
#         try:
#             self.logger.error(msg = app.latinToAscii(msg), context = self.context, severity = severity)
#         except:
#             self.logger.error(msg = msg, context = self.context, severity = severity)
# 
#     def config(self, logPath, debug = False):
# 
#         level = logging.DEBUG if debug else logging.INFO
# 
#         # Overwrite functions
#         self.logger.time = self.time
#         self.logger.error = self.logError
#         self.logger.access = self.access
# 
#         # Set screen and level
#         self.logger.screen = debug
#         self.logger.error_log.setLevel(level)
# 
#         # Create log dir
#         if not os.path.isdir(logPath):
#             os.mkdir(logPath)
# 
#         self.logger.error_file = ""
# 
#         # Create RotatingFileHandler
#         h = handlers.RotatingFileHandler(os.path.join(logPath, 'CouchPotato.log'), 'a', 500000, 4)
#         h.setLevel(level)
#         h.setFormatter(logging.Formatter('%(asctime)s %(levelname)-5.5s %(message)s', '%H:%M:%S'))
#         self.logger.error_log.addHandler(h)
# 
#     def access(self):
#         pass
# 
#     def logError(self, msg = '', context = '', severity = logging.INFO, traceback = False):
# 
#         if traceback:
#             msg += _cperror.format_exc()
# 
#         context = context if context else self.context
#         self.logger.error_log.log(severity, '[%+25.25s] %s' % (context[-25:], msg))
# 
#     def time(self):
#         now = datetime.datetime.now()
#         return ('[%02d:%02d:%02d]' % (now.hour, now.minute, now.second))


# Path: app/config/db.py
from app.config.cplog import CPLog
from sqlalchemy import create_engine
from sqlalchemy.exc import OperationalError, NoSuchTableError
from sqlalchemy.ext.sqlsoup import SqlSoup
from sqlalchemy.orm import mapper, relation, scoped_session
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.schema import MetaData, Table, Column, ForeignKey
from sqlalchemy.sql.expression import and_, desc
from sqlalchemy.types import Integer, DateTime, String, Boolean, Text
    from app.lib.qualities import Qualities
import datetime
import os
import sys
import app.config

    def __repr__(self):
        return "<moviequeue: %s active=%s complete=%s quality=%s" % (self.Movie.name, self.active, self.complete, self.qualityType)

class MovieETA(object):
    dvd = 0
    theater = 0
    bluray = 0
    lastCheck = 0

    def __repr__(self):
        return "<movieeta: %s" % self.videoEtaId

class MovieExtra(object):
    movieId = None
    name = None
    def __repr__(self):
        return "<movieextra: %s, %s" % (self.name, self.value)

class RenameHistory(object):
    def __repr__(self):
        return "<renamehistory: %s" % self.movieQueue

class History(object):
    movie = None
    status = None
    value = None

    def __repr__(self):
        return "<history: value=%s status=%s" % (self.value, self.status)


class SubtitleHistory(object):