Exemplo n.º 1
0
Arquivo: cli.py Projeto: Camr0n/ark
def cmd_serve(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    if not os.path.exists(site.out()):
        sys.exit("Error: cannot locate the site's output directory.")

    os.chdir(site.out())

    try:
        server = http.server.HTTPServer(
            (parser['host'], parser['port']),
            http.server.SimpleHTTPRequestHandler
        )
    except PermissionError:
        sys.exit("Permission error: use 'sudo' to run on a port number below 1024.")

    address = server.socket.getsockname()

    print("-" * 80)
    print("Root: %s" % site.out())
    print("Host: %s"  % address[0])
    print("Port: %s" % address[1])
    print("Stop: Ctrl-C")
    print("-" * 80)

    if parser['browser']:
        webbrowser.open("http://%s:%s" % (parser['host'], parser['port']))

    try:
        server.serve_forever()
    except KeyboardInterrupt:
        print("\n" + "-" * 80 + "Stopping server...\n" + "-" * 80)
        server.server_close()
Exemplo n.º 2
0
def cmd_serve(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    if not os.path.exists(site.out()):
        sys.exit("Error: cannot locate the site's output directory.")

    os.chdir(site.out())

    try:
        server = http.server.HTTPServer((parser['host'], parser['port']),
                                        http.server.SimpleHTTPRequestHandler)
    except PermissionError:
        sys.exit(
            "Permission error: use 'sudo' to run on a port number below 1024.")

    address = server.socket.getsockname()

    print("-" * 80)
    print("Root: %s" % site.out())
    print("Host: %s" % address[0])
    print("Port: %s" % address[1])
    print("Stop: Ctrl-C")
    print("-" * 80)

    if parser['browser']:
        webbrowser.open("http://%s:%s" % (parser['host'], parser['port']))

    try:
        server.serve_forever()
    except KeyboardInterrupt:
        print("\n" + "-" * 80 + "Stopping server...\n" + "-" * 80)
        server.server_close()
Exemplo n.º 3
0
Arquivo: cli.py Projeto: Camr0n/ark
def cmd_clear(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    if not os.path.exists(site.out()):
        sys.exit("Error: cannot locate the site's output directory.")

    utils.cleardir(site.out())
Exemplo n.º 4
0
def cmd_clear(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    if not os.path.exists(site.out()):
        sys.exit("Error: cannot locate the site's output directory.")

    utils.cleardir(site.out())
Exemplo n.º 5
0
Arquivo: cli.py Projeto: Camr0n/ark
def cmd_build(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    if parser['out']: site.setconfig('[out]', parser['out'])
    if parser['src']: site.setconfig('[src]', parser['src'])
    if parser['lib']: site.setconfig('[lib]', parser['lib'])
    if parser['inc']: site.setconfig('[inc]', parser['inc'])

    if parser['theme']:
        site.setconfig('[theme]', site.find_theme(parser['theme']))

    if parser['clear']:
        utils.cleardir(site.out())

    site.setconfig('[flags]', parser.get_args())

    @hooks.register('main')
    def build_callback():
        if os.path.isdir(site.src()):
            build.build_site()
        else:
            sys.exit("Error: cannot locate the site's source directory.")
Exemplo n.º 6
0
def cmd_build(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    if parser['out']: site.setconfig('[out]', parser['out'])
    if parser['src']: site.setconfig('[src]', parser['src'])
    if parser['lib']: site.setconfig('[lib]', parser['lib'])
    if parser['inc']: site.setconfig('[inc]', parser['inc'])

    if parser['theme']:
        site.setconfig('[theme]', site.find_theme(parser['theme']))

    if parser['clear']:
        utils.cleardir(site.out())

    site.setconfig('[flags]', parser.get_args())

    @hooks.register('main')
    def build_callback():
        if os.path.isdir(site.src()):
            build.build_site()
        else:
            sys.exit("Error: cannot locate the site's source directory.")