コード例 #1
0
    def validate_form(self):
        error_text = ''
        base_asset = self.ui.base_asset_input.currentText()
        quote_asset = self.ui.quote_asset_input.text()
        if not self.validate_bot_name():
            bot_name = self.ui.bot_name_input.text()
            error_text = 'Bot name needs to be unique. "{}" is already in use.'.format(
                bot_name)
        elif not self.validate_asset(base_asset):
            error_text = 'Field "Base Asset" does not have a valid asset.'
        elif not self.validate_asset(quote_asset):
            error_text = 'Field "Quote Asset" does not have a valid asset.'
        elif not self.validate_market():
            error_text = "Market {}/{} doesn't exist.".format(
                base_asset, quote_asset)
        elif not self.validate_account_name():
            error_text = "Account doesn't exist."
        elif not self.validate_account():
            error_text = 'Private key is invalid.'

        if error_text:
            dialog = NoticeDialog(error_text)
            dialog.exec_()
            return False
        else:
            return True
コード例 #2
0
ファイル: unlock_wallet.py プロジェクト: tryiou/DEXBot
 def validate_form(self):
     password = self.password_input.text()
     if not self.controller.unlock_wallet(password):
         dialog = NoticeDialog('Invalid password!')
         dialog.exec_()
         self.password_input.setText('')
     else:
         self.accept()
コード例 #3
0
ファイル: create_wallet.py プロジェクト: bitphage/DEXBot
 def validate_form(self):
     password = self.password_input.text()
     confirm_password = self.confirm_password_input.text()
     if not self.controller.create_wallet(password, confirm_password):
         dialog = NoticeDialog('Passwords do not match!')
         dialog.exec_()
     else:
         self.accept()
コード例 #4
0
    def validate_form(self):
        error_texts = []
        base_asset = self.view.base_asset_input.text()
        quote_asset = self.view.quote_asset_input.text()
        fee_asset = self.view.fee_asset_input.text()
        worker_name = self.view.worker_name_input.text()
        old_worker_name = None if self.mode == 'add' else self.view.worker_name

        if not self.validator.validate_worker_name(worker_name,
                                                   old_worker_name):
            error_texts.append(
                'Worker name needs to be unique. "{}" is already in use.'.
                format(worker_name))
        if not self.validator.validate_asset(base_asset):
            error_texts.append(
                'Field "Base Asset" does not have a valid asset.')
        if not self.validator.validate_asset(quote_asset):
            error_texts.append(
                'Field "Quote Asset" does not have a valid asset.')
        if not self.validator.validate_asset(fee_asset):
            error_texts.append(
                'Field "Fee Asset" does not have a valid asset.')
        if not self.validator.validate_market(base_asset, quote_asset):
            error_texts.append("Market {}/{} doesn't exist.".format(
                base_asset, quote_asset))
        if self.mode == 'add':
            account = self.view.account_input.text()
            private_key = self.view.private_key_input.text()
            if not self.validator.validate_account_name(account):
                error_texts.append("Account doesn't exist.")
            if not self.validator.validate_account_not_in_use(account):
                error_texts.append(
                    'Use a different account. "{}" is already in use.'.format(
                        account))
            if not self.validator.validate_private_key(account, private_key):
                error_texts.append('Private key is invalid.')
            elif private_key and not self.validator.validate_private_key_type(
                    account, private_key):
                error_texts.append('Please use active private key.')

        error_texts.extend(
            self.view.strategy_widget.strategy_controller.validation_errors())
        error_text = '\n'.join(error_texts)

        if error_text:
            dialog = NoticeDialog(error_text)
            dialog.exec_()
            return False
        else:
            return True