Beispiel #1
0
def main(args=sys.argv[1:]):
    args = parse_args(args)
    if args.version:
        print(__version__)
        sys.exit(0)
    error, help_message = validate_args(args)
    if args.help:
        print_help(help_message, long=True)
        sys.exit(0)
    if error:
        print_help(help_message)
        sys.exit(0)
    profile, master_password = create_profile(args)
    if not master_password:
        master_password = getpass.getpass("Master Password: "******"Copied to clipboard")
        except Exception as e:
            print("Copy failed, we are sorry")
            print("Can you send us an email at [email protected]\n")
            print("-" * 80)
            print("Object: [LessPass][cli] Copy issue on %s" %
                  platform.system())
            print("Hello,")
            print("I got an issue with LessPass cli software.\n")
            traceback.print_exc()
            print("-" * 80)
    else:
        print(generated_password)
Beispiel #2
0
def main(args=sys.argv[1:]):
    args = parse_args(args)
    if args.clipboard and not get_system_copy_command():
        print(
            "error: To use the option -c (--copy) you need pbcopy on OSX, "
            + "xsel, xclip, or wl-clipboard on Linux, and clip on Windows"
        )
        sys.exit(3)

    if args.save_path:
        return save_password_profiles(args.config_home_path, args.url, args.save_path)

    if args.load_path:
        return load_password_profiles(args.config_home_path, args.url, args.load_path)

    if args.prompt:
        if not args.site:
            args.site = getpass.getpass("Site: ")
        if not args.login:
            args.login = getpass.getpass("Login: "******"error: argument SITE is required but was not provided.")
        sys.exit(4)

    if not args.master_password:
        prompt = "Master Password: "******"error: argument MASTER_PASSWORD is required but was not provided")
        sys.exit(5)

    profile, master_password = create_profile(args)
    try:
        generated_password = generate_password(profile, master_password)
    except exceptions.ExcludeAllCharsAvailable:
        print("error: you can't exclude all chars available")
        sys.exit(6)

    if args.clipboard:
        try:
            copy(generated_password)
            print("Copied to clipboard")
        except Exception:
            print("Copy failed, we are sorry")
            print("Can you send us an email at [email protected]\n")
            print("-" * 80)
            print("Object: [LessPass][cli] Copy issue on %s" % platform.system())
            print("Hello,")
            print("I got an issue with LessPass cli software.\n")
            traceback.print_exc()
            print("-" * 80)
    else:
        print(generated_password)
Beispiel #3
0
 def test_create_profile_default(self):
     profile, master_password = create_profile(parse_args(["site",
                                                           "login"]))
     self.assertTrue(profile["lowercase"])
     self.assertTrue(profile["uppercase"])
     self.assertTrue(profile["digits"])
     self.assertTrue(profile["symbols"])
     self.assertEqual(profile["length"], 16)
     self.assertEqual(profile["counter"], 1)
     self.assertEqual(profile["site"], "site")
     self.assertEqual(profile["login"], "login")
     self.assertIsNone(master_password)
Beispiel #4
0
def main(args=sys.argv[1:]):
    args = parse_args(args)
    if args.clipboard and not get_system_copy_command():
        print("ERROR To use the option -c (--copy) you need pbcopy " +
              "on OSX, xsel or xclip on Linux, and clip on Windows")
        sys.exit(3)

    if args.prompt:
        args.site = getpass.getpass("Site: ")
        args.login = getpass.getpass("Login: "******"ERROR argument SITE is required but was not provided.")
        sys.exit(4)

    if not args.master_password:
        args.master_password = getpass.getpass("Master Password: "******"ERROR argument MASTER_PASSWORD is required but was not provided")
        sys.exit(5)

    profile, master_password = create_profile(args)
    generated_password = generate_password(profile, master_password)

    if args.clipboard:
        try:
            copy(generated_password)
            print("Copied to clipboard")
        except Exception as e:
            print("Copy failed, we are sorry")
            print("Can you send us an email at [email protected]\n")
            print("-" * 80)
            print("Object: [LessPass][cli] Copy issue on %s" %
                  platform.system())
            print("Hello,")
            print("I got an issue with LessPass cli software.\n")
            traceback.print_exc()
            print("-" * 80)
    else:
        print(generated_password)
Beispiel #5
0
def main(args=sys.argv[1:]):
    args = parse_args(args)
    if args.clipboard and not get_system_copy_command():
        print(
            "ERROR To use the option -c (--copy) you need pbcopy "
            + "on OSX, xsel or xclip on Linux, and clip on Windows"
        )
        sys.exit(3)

    if args.prompt_all:
        args.site = getpass.getpass("Site: ")
        args.login = getpass.getpass("Login: "******"Counter: ")
        if counter.isdigit():
            args.counter = int(counter)
        else:
            print("ERROR argument COUNTER must be an integer.")
            sys.exit(4)
            
        length = getpass.getpass("Length [5-35]: ")
        try:
            length = int(length)
            if length >= 5 and length <= 35:
                args.length = length
            else:
                raise
        except:
            print("ERROR argument LENGTH must be an integer in range [5-35].")
            sys.exit(4)
            
        args.nl = True if getpass.getpass("Lowercase (Y/n): ") == 'n' else False
        args.nu = True if getpass.getpass("Uppercase (Y/n): ") == 'n' else False
        args.nd = True if getpass.getpass("Digits (Y/n): ") == 'n' else False
        args.ns = True if getpass.getpass("Symbols (Y/n): ") == 'n' else False
        
    elif args.prompt:
        args.site = getpass.getpass("Site: ")
        args.login = getpass.getpass("Login: "******"ERROR argument SITE is required but was not provided.")
        sys.exit(4)

    if not args.master_password:
        args.master_password = getpass.getpass("Master Password: "******"ERROR argument MASTER_PASSWORD is required but was not provided")
        sys.exit(5)

    profile, master_password = create_profile(args)
    generated_password = generate_password(profile, master_password)

    if args.clipboard:
        try:
            copy(generated_password)
            print("Copied to clipboard")
        except Exception as e:
            print("Copy failed, we are sorry")
            print("Can you send us an email at [email protected]\n")
            print("-" * 80)
            print("Object: [LessPass][cli] Copy issue on %s" % platform.system())
            print("Hello,")
            print("I got an issue with LessPass cli software.\n")
            traceback.print_exc()
            print("-" * 80)
    else:
        print(generated_password)
Beispiel #6
0
 def test_create_profile_us(self):
     profile, _ = create_profile(parse_args(["site", "-us"]))
     self.assertFalse(profile["lowercase"])
     self.assertTrue(profile["uppercase"])
     self.assertFalse(profile["digits"])
     self.assertTrue(profile["symbols"])
Beispiel #7
0
 def test_create_profile_master_password(self):
     _, master_password = create_profile(
         parse_args(["site", "login", "master_password"]))
     self.assertEqual(master_password, "master_password")
Beispiel #8
0
 def test_create_profile_counter(self):
     profile, _ = create_profile(parse_args(["site", "--counter", "2"]))
     self.assertEqual(profile["counter"], 2)
Beispiel #9
0
 def test_create_profile_length(self):
     profile, _ = create_profile(parse_args(["site", "--length", "8"]))
     self.assertEqual(profile["length"], 8)
Beispiel #10
0
 def test_create_profile_login(self):
     profile, _ = create_profile(parse_args(["site"]))
     self.assertEqual(profile["login"], "")