예제 #1
0
def main():
    global http_server, watcher

    cli_parser = argparse.ArgumentParser(prog='presstatic')
    cli_parser.add_argument('-output',
                            help="relative directory for the generated files.",
                            default='public')
    cli_parser.add_argument(
        '-http',
        metavar='HOST:PORT',
        help="creates an HTTP Server with <directory> as root dir.")
    cli_parser.add_argument('-s3',
                            help="deploy on the specified S3 bucket.",
                            metavar='bucket')
    cli_parser.add_argument('directory',
                            help='directory containing the static website.')

    cli_args = cli_parser.parse_args()

    site_builder = SiteBuilder(cli_args.directory, output=cli_args.output)
    site_builder.build()

    if cli_args.http:
        signal.signal(signal.SIGINT, signal_handler)

        host, port = cli_args.http.split(':')
        root_dir = os.path.join(cli_args.directory, cli_args.output)

        http_server = HttpServer(host, port, root_dir)
        http_server.start()

        watcher = Watcher(site_builder)
        watcher.start()

        with indent(4, quote='>>'):
            puts(
                colored.green("Serving {path} @ {host}:{port}".format(
                    path=root_dir, host=host, port=port)))

        signal.pause()

    elif cli_args.s3:
        s3.S3Storage(cli_args.s3).store(site_builder.output_path)
        puts(help.s3_setup(bucket=cli_args.s3))
예제 #2
0
def main():
    global http_server, watcher

    cli_parser = argparse.ArgumentParser(prog='presstatic')
    cli_parser.add_argument('-output',
                            help="relative directory for the generated files.",
                            default='public')
    cli_parser.add_argument('-http',
                            metavar='HOST:PORT',
                            help="creates an HTTP Server with <directory> as root dir.")
    cli_parser.add_argument('-s3',
                            help="deploy on the specified S3 bucket.",
                            metavar='bucket')
    cli_parser.add_argument('directory',
                            help='directory containing the static website.')

    cli_args = cli_parser.parse_args()

    site_builder = SiteBuilder(cli_args.directory, output=cli_args.output)
    site_builder.build()

    if cli_args.http:
        signal.signal(signal.SIGINT, signal_handler)

        host, port = cli_args.http.split(':')
        root_dir = os.path.join(cli_args.directory, cli_args.output)

        http_server = HttpServer(host, port, root_dir)
        http_server.start()

        watcher = Watcher(site_builder)
        watcher.start()

        with indent(4, quote='>>'):
            puts(colored.green("Serving {path} @ {host}:{port}".format(path=root_dir,
                                                                       host=host,
                                                                       port=port)))

        signal.pause()

    elif cli_args.s3:
        s3.S3Storage(cli_args.s3).store(site_builder.output_path)
        puts(help.s3_setup(bucket=cli_args.s3))
예제 #3
0
def main():
    cli_parser = argparse.ArgumentParser(prog='presstatic')
    cli_parser.add_argument('-http',
                            metavar='HOST:PORT',
                            help="creates an HTTP Server with <directory> as root dir.")
    cli_parser.add_argument('-s3',
                            help="deploy on the specified S3 bucket.",
                            metavar='bucket')
    cli_parser.add_argument('directory',
                            help='directory containing the static website.')

    cli_args = cli_parser.parse_args()

    if cli_args.http:
        host, port = cli_args.http.split(':')
        http_server_on_dir(host, port, cli_args.directory)
    elif cli_args.s3:
        s3.S3Storage(cli_args.s3).store(cli_args.directory)
        puts(help.s3_setup(bucket=cli_args.s3))