Example #1
0
def main(args):
    try:
        opts, args = getopt.getopt(args, "ha", [
            "help", "all", "force", "uptodate", "dry-run", "logging",
            "logfile=", "debug", "debug-simpletal"
        ])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    if (len(args) == 0):
        usage()
        sys.exit(2)

    options = {}
    enableLogging = 0
    pubtalLogging = logging.INFO
    simpletalLogging = logging.INFO
    logFile = "uploadSite.log"
    for opt, arg in opts:
        if (opt == '-h' or opt == '--help'):
            usage()
            sys.exit(0)
        elif (opt == '-a' or opt == '--all'):
            options['allFiles'] = 1
        elif (opt == "--logging"):
            enableLogging = 1
        elif (opt == "--logfile"):
            logFile = arg
        elif (opt == '--force'):
            options['forceUpload'] = 1
        elif (opt == '--uptodate'):
            options['markFilesUpToDate'] = 1
        elif (opt == '--dry-run'):
            options['dry-run'] = 1
        elif (opt == '--debug'):
            pubtalLogging = logging.DEBUG
            enableLogging = 1

    if (LOGGING_EXISTS):
        root = logging.getLogger()
        if (enableLogging):
            handler = logging.FileHandler(logFile)
            root.addHandler(handler)
            handler.setFormatter(
                logging.Formatter(
                    '%(asctime)s %(levelname)s  %(name)s - %(message)s'))
            root.setLevel(pubtalLogging)
            talLogger = logging.getLogger("simpleTAL")
            talLogger.setLevel(simpletalLogging)
            talesLogger = logging.getLogger("simpleTALES")
            talesLogger.setLevel(simpletalLogging)
        else:
            root.addHandler(logging.StreamHandler())
            root.addFilter(SiteUtils.BlockFilter())
            logging.disable(logging.CRITICAL)

    update = UploadSite(args[0])
    update.uploadSite(args[1:], options)
Example #2
0
def main(args):
    try:
        opts, leftargs = getopt.getopt(args, "ha", [
            "help", "all", "class=", "logging", "logfile=", "debug",
            "debug-simpletal"
        ])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    if (len(args) == 0):
        usage()
        sys.exit(2)

    enableLogging = 0
    options = {}
    pubtalLogging = logging.INFO
    simpletalLogging = logging.INFO
    logFile = "updateSite.log"
    for opt, arg in opts:
        if (opt == '-h' or opt == '--help'):
            usage()
            sys.exit(0)
        elif (opt == "--all" or opt == "-a"):
            options['buildAllClasses'] = 1
        elif (opt == "--class"):
            options['classes'] = arg
        elif (opt == "--logging"):
            enableLogging = 1
        elif (opt == "--logfile"):
            logFile = arg
        elif (opt == '--debug'):
            pubtalLogging = logging.DEBUG
            enableLogging = 1
        elif (opt == '--debug-simpletal'):
            simpletalLogging = logging.DEBUG
            enableLogging = 1

    if (LOGGING_EXISTS):
        root = logging.getLogger()
        if (enableLogging):
            handler = logging.FileHandler(logFile)
            root.addHandler(handler)
            handler.setFormatter(
                logging.Formatter(
                    '%(asctime)s %(levelname)s  %(name)s - %(message)s'))
            root.setLevel(pubtalLogging)
            talLogger = logging.getLogger("simpleTAL")
            talLogger.setLevel(simpletalLogging)
            talesLogger = logging.getLogger("simpleTALES")
            talesLogger.setLevel(simpletalLogging)
        else:
            root.addHandler(logging.StreamHandler())
            root.addFilter(SiteUtils.BlockFilter())
            logging.disable(logging.CRITICAL)

    if (len(leftargs) == 0):
        usage()
        sys.exit(1)
    elif (len(leftargs) == 1):
        update = UpdateSite(leftargs[0], path=None, options=options)
    else:
        update = UpdateSite(leftargs[0], path=leftargs[1:], options=options)
    update.buildSite()