当前位置: 首页>>代码示例>>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;未经允许,请勿转载。