當前位置: 首頁>>代碼示例>>Python>>正文


Python display.vvvv方法代碼示例

本文整理匯總了Python中__main__.display.vvvv方法的典型用法代碼示例。如果您正苦於以下問題:Python display.vvvv方法的具體用法?Python display.vvvv怎麽用?Python display.vvvv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在__main__.display的用法示例。


在下文中一共展示了display.vvvv方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def run(self, terms, variables=None, **kwargs):

        ret = []
        # Perform iteration
        for term in terms:

            display.debug("File lookup term: %s" % term)

            # Find the file in the expected search path
            lookupfile = self.find_file_in_search_path(variables, 'files', term)
            display.vvvv(u"File lookup using %s as file" % lookupfile)
            try:
                if lookupfile:
                    contents, show_data = self._loader._get_file_contents(lookupfile)
                    ret.append(contents.rstrip())
                else:
                    raise AnsibleParserError()

            except AnsibleParserError:
                raise AnsibleError("could not locate file in lookup: %s" % term) 
開發者ID:PacktPublishing,項目名稱:Implementing-DevOps-with-Ansible-2,代碼行數:22,代碼來源:Example4.LookUpPlugin.py

示例2: get_user_groups

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def get_user_groups(self, rows):

        display.vvvv(u"Getting user groups")

        userGroupsDict = {}

        userGroupList = []

        for row in rows:
            if row['group'] not in userGroupsDict :
                userGroupsDict[row['group']] = []

            userGroupsDict[row['group']].append(row['user_name'])

        for key in userGroupsDict :
            userGroupList.append({ "name": key, "members": userGroupsDict[key]})

        return json.dumps(userGroupList) 
開發者ID:redhat-cop,項目名稱:infra-ansible,代碼行數:20,代碼來源:csvtojson.py

示例3: get_users

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def get_users(self, rows):

        display.vvvv(u"Getting users")

        return json.dumps(rows)

    # get json for groups - need to maniuplate the rows a bit.
    # take username, group and transfrom to { name: mygroup, members: [ user_name: user1 }, { user_name: user2 } ]} 
開發者ID:redhat-cop,項目名稱:infra-ansible,代碼行數:10,代碼來源:csvtojson.py

示例4: _lookup_login_url

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def _lookup_login_url(self, payload):
        """ Try to find correct login URL and get api token using this URL.

        :param payload: Token request payload
        :type payload: dict
        :return: token generation response
        """
        preconfigured_token_path = self._get_api_token_path()
        if preconfigured_token_path:
            token_paths = [preconfigured_token_path]
        else:
            token_paths = self._get_known_token_paths()

        for url in token_paths:
            try:
                response = self._send_login_request(payload, url)

            except ConnectionError as e:
                display.vvvv('REST:request to {0} failed because of connection error: {1}'.format(url, e))
                # In the case of ConnectionError caused by HTTPError we should check response code.
                # Response code 400 returned in case of invalid credentials so we should stop attempts to log in and
                # inform the user.
                if hasattr(e, 'http_code') and e.http_code == 400:
                    raise
            else:
                if not preconfigured_token_path:
                    self._set_api_token_path(url)
                return response

        raise ConnectionError(INVALID_API_TOKEN_PATH_MSG if preconfigured_token_path else MISSING_API_TOKEN_PATH_MSG) 
開發者ID:CiscoDevNet,項目名稱:FTDAnsible,代碼行數:32,代碼來源:ftd.py

示例5: _display

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def _display(self, http_method, title, msg=''):
        display.vvvv('REST:{0}:{1}:{2}\n{3}'.format(http_method, self.connection._url, title, msg)) 
開發者ID:CiscoDevNet,項目名稱:FTDAnsible,代碼行數:4,代碼來源:ftd.py

示例6: _connect

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def _connect(self):
        if self._connected:
            return
        display.vvvv("Opening the rest session now")
        payload = {'action': 'login', 'username': self._username, 'password': self._password}
        self._http_session_handle = requests.session()
        self._http_session_handle.trust_env = False
        response = self._http_session_handle.post(self._login_url, data=payload, verify=False)
        display.vvvv("Login response")
        display.vvvv(response.text)
        display.vvvv("The session object is")
        display.vvvv("=== ======= ====== ==")
        display.vvvv(str(self._http_session_handle))
        self._connected = True 
開發者ID:aruba,項目名稱:aruba-ansible-modules,代碼行數:16,代碼來源:arubaoscx_rest.py

示例7: reset

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def reset(self):
        '''
        Reset the connection
        '''
        if self._socket_path:
            display.vvvv('resetting persistent connection for socket_path %s' % self._socket_path, host=self.host)
            self.close()
        display.vvvv('reset call on connection instance', host=self.host) 
開發者ID:aruba,項目名稱:aruba-ansible-modules,代碼行數:10,代碼來源:arubaoscx_rest.py

示例8: close

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def close(self):
        if self._connected:
            response = self._http_session_handle.post(self._logout_url, verify=False)
            display.debug("Hi! Closing the http connection now")
            display.vvvv(response.text)
            display.display("Closed the http connection!")
            self._connected = False 
開發者ID:aruba,項目名稱:aruba-ansible-modules,代碼行數:9,代碼來源:arubaoscx_rest.py

示例9: run

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def run(self, tmp=None, task_vars=None):
        del tmp  # tmp no longer has any effect

        socket_path = None

        if self._play_context.connection == 'local' or self._play_context.connection == 'network_cli':
            provider = load_provider(arubaoss_provider_spec, self._task.args)
            transport = provider['transport'] or 'aossapi'

            display.vvvv('connection transport is %s for %s' % (transport, self._play_context.remote_addr))
            if not provider.get('api_version') is None:
                api = provider.get('api_version')
                if api not in ['v1.0','v2.0','v2.1','v2.2','v3.0','v3.1','v4.0','v5.0']:
                    provider['api_version'] = None
                    display.vvvv('%s is not valid api version. using aossapi v6.0 instead' % api)
                else:
                    display.vvvv('%s is not latest version (v6.0), arubaoss module may not work as intended' % api)


            if transport == 'cli':
                return dict(
                        failed=True,
                        msg='invalid connection specified, expected connection=local, '
                        'got %s' % self._play_context.connection)
            else:
                self._task.args['provider'] = ActionModule.aossapi_implementation(provider, self._play_context)

        result = super(ActionModule, self).run(task_vars=task_vars)
        return result 
開發者ID:aruba,項目名稱:aruba-ansible-modules,代碼行數:31,代碼來源:arubaoss.py

示例10: run

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def run(self, terms, variables=None, **kwargs):

        ret = []

        cwd = os.getcwd()

        for term in terms:

            params = term.split()

            paramvals = {
                'file' : 'users.csv',
                'var' : 'users'
            }

            # parameters specified?
            try:
                for param in params:
                    name, value = param.split('=')
                    assert(name in paramvals)
                    paramvals[name] = value
                    display.vvvv(u"Param: %s : %s" % (name, value))
            except (ValueError, AssertionError) as e:
                raise AnsibleError(e)

            if os.path.isabs(paramvals['file']):
              lookupfile = paramvals['file']
            else:
              lookupfile = cwd + '/' + paramvals['file']

            display.vvvv(u"File lookup using %s as file" % paramvals['file'])
            try:
                if lookupfile:
                    #read csv into rows
                    with open(lookupfile) as f:
                        reader = csv.DictReader(f)
                        rows = list(reader)

                    # do output for users or groups
                    if(paramvals['var'] == 'user_groups'):
                        ret.append(self.get_user_groups(rows))
                    else:
                        ret.append(self.get_users(rows))

                else:
                    raise AnsibleParserError()
            except AnsibleParserError:
                raise AnsibleError("could not locate file in lookup: %s" % paramvals['file'])

        return ret

    # get json for users - file should already support this format 
開發者ID:redhat-cop,項目名稱:infra-ansible,代碼行數:54,代碼來源:csvtojson.py

示例11: run

# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvvv [as 別名]
def run(self, tmp=None, task_vars=None):
        if self._play_context.connection != 'local':
            return dict(
                failed=True,
                msg='invalid connection specified, expected connection=local, '
                    'got %s' % self._play_context.connection
            )

        provider = self.load_provider()
        transport = provider['transport'] or 'cli'

        display.vvvv('connection transport is %s' % transport, self._play_context.remote_addr)

        if transport == 'cli':
            pc = copy.deepcopy(self._play_context)
            pc.connection = 'network_cli'
            pc.network_os = 'ce'
            pc.remote_addr = provider['host'] or self._play_context.remote_addr
            pc.port = int(provider['port']) or int(self._play_context.port) or 22
            pc.remote_user = provider['username'] or self._play_context.connection_user
            pc.password = provider['password'] or self._play_context.password
            pc.timeout = provider['timeout'] or self._play_context.timeout
            self._task.args['provider'] = provider.update(
                host=pc.remote_addr,
                port=pc.port,
                username=pc.remote_user,
                password=pc.password
                #ssh_keyfile=pc.private_key_file
            )
            display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
            connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)
            socket_path = self._get_socket_path(pc)
            display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)

            if not os.path.exists(socket_path):
                # start the connection if it isn't started
                rc, out, err = connection.exec_command('open_shell()')
                display.vvvv('open_shell() returned %s %s %s' % (rc, out, err))
                if rc != 0:
                    return {'failed': True,
                            'msg': 'unable to open shell. Please see: ' +
                            'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell',
                            'rc': rc}
            else:
                # make sure we are in the right cli context which should be
                # enable mode and not config module
                rc, out, err = connection.exec_command('prompt()')
                while str(out).strip().endswith(']'):
                    display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
                    connection.exec_command('return')
                    rc, out, err = connection.exec_command('prompt()')

            task_vars['ansible_socket'] = socket_path

        # make sure a transport value is set in args
        self._task.args['transport'] = transport
        self._task.args['provider'] = provider

        result = super(ActionModule, self).run(tmp, task_vars)
        return result 
開發者ID:HuaweiSwitch,項目名稱:CloudEngine-Ansible,代碼行數:62,代碼來源:ce.py


注:本文中的__main__.display.vvvv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。