Ejemplo n.º 1
0
Archivo: app.py Proyecto: shiznu/GetCM
    def __init__(self):
        handlers = [
            (r"/", BrowseHandler),
            (r"/get/(.*)\.md5sum", SumHandler),
            (r"/get/(.*)\.zip", ZipHandler),
            (r"/get/(.*/CHANGES.txt)", tornado.web.StaticFileHandler, {"path": "/opt/www/mirror"}),
            (r"/get/(.*)", Base62Handler),
            (r"/rss", RssHandler),
            (r"/api", ApiHandler),
            (r"/mirror", MirrorApplicationHandler),
        ]

        settings = dict(
            debug=options.debug
        )
        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession
        template_path = os.path.join(os.path.dirname(__file__), "templates")
        self.lookup = TemplateLookup(directories=[template_path])
        self.activebuilds = ActiveBuilds()
        #self.stats = Stats()

        self.mirrorpool = WeightedChoice((
            ('http://oss.reflected.net/%s', 1000),
            ('http://mirror.sea.tdrevolution.net/%s', 500),
            ('http://cm.sponsored.cb-webhosting.de/%s', 50),
            ('http://mirror.netcologne.de/cyanogenmod/%s', 75),
        ))
Ejemplo n.º 2
0
Archivo: app.py Proyecto: ciwrl/GetCM
    def __init__(self):
        handlers = [
            (r"/", BrowseHandler),
            (r"/get/(.*)\.md5sum", SumHandler),
            (r"/get/(.*)\.zip", ZipHandler),
            (r"/get/(.*/CHANGES.txt)", tornado.web.StaticFileHandler, {"path": "/opt/www/mirror"}),
            (r"/get/(.*)", Base62Handler),
            (r"/rss", RssHandler),
            (r"/api", ApiHandler),
            (r"/mirror", MirrorApplicationHandler),
            (r"/static/(.*)", tornado.web.StaticFileHandler, {"path": os.path.join(os.path.dirname(__file__), "static")}),
        ]

        settings = dict(
            debug=options.debug,
        )
        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession
        template_path = os.path.join(os.path.dirname(__file__), "templates")
        self.lookup = TemplateLookup(directories=[template_path], filesystem_checks=False)

        self.mirrorpool = WeightedChoice((
            ('http://mirror.slc.cyanogenmod.org/%s', 2000),
            ('http://oss.reflected.net/%s', 1000),
            ('http://mirror.symnds.com/software/cm/%s', 1000),
            ('http://mirror.netcologne.de/cyanogenmod/%s', 200),
            ('http://cm.sponsored.cb-webhosting.de/%s', 25),
            ('http://mirror.i3d.net/pub/cyanogenmod/%s', 50),
        ))
Ejemplo n.º 3
0
    def __init__(self):
        handlers = [
            (r"/submit", SubmitHandler),
            (r"/api", ApiHandler),
        ]

        settings = {
            'debug': options.debug,
        }

        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession

        # Publish Key
        self.publish_key = config.get('socketio', 'publish_key')

        # Queues
        self.queues = {'database': Queue()}

        # Background threads
        self.threads = {'database': DatabaseThread(self.queues['database'])}

        for thread in self.threads.itervalues():
            thread.start()
Ejemplo n.º 4
0
    def __init__(self):
        handlers = [
            (r"/", BrowseHandler),
            (r"/get/(.*)\.md5sum", SumHandler),
            (r"/get/(.*)\.zip", ZipHandler),
            (r"/get/(.*/CHANGES.txt)", tornado.web.StaticFileHandler, {
                "path": "/opt/www/mirror"
            }),
            (r"/get/(.*)", Base62Handler),
            (r"/api", ApiHandler),
            (r"/mirror", MirrorApplicationHandler),
            (r"/static/(.*)", tornado.web.StaticFileHandler, {
                "path": os.path.join(os.path.dirname(__file__), "static")
            }),
        ]

        settings = dict(debug=options.debug, )
        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession
        template_path = os.path.join(os.path.dirname(__file__), "templates")
        self.lookup = TemplateLookup(directories=[template_path],
                                     filesystem_checks=False)

        self.mirrorpool = WeightedChoice((('/%s', 1000), ))
Ejemplo n.º 5
0
    def __init__(self):
        handlers = [
            (r"/submit", SubmitHandler),
            (r"/api", ApiHandler),
        ]

        settings = {
            'debug': options.debug,
        }

        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession

        # Publish Key
        self.publish_key = config.get('socketio', 'publish_key')

        # Queues
        self.queues = {
            'database': Queue()
        }

        # Background threads
        self.threads = {
            'database': DatabaseThread(self.queues['database'])
        }

        for thread in self.threads.itervalues():
            thread.start()
Ejemplo n.º 6
0
    def __init__(self):
        handlers = [
            (r"/", BrowseHandler),
            (r"/get/(.*)\.md5sum", SumHandler),
            (r"/get/(.*)\.zip", ZipHandler),
            (r"/get/(.*/CHANGES.txt)", tornado.web.StaticFileHandler, {"path": "/opt/www/mirror"}),
            (r"/get/(.*)", Base62Handler),
            (r"/api", ApiHandler),
            (r"/mirror", MirrorApplicationHandler),
            (r"/static/(.*)", tornado.web.StaticFileHandler, {"path": os.path.join(os.path.dirname(__file__), "static")}),
        ]

        settings = dict(
            debug=options.debug,
        )
        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession
        template_path = os.path.join(os.path.dirname(__file__), "templates")
        self.lookup = TemplateLookup(directories=[template_path], filesystem_checks=False)

        self.mirrorpool = WeightedChoice((
            ('http://mirror.galliumos.org/%s', 1000),
        ))
Ejemplo n.º 7
0
Archivo: app.py Proyecto: kingfs/GetCM
    def __init__(self):
        handlers = [
            (r"/", BrowseHandler),
            (r"/get/(.*)\.md5sum", SumHandler),
            (r"/get/(.*)\.zip", ZipHandler),
            (r"/get/(.*)", Base62Handler),
            (r"/rss", RssHandler),
        ]

        settings = dict(
            debug=options.debug
        )
        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession
        template_path = os.path.join(os.path.dirname(__file__), "templates")
        self.lookup = TemplateLookup(directories=[template_path])
        self.activebuilds = ActiveBuilds()
        self.stats = Stats()

        self.mirrorpool = WeightedChoice((
            ('http://mirror.sea.tdrevolution.net/cm/%s', 800),
            ('http://oss.reflected.net/cm/%s', 1000),
        ))
Ejemplo n.º 8
0
    def __init__(self):
        Dispatcher.process_update = process_update

        self._updater = Updater(TOKEN)

        init_database()
        self._init_handlers()

        log_format = '%(asctime)s - %(levelname)s - %(name)s - %(message)s'
        logging.basicConfig(format=log_format, level=logging.WARNING)
Ejemplo n.º 9
0
 def init_database(self):
     u"""
     初始化数据库。
     """
     print
     print "Init Database will kill all data. Are you sure?"
     print
     print "Type INIT_YES to continue.",
     if raw_input() == "INIT_YES":
         print "Init Database start ..."
         model.init_database()
         print "Init Database DONE."
     print "All DONE."
Ejemplo n.º 10
0
def init_database():
    u'''
    初始化数据库。
    '''
    print
    print 'Init Database will kill all data. Are you sure?'
    print
    print 'Type INIT_YES to continue.',
    if raw_input() == 'INIT_YES':
        print 'Init Database start ...'
        model.init_database()
        print 'Init Database DONE.'
    print 'All DONE.'
Ejemplo n.º 11
0
def init_database():
    u'''
    初始化数据库。
    '''
    print
    print 'Init Database will kill all data. Are you sure?'
    print
    print 'Type INIT_YES to continue.',
    if raw_input() == 'INIT_YES' :
        print 'Init Database start ...'
        model.init_database()
        print 'Init Database DONE.'
    print 'All DONE.'
Ejemplo n.º 12
0
 def init_database(self):
     u'''
     初始化数据库。
     '''
     print
     print 'Init Database will kill all data. Are you sure?'
     print
     print 'Type INIT_YES to clear all data in mysql.',
     if raw_input() == 'INIT_YES':
         print 'Init mysql start ...'
         model.init_database()
         print 'Init mysql DONE.'
     print 'Type INIT_YES to clear all data in redis.'
     if raw_input() == 'INIT_YES':
         print 'Init redis start ...'
         manager.ch.flushdb()
         print 'Init redis DONE.'
     print 'All DONE.'
Ejemplo n.º 13
0
 def init_database(self):
     u'''
     初始化数据库。
     '''
     print
     print 'Init Database will kill all data. Are you sure?'
     print
     print 'Type INIT_YES to clear all data in mysql.',
     if raw_input() == 'INIT_YES' :
         print 'Init mysql start ...'
         model.init_database()
         print 'Init mysql DONE.'
     print 'Type INIT_YES to clear all data in redis.'
     if raw_input() == 'INIT_YES' :
         print 'Init redis start ...'
         manager.ch.flushdb()
         print 'Init redis DONE.'
     print 'All DONE.'
Ejemplo n.º 14
0
def main():
    setproctitle(PROC_TITLE)
    logging.basicConfig(filename=LOG_ERROR_FILE, level=logging.ERROR)

    request_keys = {"proxy_url": PROXY_URL}
    updater = Updater(TOKEN, request_kwargs=request_keys)

    init_database()
    chat_service.init_bot(updater.job_queue)

    dp = updater.dispatcher
    dp.add_handler(CommandHandler("set", chat_service.set_user,
                                  pass_args=True,
                                  pass_job_queue=True))
    dp.add_handler(CommandHandler("help", chat_service.help_command))
    dp.add_handler(CommandHandler("me", chat_service.my_id_command))

    updater.start_polling()
    updater.idle()
Ejemplo n.º 15
0
    def __init__(self):
        handlers = [
            (r"/", BrowseHandler),
            (r"/get/(.*)\.md5sum", SumHandler),
            (r"/get/(.*)\.zip", ZipHandler),
            (r"/get/(.*/CHANGES.txt)", tornado.web.StaticFileHandler, {
                "path": "/opt/www/mirror"
            }),
            (r"/get/(.*)", Base62Handler),
            (r"/rss", RssHandler),
            (r"/api", ApiHandler),
            (r"/mirror", MirrorApplicationHandler),
            (r"/static/(.*)", tornado.web.StaticFileHandler, {
                "path": os.path.join(os.path.dirname(__file__), "static")
            }),
        ]

        settings = dict(debug=options.debug, )
        super(Application, self).__init__(handlers, **settings)

        config = ConfigParser()
        config.readfp(open(options.config))

        # One global connection
        init_database(create_engine(config.get('database', 'uri')))
        self.db = DBSession
        template_path = os.path.join(os.path.dirname(__file__), "templates")
        self.lookup = TemplateLookup(directories=[template_path],
                                     filesystem_checks=False)

        self.mirrorpool = WeightedChoice((
            ('http://mirror.slc.cyanogenmod.org/%s', 2000),
            ('http://oss.reflected.net/%s', 1000),
            ('http://mirror.symnds.com/software/cm/%s', 1000),
            ('http://mirror.netcologne.de/cyanogenmod/%s', 200),
            #('http://mirror.sea.tdrevolution.net/%s', 50),
            ('http://cm.sponsored.cb-webhosting.de/%s', 25),
            ('http://mirror.i3d.net/pub/cyanogenmod/%s', 50),
        ))
Ejemplo n.º 16
0
import os.path
from sys import argv, exit

from qtpy.QtWidgets import QApplication

from controller import RegisterController
from controller.main_controller import MainController
from model import init_database, Account
from utils import get_app_folder
from view import RegisterDialog
from view.main_window import MainWindow

if __name__ == '__main__':
    app = QApplication(argv)
    init_database(os.path.join(get_app_folder(), "database.sqlite"))

    accounts = Account.select()

    if not accounts:
        register_controller = RegisterController()
        register_dialog = RegisterDialog(register_controller)
        register_dialog.exec()

    controller = MainController()
    window = MainWindow(controller)

    exit(app.exec_())
Ejemplo n.º 17
0
import os

from model import init_database, Post
from flask import render_template, Flask, send_from_directory, request

init_database()

app = Flask(__name__, static_folder='static')


@app.route('/robots.txt')
def static_from_root():
    return send_from_directory(app.static_folder, request.path[1:])


@app.route("/")
def index():
    return render_template("login.html")


@app.route("/boards/<id>")
def board(id):
    posts = []

    if int(id) == 1:
        posts = Post.select()

    return render_template("board.html", posts=posts)


if __name__ == "__main__":