Beispiel #1
0
def main():

    parser = ArgumentParser(description="a blog comment hosting service")
    subparser = parser.add_subparsers(help="commands", dest="command")

    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s ' + dist.version)
    parser.add_argument("-c",
                        dest="conf",
                        default="/etc/isso.conf",
                        metavar="/etc/isso.conf",
                        help="set configuration file")

    imprt = subparser.add_parser('import', help="import Disqus XML export")
    imprt.add_argument("dump", metavar="FILE")

    serve = subparser.add_parser("run", help="run server")

    args = parser.parse_args()
    conf = Config.load(args.conf)

    if args.command == "import":
        conf.set("guard", "enabled", "off")
        migrate.disqus(db.SQLite3(conf.get('general', 'dbpath'), conf),
                       args.dump)
        sys.exit(0)

    run_simple(conf.get('server', 'host'),
               conf.getint('server', 'port'),
               make_app(conf),
               threaded=True,
               use_reloader=conf.getboolean('server', 'reload'))
Beispiel #2
0
def main():

    parser = ArgumentParser(description="a blog comment hosting service")
    subparser = parser.add_subparsers(help="commands", dest="command")

    parser.add_argument('--version', action='version', version='%(prog)s ' + dist.version)
    parser.add_argument("-c", dest="conf", default="/etc/isso.conf",
            metavar="/etc/isso.conf", help="set configuration file")

    imprt = subparser.add_parser('import', help="import Disqus XML export")
    imprt.add_argument("dump", metavar="FILE")
    imprt.add_argument("-n", "--dry-run", dest="dryrun", action="store_true",
                       help="perform a trial run with no changes made")

    serve = subparser.add_parser("run", help="run server")

    args = parser.parse_args()
    conf = Config.load(args.conf)

    if args.command == "import":
        xxx = tempfile.NamedTemporaryFile()
        dbpath = conf.get("general", "dbpath") if not args.dryrun else xxx.name

        conf.set("guard", "enabled", "off")
        migrate.disqus(db.SQLite3(dbpath, conf), args.dump)
        sys.exit(0)

    if not any(conf.getiter("general", "host")):
        logger.error("No website(s) configured, Isso won't work.")
        sys.exit(1)

    if conf.get("server", "listen").startswith("http://"):
        host, port, _ = urlsplit(conf.get("server", "listen"))
        try:
            from gevent.pywsgi import WSGIServer
            WSGIServer((host, port), make_app(conf)).serve_forever()
        except ImportError:
            run_simple(host, port, make_app(conf), threaded=True,
                       use_reloader=conf.getboolean('server', 'reload'))
    else:
        sock = conf.get("server", "listen").partition("unix://")[2]
        try:
            os.unlink(sock)
        except OSError as ex:
            if ex.errno != errno.ENOENT:
                raise
        wsgi.SocketHTTPServer(sock, make_app(conf)).serve_forever()
Beispiel #3
0
def test_disqus():

    xml = join(dirname(__file__), "disqus.xml")
    xxx = tempfile.NamedTemporaryFile()

    db = SQLite3(xxx.name, Config.load(None))
    disqus(db, xml)

    assert db.threads["/"]["title"] == "Hello, World!"
    assert db.threads["/"]["id"] == 1


    a = db.comments.get(1)

    assert a["author"] == "peter"
    assert a["email"] == "*****@*****.**"

    b = db.comments.get(2)
    assert b["parent"] == a["id"]
Beispiel #4
0
def main():

    parser = ArgumentParser(description="a blog comment hosting service")
    subparser = parser.add_subparsers(help="commands", dest="command")

    parser.add_argument('--version', action='version', version='%(prog)s ' + dist.version)
    parser.add_argument("-c", dest="conf", default="/etc/isso.conf",
            metavar="/etc/isso.conf", help="set configuration file")

    imprt = subparser.add_parser('import', help="import Disqus XML export")
    imprt.add_argument("dump", metavar="FILE")

    serve = subparser.add_parser("run", help="run server")

    args = parser.parse_args()
    conf = Config.load(args.conf)

    if args.command == "import":
        conf.set("guard", "enabled", "off")
        migrate.disqus(db.SQLite3(conf.get('general', 'dbpath'), conf), args.dump)
        sys.exit(0)

    run_simple(conf.get('server', 'host'), conf.getint('server', 'port'), make_app(conf),
               threaded=True, use_reloader=conf.getboolean('server', 'reload'))