当前位置: 首页>>代码示例>>Python>>正文


Python six.print_方法代码示例

本文整理汇总了Python中six.print_方法的典型用法代码示例。如果您正苦于以下问题:Python six.print_方法的具体用法?Python six.print_怎么用?Python six.print_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six的用法示例。


在下文中一共展示了six.print_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _talk

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def _talk(self, request, response):
        """
        :type request: RequestMessage
        """
        ba = request.to_bytes()

        if (self.debug):
            print("\nba length={}".format(len(ba)))
            for i, b in enumerate(ba):
                if six.PY2:
                    six.print_("{:02X} ".format(ord(b)), sep='', end='')
                else:
                    six.print_("{:02X} ".format(b), end='')
                if (i + 1) % 16 == 0:
                    six.print_()
            six.print_()

        self._ser.write(ba)

        response.read(self._ser)

        return response 
开发者ID:civic,项目名称:elitech-datareader,代码行数:24,代码来源:__init__.py

示例2: command_raw_send

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def command_raw_send(args):
    device = elitech.Device(args.serial_port, args.ser_baudrate, args.ser_timeout)

    request_bytes = _bin(args.req)

    res = device.raw_send(request_bytes, args.res_len)

    print("\nresponse length={}".format(len(res)))
    for i, b in enumerate(res):
        if six.PY2:
            six.print_("{:02X} ".format(ord(b)), sep='', end='')
        else:
            six.print_("{:02X} ".format(b), end='')
        if (i + 1) % 16 == 0:
            six.print_()

    six.print_() 
开发者ID:civic,项目名称:elitech-datareader,代码行数:19,代码来源:elitech_device.py

示例3: __init__

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def __init__(self, device_dict):
        """
        init device with device dict
        """
        diff = set(device_dict.keys()) - set(YAMLKeyword.__dict__.keys())
        if len(diff) > 0:
            six.print_('Wrong key detected:')
            six.print_(diff)
            raise KeyError(str(diff))
        self.__dict__.update(device_dict)
        if self.system == SystemType.android:
            pass
        elif self.system == SystemType.arm_linux:
            try:
                sh.ssh('-q', '%s@%s' % (self.username, self.address),
                       'exit')
            except sh.ErrorReturnCode as e:
                six.print_('device connect failed, '
                           'please check your authentication',
                           file=sys.stderr)
                raise e

    #####################
    #  public interface #
    ##################### 
开发者ID:XiaoMi,项目名称:mobile-ai-bench,代码行数:27,代码来源:device.py

示例4: pull

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def pull(self, src_path, dst_path='.'):
        if self.system == SystemType.android:
            sh_commands.adb_pull(src_path, dst_path, self.address)
        elif self.system == SystemType.arm_linux:
            if os.path.isdir(dst_path):
                exist_file = dst_path + '/' + src_path.split('/')[-1]
                if os.path.exists(exist_file):
                    sh.rm('-rf', exist_file)
            elif os.path.exists(dst_path):
                sh.rm('-f', dst_path)
            try:
                sh.scp('-r',
                       '%s@%s:%s' % (self.username,
                                     self.address,
                                     src_path),
                       dst_path)
            except sh.ErrorReturnCode_1 as e:
                six.print_('Error msg {}'.format(e), file=sys.stderr)
                return 
开发者ID:XiaoMi,项目名称:mobile-ai-bench,代码行数:21,代码来源:device.py

示例5: single_poll

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def single_poll(self, next_page_token=None):
        poll_time = time.time()
        try:
            kwargs = {'domain': self.domain,
                      'taskList': {'name': self.task_list},
                      'identity': self.identity}
            if next_page_token is not None:
                kwargs['nextPageToken'] = next_page_token
            # old botocore throws TypeError when unable to establish SWF connection
            return self.worker.client.poll_for_decision_task(**kwargs)

        except KeyboardInterrupt:
            # sleep before actually exiting as the connection is not yet closed
            # on the other end
            sleep_time = 60 - (time.time() - poll_time)
            six.print_("Exiting in {0}...".format(sleep_time), file=sys.stderr)
            time.sleep(sleep_time)
            raise 
开发者ID:boto,项目名称:botoflow,代码行数:20,代码来源:decision_task_poller.py

示例6: send_response

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def send_response(cls, resource, url, response_content):
        if url == cls.DUMMY_RESPONSE_URL_SILENT:
            return
        elif url == cls.DUMMY_RESPONSE_URL_PRINT:
            six.print_(json.dumps(response_content, indent=2))
        else:
            put_response = requests.put(url,
                                        data=json.dumps(response_content))
            status_code = put_response.status_code
            response_text = put_response.text
            
            body_text = ""
            if status_code // 100 != 2:
                body_text = "\n" + response_text
            resource._base_logger.debug("Status code: {} {}{}".format(put_response.status_code, http_client.responses[put_response.status_code], body_text))

        return put_response 
开发者ID:iRobotCorporation,项目名称:cfn-custom-resource,代码行数:19,代码来源:cfn_custom_resource.py

示例7: show_progress

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def show_progress(block_num, block_size, total_size):
    """Display the total size of the file to download and the progress in percent"""
    global file_part
    if file_part is None:
        suffixes = ['B', 'KB', 'MB', 'GB', 'TB']
        suffixIndex = 0
        pp_size = total_size
        while pp_size > 1024:
            suffixIndex += 1  # Increment the index of the suffix
            pp_size = pp_size / 1024.0  # Apply the division
        six.print_('Total file size is: {0:.1f} {1}'
                   .format(pp_size, suffixes[suffixIndex]))
        six.print_("0 % of the file downloaded ...\r", end="", flush=True)
        file_part = 0

    downloaded = block_num * block_size
    if downloaded < total_size:
        percent = 100 * downloaded / total_size
        if percent - file_part > 1:
            file_part = percent
            six.print_("{0} % of the file downloaded ...\r".format(int(percent)), end="", flush=True)
    else:
        file_part = None
        six.print_("") 
开发者ID:Networks-Learning,项目名称:stackexchange-dump-to-postgres,代码行数:26,代码来源:load_into_pg.py

示例8: moveTableToSchema

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def moveTableToSchema(table, schemaName, dbConnectionParam):
    try:
        with pg.connect(dbConnectionParam) as conn:
            with conn.cursor() as cur:
                # create the schema
                cur.execute('CREATE SCHEMA IF NOT EXISTS ' + schemaName + ';')
                conn.commit()
                # move the table to the right schema
                cur.execute('ALTER TABLE ' + table + ' SET SCHEMA ' + schemaName + ';')
                conn.commit()
    except pg.Error as e:
        six.print_("Error in dealing with the database.", file=sys.stderr)
        six.print_("pg.Error ({0}): {1}".format(e.pgcode, e.pgerror), file=sys.stderr)
        six.print_(str(e), file=sys.stderr)
    except pg.Warning as w:
        six.print_("Warning from the database.", file=sys.stderr)
        six.print_("pg.Warning: {0}".format(str(w)), file=sys.stderr)

############################################################# 
开发者ID:Networks-Learning,项目名称:stackexchange-dump-to-postgres,代码行数:21,代码来源:load_into_pg.py

示例9: update

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def update(self, step=1):
        """Update progress bar by number of `steps`

        :param step: The number of tasks completed
        :return:
        """
        self.current += step
        percent = self.current / float(self.total)
        size = int(self.width * percent)
        remaining = self.total - self.current
        bar = "[" + self.symbol * size + " " * (self.width - size) + "]"

        args = {
            "total": self.total,
            "bar": bar,
            "current": self.current,
            "percent": percent * 100,
            "remaining": remaining,
        }
        self.print_("\r" + self.fmt % args, end="") 
开发者ID:dpressel,项目名称:mead-baseline,代码行数:22,代码来源:progress.py

示例10: addconstraint

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def addconstraint(self, x, y=0, fnct=None, fid=0):
        """Add constraint."""
        self._checkid(fid)
        i = 0
        if "constraint" in self._fitids[fid]:
            i = len(self._fitids[fid]["constraint"])
        else:
            self._fitids[fid]["constraint"] = {}
        # dict key needs to be string
        i = str(i)
        self._fitids[fid]["constraint"][i] = {}
        if isinstance(fnct, functional):
            self._fitids[fid]["constraint"][i]["fnct"] = fnct.todict()
        else:
            self._fitids[fid]["constraint"][i]["fnct"] = \
                functional("hyper", len(x)).todict()
        self._fitids[fid]["constraint"][i]["x"] = [float(v) for v in x]
        self._fitids[fid]["constraint"][i]["y"] = float(y)
        six.print_(self._fitids[fid]["constraint"]) 
开发者ID:casacore,项目名称:python-casacore,代码行数:21,代码来源:fitting.py

示例11: tabledelete

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def tabledelete(tablename, checksubtables=False, ack=True):
    """Delete a table on disk.

    It is the same as :func:`table.delete`, but without the need to open
    the table first.

    """
    tabname = _remove_prefix(tablename)
    t = table(tabname, ack=False)
    if t.ismultiused(checksubtables):
        six.print_('Table', tabname, 'cannot be deleted; it is still in use')
    else:
        t = 0
        table(tabname, readonly=False, _delete=True, ack=False)
        if ack:
            six.print_('Table', tabname, 'has been deleted') 
开发者ID:casacore,项目名称:python-casacore,代码行数:18,代码来源:tableutil.py

示例12: list

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def list(**type):
    '''List all of the enumerations within the database that match the keyword specified by `type`.'''
    res = builtins.list(iterate(**type))

    maxindex = max(builtins.map(idaapi.get_enum_idx, res) or [1])
    maxname = max(builtins.map(utils.fcompose(idaapi.get_enum_name, len), res) or [0])
    maxsize = max(builtins.map(size, res) or [0])
    cindex = math.ceil(math.log(maxindex or 1)/math.log(10))
    try: cmask = max(builtins.map(utils.fcompose(mask, utils.fcondition(utils.fpartial(operator.eq, 0))(utils.fconstant(1), utils.fidentity), math.log, functools.partial(operator.mul, 1.0/math.log(8)), math.ceil), res) or [database.config.bits()/4.0])
    except: cmask = 0

    for n in res:
        name = idaapi.get_enum_name(n)
        six.print_(u"[{:{:d}d}] {:>{:d}s} & {:<{:d}x} ({:d} members){:s}".format(idaapi.get_enum_idx(n), int(cindex), utils.string.of(name), maxname, mask(n), int(cmask), len(builtins.list(members(n))), u" // {:s}".format(comment(n)) if comment(n) else ''))
    return

## members 
开发者ID:arizvisa,项目名称:ida-minsc,代码行数:19,代码来源:enumeration.py

示例13: fetch_globals_functions

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def fetch_globals_functions():
    """Fetch the reference count for the global tags (function) in the database.

    Returns the tuple `(address, tags)` where the `address` and `tags`
    fields are both dictionaries containing the reference count for
    the addresses and tag names.
    """
    addr, tags = {}, {}
    t = len(list(db.functions()))
    for i, ea in enumerate(db.functions()):
        ui.navigation.auto(ea)
        six.print_(u"globals: fetching tag from function {:#x} : {:d} of {:d}".format(ea, i, t), file=output)
        res = func.tag(ea)
        #res.pop('name', None)
        for k, v in six.iteritems(res):
            addr[ea] = addr.get(ea, 0) + 1
            tags[k] = tags.get(k, 0) + 1
        continue
    return addr, tags 
开发者ID:arizvisa,项目名称:ida-minsc,代码行数:21,代码来源:tagfix.py

示例14: fetch_globals

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def fetch_globals():
    """Fetch the reference count of all of the global tags for both functions and non-functions.

    Returns the tuple `(address, tags)` where the `address` and `tags`
    fields are both dictionaries containing the reference count for
    the addresses and tag names.
    """
    # read addr and tags from all functions/globals
    faddr, ftags = fetch_globals_functions()
    daddr, dtags = fetch_globals_data()

    # consolidate tags into individual dictionaries
    six.print_(u'globals: aggregating results', file=output)
    addr, tags = dict(faddr), dict(ftags)
    for k, v in six.iteritems(daddr):
        addr[k] = addr.get(k, 0) + v
    for k, v in six.iteritems(dtags):
        tags[k] = tags.get(k, 0) + v

    six.print_(u"globals: found {:d} addresses".format(len(addr)), file=output)
    six.print_(u"globals: found {:d} tags".format(len(tags)), file=output)

    return addr, tags 
开发者ID:arizvisa,项目名称:ida-minsc,代码行数:25,代码来源:tagfix.py

示例15: globals

# 需要导入模块: import six [as 别名]
# 或者: from six import print_ [as 别名]
def globals():
    '''Re-build the cache for all of the globals in the database.'''

    # read all function and data tags
    addr, tags = fetch_globals()

    # update the global state
    six.print_(u'globals: updating global name refs', file=output)
    for k, v in six.iteritems(tags):
        internal.comment.globals.set_name(k, v)

    six.print_(u'globals: updating global address refs', file=output)
    for k, v in six.iteritems(addr):
        internal.comment.globals.set_address(k, v)

    return addr, tags 
开发者ID:arizvisa,项目名称:ida-minsc,代码行数:18,代码来源:tagfix.py


注:本文中的six.print_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。