コード例 #1
0
ファイル: usertool.py プロジェクト: benjwadams/glider-dac
    parser.add_argument('user', nargs='?', action=UserAction, help='Username')

    args = parser.parse_args()

    if not os.path.exists(args.db_file) and not args.op == "init":
        raise StandardError("File %s does not exist. Use %s %s 'init' if you want to create it" % (args.db_file, sys.argv[0], args.db_file))

    u = UserDB(args.db_file)

    if args.op == 'set':
        pw = getpass.getpass()

        u.set(args.user, pw)
    elif args.op == 'check':
        pw = getpass.getpass()

        cv = u.check(args.user, pw)
        if cv:
            print "Success"
        else:
            print "Failure"
            sys.exit(1)

    elif args.op == 'list':
        print "\n".join(u.list_users())

    elif args.op == 'init':
        u.init_db(args.db_file)


コード例 #2
0
    parser.add_argument('user', nargs='?', action=UserAction, help='Username')

    args = parser.parse_args()

    if not os.path.exists(args.db_file) and not args.op == "init":
        raise StandardError(
            "File %s does not exist. Use %s %s 'init' if you want to create it"
            % (args.db_file, sys.argv[0], args.db_file))

    u = UserDB(args.db_file)

    if args.op == 'set':
        pw = getpass.getpass()

        u.set(args.user, pw)
    elif args.op == 'check':
        pw = getpass.getpass()

        cv = u.check(args.user, pw)
        if cv:
            print "Success"
        else:
            print "Failure"
            sys.exit(1)

    elif args.op == 'list':
        print "\n".join(u.list_users())

    elif args.op == 'init':
        u.init_db(args.db_file)