コード例 #1
0
ファイル: Crypt.py プロジェクト: xxdoc/QuickUSB
def main():
    global global_opts
    global opts
    import pyi_optparse as optparse

    cmds = {}
    p = optparse.OptionParser(
        usage="%prog [opts] file",
        description="Generate a plaintext keyfile containing a "
        "random-generated encryption key. ")
    cmds["genkey"] = p

    for c, p in cmds.items():
        p.prog = p.get_prog_name() + " " + c

    cmdnames = cmds.keys()
    cmdnames.sort()
    p = optparse.OptionParser(
        usage="%prog cmd [opts]\n\n" + "Available Commands:\n  " +
        "\n  ".join(cmdnames),
        description=
        "This tool is a helper of crypt-related tasks with PyInstaller.")

    p.disable_interspersed_args()
    global_opts, args = p.parse_args()
    if not args:
        p.print_usage()
        return -1

    c = args.pop(0)
    if c not in cmds.keys():
        print "invalid command: %s" % c
        return -1

    p = cmds[c]
    opts, args = p.parse_args(args)
    try:
        return globals()["cmd_" + c](args)
    except ArgsError, e:
        p.error(e)
コード例 #2
0
        d['console'] = 1
    specfnm = os.path.join(workdir, name + '.spec')
    specfile = open(specfnm, 'w')
    if freeze:
        specfile.write(freezetmplt % d)
    elif comserver:
        specfile.write(comsrvrtmplt % d)
    else:
        specfile.write(collecttmplt % d)
    specfile.close()
    return specfnm


if __name__ == '__main__':
    import pyi_optparse as optparse
    p = optparse.OptionParser(
        usage="python %prog [opts] <scriptname> [<scriptname> ...]")
    p.add_option('-C',
                 '--configfile',
                 default=os.path.join(HOME, 'config.dat'),
                 help='Name of configfile (default: %default)')

    g = p.add_option_group('What to generate')
    g.add_option("-F",
                 "--onefile",
                 dest="freeze",
                 action="store_true",
                 default=False,
                 help="create a single file deployment")
    g.add_option("-D",
                 "--onedir",
                 dest="freeze",