本文整理匯總了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
示例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_()
示例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 #
#####################
示例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
示例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
示例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
示例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_("")
示例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)
#############################################################
示例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="")
示例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"])
示例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')
示例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
示例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
示例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
示例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