示例#1
0
def main():
    opts, args = options.parse_args()
    if len(args) != 4:
        options.print_usage()
        exit(1)

    targetConfigFile = abspath(expanduser(args[0]))
    statsConfigFile = abspath(expanduser(args[1]))
    srcDir = abspath(expanduser(args[2]))
    destDir = abspath(expanduser(args[3]))
    checkPaths(targetConfigFile, statsConfigFile, srcDir, destDir)

    config = unpackJSON(targetConfigFile, statsConfigFile)
    for channel in config.channels:
        if opts.verbose:
            print "processing", channel.id,
            start = time.time()
        counters = parseFiles(config, channel, srcDir, opts.verbose)
        writeTarget(destDir, channel, counters)
        if opts.verbose:
            print "({0:.4} seconds)".format(time.time() - start)
示例#2
0
def main():
    opts, args = options.parse_args()
    if len(args) not in (2, 3):
        options.print_help()
        exit(1)
    targetConfigPath = expanduser(args[0])
    statsConfigPath = expanduser(args[1])
    if len(args) == 3:
        outfile = args[2]
    else:
        outfile = None
    checkPaths(targetConfigPath, statsConfigPath, outfile)
    if outfile:
        out = open(outfile, 'w')
        os.chmod(outfile, 0755)
    else:
        out = sys.stdout
    tree = unpackJSON(targetConfigPath, statsConfigPath)
    if tree.sort:
        tree.channels.sort(key=channelSortKey)
    html = compileTemplate(tree)
    out.write(html)