Beispiel #1
0
    def __init__(self, app, passphrase, keyID):
        super(QDialog, self).__init__()
        self.app = app
        self.passphrase = passphrase
        self.keyID = keyID

        # Set up window
        self.ui = Ui_MakeVideoForm()
        self.ui.setupUi(self)

        print(keyID)
        print(public_keys_details())

        # Handle key error here?
        key = public_keys_details()[keyID]
        if not key:
            # Key not found
            self.window.show()
            return

        print(key["uid"])

        name, email = self.extract_name_and_email(key["uid"])

        keyExpiry = key["expires"]
        if keyExpiry == "":
            expiry = "None"
        else:
            expiry = uIntToString(keyExpiry)

        date = uIntToString(key["date"])
        fingerprint = key["fingerprint"]

        print(name)
        print(email)

        self.ui.nameLabel.setText("Name: " + name)
        self.ui.emailLabel.setText("Email: " + email)
        self.ui.expiresLabel.setText("Expiry: " + expiry)
        self.ui.dateLabel.setText("Date: " + date)
        self.ui.fingerprintTextEdit.setText(fingerprint)

        self.ui.importVideoButton.clicked.connect(self.importVideo)
        # Set up connections
        # self.ui.passphraseTextEdit.textChanged.connect(self.passphraseChanged)
        # self.ui.loadKeyButton.clicked.connect(self.loadKeyClicked)

        self.show()
Beispiel #2
0
def generate():
    while True:
        generate_key_answer = input("Would you like to generate a new gpg key? [yes/no]")
        if generate_key_answer == "yes":
            # Generate
            generate_key()
            break
        elif generate_key_answer == "no":
            # Don't generate - continue
            break
    
    keys_list = []
    keys_dict = gpglib.private_keys_users()
    for key in keys_dict.keys():
        keys_list.append(key)
        print (str(len(keys_list) - 1) + ". " + key)

    while True:
        key_index_str = input("Please enter a key index [0-" + str(len(keys_list)-1) + "] ")
        if not str.isnumeric(key_index_str):
            print ("Please enter a numeric key index")
            continue
        key_index = int(key_index_str)
        if key_index >= len(keys_list) or key_index < 0:
            # Invalid selection
            print ("Key index out of range")
            continue
        else:
            # Key selected
            key_selection = keys_list[key_index]
            break
    
    key_id = keys_dict[key_selection]
    while True:
        passphrase = input ("Please enter the passphrase for " + key_selection + ": ")
        if gpglib.test_passphrase(key_id, passphrase):
            break
        else:
            print ("Incorrect passphrase")

    # Make VAIDA video
    key = gpglib.public_keys_details()[key_id]
    name, email = extract_name_and_email(key['uid'])
    key_expiry = key['expires']
    if key_expiry == '':
        expiry = "None"
    else:
        expiry = uIntToString.uIntToString(key_expiry)
    date = uIntToString.uIntToString(key['date'])
    fingerprint = key['fingerprint']

    print ("---")
    print ("---")
    print ("Details for making your VAIDA video")
    print ("Name: " + name)
    print ("Email: " + email)
    print ("Expiry: " + expiry)
    print ("Date: " + date)
    print ("Fingerprint: " + fingerprint)
    print ("---")
    print ("---")
    
    while True:
        fname = input("Please enter the location of your VAIDA video: ")
        try:
            vaida_path = gpglib.create_vaida(fname, passphrase, key_id)
            break
        except (IOError):
            # TODO
            print ("Please try again - file probably not found")

    print ("VAIDA created at " + vaida_path)