예제 #1
0
파일: sopdsd.py 프로젝트: MegaDiablo/sopds
    def __init__(self):
        self.start_scan=False
        self.cfg=sopdscfg.cfgreader()
        if not (self.cfg.SCAN_DAEMON or self.cfg.HTTP_DAEMON):
           print('Check configuration file. No daemons enabled.')
           sys.exit(0)

        self.logger = logging.getLogger('')
        self.logger.setLevel(self.cfg.LOGLEVEL)
        formatter=logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
        self.fh = logging.FileHandler(self.cfg.SCAND_LOGFILE)
        self.fh.setLevel(self.cfg.LOGLEVEL)
        self.fh.setFormatter(formatter)
        self.logger.addHandler(self.fh)
        self.logger.info('sopdsDaemon __init__()...')

        self.scanner=opdsScanner(self.cfg, self.logger)

        Daemon.__init__(self, self.cfg.PID_FILE, self.cfg.HTTPD_PID_FILE, '/dev/null', self.cfg.SCAND_LOGFILE,self.cfg.HTTPD_LOGFILE,self.cfg.SCAND_LOGFILE,self.cfg.HTTPD_LOGFILE, self.cfg.SCAN_DAEMON, self.cfg.HTTP_DAEMON)
예제 #2
0
파일: sopdsd.py 프로젝트: kale-ru/sopds
    def __init__(self):
        self.start_scan = False
        self.cfg = sopdscfg.cfgreader()
        if not (self.cfg.SCAN_DAEMON or self.cfg.HTTP_DAEMON):
            print('Check configuration file. No daemons enabled.')
            sys.exit(0)

        self.logger = logging.getLogger('')
        self.logger.setLevel(self.cfg.LOGLEVEL)
        formatter = logging.Formatter(
            '%(asctime)s %(levelname)-8s %(message)s')
        self.fh = logging.FileHandler(self.cfg.SCAND_LOGFILE)
        self.fh.setLevel(self.cfg.LOGLEVEL)
        self.fh.setFormatter(formatter)
        self.logger.addHandler(self.fh)
        self.logger.info('sopdsDaemon __init__()...')

        self.scanner = opdsScanner(self.cfg, self.logger)

        Daemon.__init__(self, self.cfg.PID_FILE, self.cfg.HTTPD_PID_FILE,
                        '/dev/null', self.cfg.SCAND_LOGFILE,
                        self.cfg.HTTPD_LOGFILE, self.cfg.SCAND_LOGFILE,
                        self.cfg.HTTPD_LOGFILE, self.cfg.SCAN_DAEMON,
                        self.cfg.HTTP_DAEMON)
예제 #3
0
      sopds.setUser(user)
      sopds.make_response()
   else:
       sopds.set_response_status('401 Unauthorized')
       sopds.add_response_header([('WWW-Authenticate', 'Basic realm=\"%s\"'%cfg.SITE_TITLE)])
       sopds.add_response_header([('Content-type', 'text/html')])

   start_response(sopds.get_response_status(), sopds.get_response_headers())
   return sopds.get_response_body()

def start_server(config):
    global sopds
    global cfg

    cfg=config
    zipf.ZIP_CODEPAGE=cfg.ZIP_CODEPAGE
    sopds = sopdscli.opdsClient(cfg,sopdscli.modeINT)

    try:
       httpd = make_server(cfg.BIND_ADDRESS, cfg.PORT, app)
       print('Started Simple OPDS server on port ' , cfg.PORT)
       httpd.serve_forever()
    except KeyboardInterrupt:
       print('^C received, shutting down the web server')
       httpd.socket.close()


if __name__ == "__main__":
    config=sopdscfg.cfgreader()
    start_server(config)
예제 #4
0
파일: sopdsweb.py 프로젝트: SokoloffA/sopds
def start_server(config = None):
    if not config:
        config=sopdscfg.cfgreader()

    server = WebServer(config)
    server.start()
예제 #5
0
파일: sopdsd.py 프로젝트: SokoloffA/sopds
        self.stdout  = self.cfg.WEB_LOGFILE
        self.stderr  = self.cfg.WEB_LOGFILE
        self.enabled = self.cfg.WEB_DAEMON


    #***************************************
    #
    #***************************************
    def _run(self):
        sopdsweb.start_server(self.cfg)

#*******************************************
#
#*******************************************
if __name__ == "__main__":
    cfg=sopdscfg.cfgreader()

    daemonTool = DaemonTool(cfg)

    if len(sys.argv) == 2:

        if 'start' == sys.argv[1]:
            daemonTool.start()

        elif 'stop' == sys.argv[1]:
            daemonTool.stop()

        elif 'restart' == sys.argv[1]:
            daemonTool.restart()

        elif 'status' == sys.argv[1]:
예제 #6
0
파일: sopds-scan.py 프로젝트: kale-ru/sopds
    parser.add_option('-v',
                      '--verbose',
                      action='store_true',
                      dest='verbose',
                      default=False,
                      help='Enable verbose output')
    parser.add_option('-c',
                      '--config',
                      dest='configfile',
                      default='',
                      help='Config file pargh')
    (options, arguments) = parser.parse_args()
    VERBOSE = options.verbose
    CFG_FILE = options.configfile

    if CFG_FILE == '': cfg = sopdscfg.cfgreader()
    else: cfg = sopdscfg.cfgreader(CFG_FILE)

    logger = logging.getLogger('')
    logger.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')

    if cfg.LOGLEVEL != logging.NOTSET:
        # Создаем обработчик для записи логов в файл
        fh = logging.FileHandler(cfg.LOGFILE)
        fh.setLevel(cfg.LOGLEVEL)
        fh.setFormatter(formatter)
        logger.addHandler(fh)

    if VERBOSE:
        # Создадим обработчик для вывода логов на экран с максимальным уровнем вывода
예제 #7
0
import logging
import sopdscfg
from sopdscan import opdsScanner
from optparse import OptionParser
from sys import argv

if (__name__=="__main__"):
    parser=OptionParser(conflict_handler="resolve", version="sopds-scan.py. Version "+sopdscfg.VERSION, add_help_option=True, usage='sopds-scan.py [options]',description='sopds-scan.py: Simple OPDS Scanner - programm for scan your e-books directory and store data to MYSQL database.')
    parser.add_option('-v','--verbose', action='store_true', dest='verbose', default=False, help='Enable verbose output')
    parser.add_option('-c','--config',dest='configfile',default='',help='Config file pargh')
    (options,arguments)=parser.parse_args()
    VERBOSE=options.verbose
    CFG_FILE=options.configfile

    if CFG_FILE=='': cfg=sopdscfg.cfgreader()
    else: cfg=sopdscfg.cfgreader(CFG_FILE)

    logger = logging.getLogger('')
    logger.setLevel(logging.DEBUG)
    formatter=logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')

    if cfg.LOGLEVEL!=logging.NOTSET:
       # Создаем обработчик для записи логов в файл
       fh = logging.FileHandler(cfg.LOGFILE)
       fh.setLevel(cfg.LOGLEVEL)
       fh.setFormatter(formatter)
       logger.addHandler(fh)

    if VERBOSE:
       # Создадим обработчик для вывода логов на экран с максимальным уровнем вывода