<commit_before>#!/usr/bin/env python

# This file parses the command line and calls the appropriate functions

import getopt
import os
import sys

from letsencrypt.client import client
from letsencrypt.client import display
from letsencrypt.client.CONFIG import ACME_SERVER

def main():
    # Check to make sure user is root
    if not os.geteuid() == 0:
        sys.exit("\nOnly root can run letsencrypt.\n")
    # Parse options
    try:
        opts, args = getopt.getopt(sys.argv[1:], "", ["text", "test",
                                                      "view-checkpoints",
                                                      "privkey=", "csr=",
                                                      "server=", "rollback=",
                                                      "revoke", "agree-eula",
                                                      "redirect",
                                                      "no-redirect",
                                                      "help"])
    except getopt.GetoptError as err:
        # print help info and exit
        print str(err)
        usage()
        sys.exit(2)

    server = None
    csr = None
    privkey = None
    curses = True
    names = args
    flag_revoke = False
    redirect = None
    eula = False

    for o, a in opts:
        if o == "--text":
            curses = False
        elif o == "--csr":
            csr = a
        elif o == "--privkey":
            privkey = a
        elif o == "--server":
            server = a
        elif o == "--rollback":
            from letsencrypt.client import configurator, logger
            logger.setLogger(logger.FileLogger(sys.stdout))
            logger.setLogLevel(logger.INFO)
            config = configurator.Configurator()
            config.rollback_checkpoints(a)
            config.restart()
            sys.exit(0)
        elif o == "--view-checkpoints":
            from letsencrypt.client import configurator, logger
            logger.setLogger(logger.FileLogger(sys.stdout))
            logger.setLogLevel(logger.INFO)
            config = configurator.Configurator()
            config.display_checkpoints()
            sys.exit(0)
        elif o == "--revoke":
            # Do Stuff
            flag_revoke = True
        elif o == "--redirect":
            redirect = True
        elif o == "--no-redirect":
            redirect = False
        elif o == "--agree-eula":
            eula = True
        elif o == "--help":
            print_options()
        elif o == "--test":
            #put any temporary tests in here
            continue

    if curses:
        display.setDisplay(display.NcursesDisplay())
    else:
        display.setDisplay(display.FileDisplay(sys.stdout))

    if not server:
        server = ACME_SERVER

    c = client.Client(server, csr, privkey, curses)
    if flag_revoke:
        c.list_certs_keys()
    else:
        c.authenticate(args, redirect, eula)

def usage():
    s = "Available options: --text, --privkey=, --csr=, --server=, "
    s += "--rollback=, --view-checkpoints, --revoke, --agree-eula, --redirect,"
    s += " --no-redirect, --help"
    print str

def print_options():
    print "\nsudo ./letsencrypt.py (default authentication mode using pythondialog)"
    options = [ "privkey= (specify privatekey file to use to generate the certificate)",
                "csr= (Use a specific CSR. If this is specified, privkey " +
                "must also be specified with the correct private key for the CSR)",
                "server (list the ACME CA server address)",
                "revoke (revoke a certificate)",
                "view-checkpoints (Used to view available checkpoints and " +
                "see what configuration changes have been made)",
                "rollback=X (Revert the configuration X number of checkpoints)",
                "redirect (Automatically redirect all HTTP traffic to " +
                "HTTPS for the newly authenticated vhost)",
                "no-redirect (Skip the HTTPS redirect question, " +
                "allowing both HTTP and HTTPS)",
                "agree-eula (Skip the end user agreement screen)" ]
    for o in options:
        print "    --%s" % o
    sys.exit(0)

if __name__ == "__main__":
    main()
<commit_msg>Fixed small typo in usage()<commit_after>#!/usr/bin/env python

# This file parses the command line and calls the appropriate functions

import getopt
import os
import sys

from letsencrypt.client import client
from letsencrypt.client import display
from letsencrypt.client.CONFIG import ACME_SERVER

def main():
    # Check to make sure user is root
    if not os.geteuid() == 0:
        sys.exit("\nOnly root can run letsencrypt.\n")
    # Parse options
    try:
        opts, args = getopt.getopt(sys.argv[1:], "", ["text", "test",
                                                      "view-checkpoints",
                                                      "privkey=", "csr=",
                                                      "server=", "rollback=",
                                                      "revoke", "agree-eula",
                                                      "redirect",
                                                      "no-redirect",
                                                      "help"])
    except getopt.GetoptError as err:
        # print help info and exit
        print str(err)
        usage()
        sys.exit(2)

    server = None
    csr = None
    privkey = None
    curses = True
    names = args
    flag_revoke = False
    redirect = None
    eula = False

    for o, a in opts:
        if o == "--text":
            curses = False
        elif o == "--csr":
            csr = a
        elif o == "--privkey":
            privkey = a
        elif o == "--server":
            server = a
        elif o == "--rollback":
            from letsencrypt.client import configurator, logger
            logger.setLogger(logger.FileLogger(sys.stdout))
            logger.setLogLevel(logger.INFO)
            config = configurator.Configurator()
            config.rollback_checkpoints(a)
            config.restart()
            sys.exit(0)
        elif o == "--view-checkpoints":
            from letsencrypt.client import configurator, logger
            logger.setLogger(logger.FileLogger(sys.stdout))
            logger.setLogLevel(logger.INFO)
            config = configurator.Configurator()
            config.display_checkpoints()
            sys.exit(0)
        elif o == "--revoke":
            # Do Stuff
            flag_revoke = True
        elif o == "--redirect":
            redirect = True
        elif o == "--no-redirect":
            redirect = False
        elif o == "--agree-eula":
            eula = True
        elif o == "--help":
            print_options()
        elif o == "--test":
            #put any temporary tests in here
            continue

    if curses:
        display.setDisplay(display.NcursesDisplay())
    else:
        display.setDisplay(display.FileDisplay(sys.stdout))

    if not server:
        server = ACME_SERVER

    c = client.Client(server, csr, privkey, curses)
    if flag_revoke:
        c.list_certs_keys()
    else:
        c.authenticate(args, redirect, eula)

def usage():
    s = "Available options: --text, --privkey=, --csr=, --server=, "
    s += "--rollback=, --view-checkpoints, --revoke, --agree-eula, --redirect,"
    s += " --no-redirect, --help"
    print s

def print_options():
    print "\nsudo ./letsencrypt.py (default authentication mode using pythondialog)"
    options = [ "privkey= (specify privatekey file to use to generate the certificate)",
                "csr= (Use a specific CSR. If this is specified, privkey " +
                "must also be specified with the correct private key for the CSR)",
                "server (list the ACME CA server address)",
                "revoke (revoke a certificate)",
                "view-checkpoints (Used to view available checkpoints and " +
                "see what configuration changes have been made)",
                "rollback=X (Revert the configuration X number of checkpoints)",
                "redirect (Automatically redirect all HTTP traffic to " +
                "HTTPS for the newly authenticated vhost)",
                "no-redirect (Skip the HTTPS redirect question, " +
                "allowing both HTTP and HTTPS)",
                "agree-eula (Skip the end user agreement screen)" ]
    for o in options:
        print "    --%s" % o
    sys.exit(0)

if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.10314318975552969, 'fraction_numerical': 0.0013969732246798604, 'mean_word_length': 1.5112540192926045, 'pattern_counts': {'":': 26, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5236325', 'n_tokens_mistral': 2243, 'n_tokens_neox': 2194, 'n_words': 698}