Esempio n. 1
0
    def search_and_proxy(self, option, from_result=False):
        """搜索并登录资产"""
        self.search_assets(option=option, from_result=from_result)
        if len(self.search_result) == 1:
            request.asset = asset = self.search_result[0]
            if len(asset.system_users) == 1:
                system_user = asset.system_users[0]
            else:
                self.client_channel.send(
                    wr(primary(
                        'More than one system user granted, select one')))
                system_user = self.choose_system_user(asset.system_users)
                if system_user is None:
                    return self.dispatch()

            request.system_user = system_user
            self.return_to_proxy(asset, system_user)
        elif len(self.search_result) == 0:
            self.client_channel.send(
                wr(warning('No asset match, please input again')))
            return self.dispatch()
        else:
            self.client_channel.send(
                wr(primary('Search result is not unique, '
                           'select below or search again'),
                   after=2))
            self.display_search_result()
            self.dispatch(twice=True)
Esempio n. 2
0
    def search_and_proxy(self, option, from_result=False):
        """搜索并登录资产"""
        self.search_assets(option=option, from_result=from_result)
        if len(self.search_result) == 1:
            request.asset = asset = self.search_result[0]
            if len(asset.system_users) == 1:
                system_user = asset.system_users[0]
            else:
                self.client_channel.send(
                    wr(primary('More than one system user granted, select one')))
                system_user = self.choose_system_user(asset.system_users)
                if system_user is None:
                    return self.dispatch()

            request.system_user = system_user
            self.return_to_proxy(asset, system_user)
        elif len(self.search_result) == 0:
            self.client_channel.send(
                wr(warning('No asset match, please input again')))
            return self.dispatch()
        else:
            self.client_channel.send(
                wr(primary('Search result is not unique, '
                           'select below or search again'), after=2))
            self.display_search_result()
            self.dispatch(twice=True)