Example #1
0
def runserver(port=8080, address="127.0.0.1"):
    port = int(port)
    db.generate_mapping()
    tornado.httpserver.HTTPServer(Application(),
                                  xheaders=True).listen(port, address)
    print("App started. Listening on {}:{}".format(address, port))
    tornado.ioloop.IOLoop.instance().start()
Example #2
0
File: app.py Project: wbbim/collipa
def runserver(port=8080, address="127.0.0.1"):
    port = int(port)
    db.generate_mapping()
    tornado.httpserver.HTTPServer(Application(),
                                  xheaders=True).listen(port, address)
    print("App started. Listenning on {}:{}".format(address, port))
    tornado.ioloop.IOLoop.instance().start()
Example #3
0
def main(argv):
    try:
        opts, args = getopt.getopt(argv, "", ["install", "init"])
    except getopt.GetoptError:
        print("参数错误")
        sys.exit(2)

    for opt, val in opts:
        if opt == "--init":
            # create tables
            from collipa.models import db
            db.generate_mapping(create_tables=True)
            init_node()
            print("数据库表初始化成功")
Example #4
0
def main(argv):
    try:
        opts, args = getopt.getopt(
            argv, "", ["install", "init", "iwanttodropdatabase", 'merge'])
    except getopt.GetoptError:
        print("参数错误")
        sys.exit(2)

    for opt, val in opts:
        if opt == '--merge':
            merge()
            print('merge 成功!')

        if opt == "--init":
            m = MySQLdb.connect(host=config.db_host,
                                user=config.db_user,
                                passwd=config.db_pass)
            c = m.cursor()

            # create database
            try:
                c.execute("create database %s" % config.db_name)
                c.execute(
                    "grant all privileges on %s.* to '%s'@'localhost' identified by '%s'"
                    % (config.db_name, config.db_user, config.db_pass))
                c.execute("flush privileges")

                c.close()
                m.commit()
                m.close()
            except Exception:
                pass

            # create tables
            from collipa.models import db
            db.generate_mapping(create_tables=True)
            init_node()
            print("数据库表初始化成功")
Example #5
0
def main(argv):
    try:
        opts, args = getopt.getopt(argv, "", ["install", "init",
                                              "iwanttodropdatabase", 'merge'])
    except getopt.GetoptError:
        print("参数错误")
        sys.exit(2)

    for opt, val in opts:
        if opt == '--merge':
            merge()
            print('merge 成功!')

        if opt == "--init":
            m = MySQLdb.connect(host=config.db_host, user=config.db_user,
                                passwd=config.db_pass)
            c = m.cursor()

            # create database
            try:
                c.execute("create database %s" % config.db_name)
                c.execute("grant all privileges on %s.* to '%s'@'localhost' identified by '%s'" %
                          (config.db_name, config.db_user, config.db_pass))
                c.execute("flush privileges")

                c.close()
                m.commit()
                m.close()
            except Exception:
                pass

            # create tables
            from collipa.models import db
            db.generate_mapping(create_tables=True)
            init_node()
            print("数据库表初始化成功")
Example #6
0
# coding: utf-8

import sys
import imp
imp.reload(sys)
sys.setdefaultencoding('utf-8')

from pony import orm
from IPython import embed
from collipa.models import db


@orm.db_session
def runshell():
    embed()

if __name__ == '__main__':
    db.generate_mapping()
    runshell()
Example #7
0
# coding: utf-8

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

from pony import orm
from IPython import embed
from collipa.models import db


@orm.db_session
def runshell():
    embed()


if __name__ == '__main__':
    db.generate_mapping()
    runshell()