コード例 #1
0
ファイル: manage.py プロジェクト: weralwolf/iod-data-analyser
def execute_selected_command(command_name, *args):
    commands = sorted(list_commands(), key=lambda x: x['index'] or 0)
    if command_name == 'all':
        for command in filter(lambda x: x['index'] is not None, commands):
            execute_command(command)
        return

    to_execute = find_command(command_name, commands)
    if to_execute is None:
        print('No such stript.')
        exit(1)

    return execute_command(to_execute)
コード例 #2
0
ファイル: narrator.py プロジェクト: monicatoth/ls_explorer
def narrate():
    ''' Simple function to provide a user prompt, accept input, and pass it
    along to the functions that recognize and fulfill commands '''
    logger.info('Beginning narrate function')
    print("Welcome! Type '{0}quit{1}' at any time to stop the program. Type '{0}help{1}' to see your options.".format(u.colors['red'], u.colors['default']))
    while True: 
        user_input = raw_input('{0}> {1}'.format(u.colors['black'], u.colors['default']))
        commands = c.extract_commands(user_input)
        if commands is None:
            logger.info('User has specified no command words')
            continue
        elif len(commands) == 0: # something went wrong
            logger.error('An empty list of commands was returned.')
        else: 
            c.execute_command(commands, user_input)
            continue
コード例 #3
0
    def menu_change_password(self):
        #ask the user for new password
        new_password = []

        inputbox = ui_password_change.Ui_Password_Change(new_password)
        inputbox.show()
        if inputbox.exec_() == 1:
            #run the PUT command
            if len(new_password[0]) != 0:
                #set the new user's provided password
                yc.execute_command("set_code", new_password[0])
                self.refresh()
            else:
                #user picked a blank password, so we unset the code and leave the neo unprotected
                yc.execute_command("unset_code", new_password[0])
                self.refresh()
コード例 #4
0
ファイル: ui_main.py プロジェクト: tarnfeld/yubioath-desktop
    def menu_change_password(self):
        #ask the user for new password
        new_password = []

        inputbox = ui_password_change.Ui_Password_Change(new_password)
        inputbox.show()
        if inputbox.exec_() == 1:
            #run the PUT command
            if len(new_password[0]) != 0:
                #set the new user's provided password
                yc.execute_command("set_code", new_password[0])
                self.refresh()
            else:
                #user picked a blank password, so we unset the code and leave the neo unprotected
                yc.execute_command("unset_code", new_password[0])
                self.refresh()
コード例 #5
0
ファイル: ui_main.py プロジェクト: tarnfeld/yubioath-desktop
    def refresh(self):

        # compute codes and check if the NEO is inserted into the USB
        cred_list = yc.execute_command("calculate_all")

        # if None there is no NEO
        if cred_list is None:
            # close the main window
            self.hide_interface()

        else:

            #clear the list at the end of the 30 seconds
            self.leftList.clear()
            self.rightList.clear()

            for credential in cred_list:
                if credential.algorithm == 'totp':
                    self.leftList.addItem(
                        str(credential.name).decode('utf-8').strip())
                    self.rightList.addItem(str(credential.code))

                else:
                    self.leftList.addItem(
                        str(credential.name).decode('utf-8').strip())

                    self.rightList.addItem('HOTP')
                    #identify the row and set the tooltip
                    value = self.rightList.count()
                    item = self.rightList.item(value - 1)
                    item.setToolTip("Click to generate HOTP")
コード例 #6
0
    def refresh(self):
        
        # compute codes and check if the NEO is inserted into the USB        
        cred_list = yc.execute_command("calculate_all")
        
        # if None there is no NEO
        if cred_list is None:
            # close the main window
            self.hide_interface()

        else:
            
            #clear the list at the end of the 30 seconds
            self.leftList.clear()
            self.rightList.clear()
            
            for credential in cred_list:
                if credential.algorithm == 'totp':
                    self.leftList.addItem(str(credential.name).decode('utf-8').strip())
                    self.rightList.addItem(str(credential.code))

                else:
                    self.leftList.addItem(str(credential.name).decode('utf-8').strip())
                    
                    self.rightList.addItem('HOTP')
                    #identify the row and set the tooltip
                    value = self.rightList.count()
                    item = self.rightList.item(value-1)
                    item.setToolTip("Click to generate HOTP")
コード例 #7
0
ファイル: ui_main.py プロジェクト: pgalves/yubioath-desktop
    def addCredential(self):

        #set data structure for the add command
        new_account = {
        'KEY_TYPE':None,
        'ACCOUNT_NAME':None,
        'SECRET_KEY':None
        }

        #ask the user for new account information
        inputbox = ui_addaccount.Ui_AddAccount(new_account)
        inputbox.show()
        if inputbox.exec_() == 1:
            #strip off white spaces
            new_account['ACCOUNT_NAME'].replace(" ", "")
            new_account['SECRET_KEY'].replace(" ", "")
            #run the PUT command
            yc.execute_command("put", new_account)
            self.refresh()
コード例 #8
0
def handle_command(command, channel):
    """
        Executes bot command if the command is known
    """
    default_response = "Not sure what you mean. Try *help*"

    response = None
    if command.startswith(POSSIBLE_COMMANDS):
        response = execute_command(command)

    slack_client.api_call("chat.postMessage",
                          channel=channel,
                          text=response or default_response)
コード例 #9
0
    def delCredential(self):

        #get selected item from the user
        item = self.leftList.currentItem()
        if not item:
            QtGui.QMessageBox.information(QtGui.QWidget(), "Information", "Select 1 credential name on the left panel to delete it")
            return

        #ask for confirmation before delete
        delete, ok = QtGui.QInputDialog.getText(None, "Warning!", "Type \"delete\" to confirm deletion", QtGui.QLineEdit.Normal)
        if delete == "delete":
            if yc.execute_command("delete", item.text()):
                self.refresh()
            else:
                print "Warning: Delete unsuccessfull"
コード例 #10
0
ファイル: ui_main.py プロジェクト: pgalves/yubioath-desktop
    def delCredential(self):

        #get selected item from the user
        item = self.leftList.currentItem()
        if not item:
            QtGui.QMessageBox.information(QtGui.QWidget(), "Information", "Select 1 credential name on the left panel to delete it")
            return

        #ask for confirmation before delete
        delete, ok = QtGui.QInputDialog.getText(None, "Warning!", "Type \"delete\" to confirm deletion", QtGui.QLineEdit.Normal)
        if delete == "delete":
            if yc.execute_command("delete", item.text()):
                self.refresh()
            else:
                print "Warning: Delete unsuccessfull"
コード例 #11
0
ファイル: ui_main.py プロジェクト: tarnfeld/yubioath-desktop
    def itemClicked(self, item):
        # 1 click copy the item value as text
        # Handle HOTP load and copy
        if str(item.text()) == "HOTP":
            #get current row
            row = self.rightList.currentRow()
            #get name from the right list widget
            item = self.leftList.item(row)
            hotp_name = item.text()
            hotp = str(yc.execute_command("calculate", hotp_name))
            if hotp is None:
                hotp = "Error"

            #update the item with the generated code
            item = self.rightList.item(row)
            item.setText(hotp)

        app = QtCore.QCoreApplication.instance()
        clipboard = app.clipboard()
        clipboard.clear(QtGui.QClipboard.Clipboard)
        clipboard.setText(str(item.text()), QtGui.QClipboard.Clipboard)
コード例 #12
0
    def itemClicked(self, item):
        # 1 click copy the item value as text
        # Handle HOTP load and copy
        if str(item.text()) == "HOTP":
            #get current row
            row = self.rightList.currentRow()
            #get name from the right list widget
            item = self.leftList.item(row)
            hotp_name = item.text()
            hotp = str(yc.execute_command("calculate", hotp_name))
            if hotp is None:
                hotp = "Error"

            #update the item with the generated code
            item = self.rightList.item(row)
            item.setText(hotp)
        
        app = QtCore.QCoreApplication.instance()
        clipboard = app.clipboard()
        clipboard.clear(QtGui.QClipboard.Clipboard)
        clipboard.setText(str(item.text()), QtGui.QClipboard.Clipboard)
コード例 #13
0
def main():
    execute_command()