本文整理汇总了Python中six.print_函数的典型用法代码示例。如果您正苦于以下问题:Python print_函数的具体用法?Python print_怎么用?Python print_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
cmds = ["jconsole", "localhost:%s" % self.node.jmx_port]
try:
subprocess.call(cmds)
except OSError:
print_("Could not start jconsole. Please make sure jconsole can be found in your $PATH.")
exit(1)
示例2: validate
def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, load_cluster=True)
try:
self.setting = common.parse_settings(args)
except common.ArgumentError as e:
print_(str(e), file=sys.stderr)
exit(1)
示例3: print_help
def print_help():
print_("""avaliable command:
help --- show this help
ls --- list friends and groups
talk --- talk to friends
quit --- quit program
""")
示例4: build_static
def build_static(self, *args, **options):
"""
Builds the static files directory as well as robots.txt and favicon.ico
"""
logger.debug("Building static directory")
if self.verbosity > 1:
six.print_("Building static directory")
management.call_command("collectstatic", interactive=False, verbosity=0)
target_dir = os.path.join(self.build_dir, settings.STATIC_URL[1:])
if os.path.exists(settings.STATIC_ROOT) and settings.STATIC_URL:
if getattr(settings, "BAKERY_GZIP", False):
self.copytree_and_gzip(settings.STATIC_ROOT, target_dir)
# if gzip isn't enabled, just copy the tree straight over
else:
shutil.copytree(settings.STATIC_ROOT, target_dir)
# If they exist in the static directory, copy the robots.txt
# and favicon.ico files down to the root so they will work
# on the live website.
robot_src = os.path.join(target_dir, "robots.txt")
if os.path.exists(robot_src):
shutil.copy(robot_src, os.path.join(settings.BUILD_DIR, "robots.txt"))
favicon_src = os.path.join(target_dir, "favicon.ico")
if os.path.exists(favicon_src):
shutil.copy(favicon_src, os.path.join(settings.BUILD_DIR, "favicon.ico"))
示例5: findA_M0
def findA_M0():
prefix = b"\x00" + b"\xf2" + b"\x00" * (256 - 2 - 16)
c = mysrp.Client()
import time
start = time.time()
num_near_misses = 0
for count in thencount():
if count > 300 and count % 500 == 0:
now = time.time()
print_(count, "tries", now - start)
start = now
if count > 1000000:
raise ValueError("unable to find suitable value in reasonable time")
a_str = prefix + binascii.unhexlify("%032x" % count)
assert len(a_str) == 2048 / 8, (len(a_str), 2048 / 8)
a = mysrp.bytes_to_long(a_str)
A = c.one(a)
# require that the computed M1 has a leading zero
c.two(B, srpSalt, emailUTF8, srpPW)
if c._debug_M1_bytes[0:1] != b"\x00":
continue
print_("found a on count", count)
printdec("private a (normally random)", a)
printhex("private a (hex)", a_str, groups_per_line=2)
return a, A
示例6: register
def register(self):
"""Registers the workflow type and task types with SWF
It is necessary to do this each time a new task is added to a workflow.
It is safest to run this before each call to :meth:`execute` if you are
just launching a workflow from a cron. However, if you are launching
many workflows and calling :meth:`execute` many times, you may want to
consider calling this method only when necessary because it can
contribute to an SWF API throttling issue.
"""
tasks = get_task_configurations(self.workflow_task)
registerables = []
registerables.append(swf.Domain(name=self.domain))
task_dats = set((t['task_family'], t['task_list'])
for (t_id, t) in iteritems(tasks))
for task_dat in task_dats:
registerables.append(swf.ActivityType(domain=self.domain,
version=self.version,
name=task_dat[0],
task_list=task_dat[1]))
wf_name = self.workflow_task.task_family
wf_task_list = getattr(self.workflow_task, 'swf_task_list', 'default')
registerables.append(swf.WorkflowType(domain=self.domain,
version=self.version,
name=wf_name,
task_list=wf_task_list))
for swf_entity in registerables:
try:
swf_entity.register()
print_(swf_entity.name, 'registered successfully')
except (SWFDomainAlreadyExistsError, SWFTypeAlreadyExistsError):
print_(swf_entity.__class__.__name__, swf_entity.name,
'already exists')
示例7: print_result
def print_result(self, result):
if self.args.get('format') is None:
stylesheet = self.args.get('stylesheet')
show_conn_info = bool(stylesheet)
elif self.args.get('format') == 'none':
stylesheet = None
show_conn_info = False
elif self.args.get('format') == 'xml':
stylesheet = None
show_conn_info = True
else:
stylesheet = self.args.get('stylesheet')
if not stylesheet:
stylesheet = self.config.get_region_option('vpn-stylesheet')
if stylesheet:
stylesheet = stylesheet.format(format=self.args['format'])
else:
self.log.warn('current region has no stylesheet')
msg = ('current region has no XSLT stylesheet to format '
'output; connection info will not be shown (try '
'specifying one with "--stylesheet" or using '
'"--format xml")')
six.print_(msg, file=sys.stderr)
show_conn_info = bool(stylesheet)
for vpn in result.get('vpnConnectionSet', []):
self.print_vpn_connection(vpn, show_conn_info=show_conn_info,
stylesheet=stylesheet)
示例8: showStats
def showStats( self ):
'''Shows a few stats on standard output. Shouldn't be called before buildGraph().
'''
if self.numInputSentences > 0:
six.print_( "Character " + self.charLabel + " has a total of " + str( self.numInputWords ) + " words over " + str( self.numInputSentences ) + " sentences for an average of " + str( self.numInputWords / self.numInputSentences ) + " words/sentence.")
else:
six.print_( "Character " + self.charLabel + " has a total of " + str( self.numInputWords ) + " words." )
示例9: run
def run(self):
try:
common.invalidate_cache()
except Exception as e:
print_(str(e), file=sys.stderr)
print_("Error while deleting cache. Please attempt manually.")
exit(1)
示例10: n_mult
def n_mult(a,b):
if isinstance(a,N_polynomial) and isinstance(b,N_polynomial):
total={}
for keya in a.terms_:
for keyb in b.terms_:
m = prodMonomials(keya,keyb)
coeff=a.terms_[keya]*b.terms_[keyb]
if m in total:
newc = coeff + total[m]
if newc==0:
del total[m]
else:
total[m]=newc
else:
total[m]=coeff
return N_polynomial(n_ar=total)
if isinstance(a,N_constantNum) and isinstance(b,N_polynomial):
# print "multiplyBy ", a.a
if(a.num_==1):
return b
out=b.copy()
out.scalarMultiply(a.num_)
return out
if isinstance(a,N_constantNum) and isinstance(b,N_constantNum):
return N_constantNum(a.num_*b.num_)
print_(a, b)
raise NotImplementedError()
示例11: start
def start(self):
""" Start the monitor """
if CURSES_SUPPORTED:
curses.wrapper(self.run)
else:
six.print_("Your system does not have curses installed. "
"Cannot use 'watch'")
示例12: run_cqlsh
def run_cqlsh(self, cmds=None, show_output=False, cqlsh_options=[]):
cdir = self.get_cassandra_dir()
cli = common.join_bin(cdir, 'bin', 'cqlsh')
env = common.make_cassandra_env(cdir, self.get_path())
host = self.network_interfaces['thrift'][0]
port = self.network_interfaces['thrift'][1]
args = cqlsh_options + [ host, str(port) ]
sys.stdout.flush()
if cmds is None:
os.execve(cli, [ common.platform_binary('cqlsh') ] + args, env)
else:
p = subprocess.Popen([ cli ] + args, env=env, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
for cmd in cmds.split(';'):
p.stdin.write(cmd + ';\n')
p.stdin.write("quit;\n")
p.wait()
for err in p.stderr:
print_("(EE) ", err, end='')
if show_output:
i = 0
for log in p.stdout:
# first four lines are not interesting
if i >= 4:
print_(log, end='')
i = i + 1
示例13: __init__
def __init__(self, ncpus="autodetect", interface="0.0.0.0",
broadcast="255.255.255.255", port=None, secret=None,
timeout=None, restart=False, proto=2, socket_timeout=3600, pid_file=None):
pp.Server.__init__(self, ncpus, (), secret, restart,
proto, socket_timeout)
if pid_file:
with open(pid_file, 'w') as pfile:
six.print_(os.getpid(), file=pfile)
atexit.register(os.remove, pid_file)
self.host = interface
self.bcast = broadcast
if port is not None:
self.port = port
else:
self.port = ppc.randomport()
self.timeout = timeout
self.ncon = 0
self.last_con_time = time.time()
self.ncon_lock = threading.Lock()
self.logger.debug("Strarting network server interface=%s port=%i"
% (self.host, self.port))
if self.timeout is not None:
self.logger.debug("ppserver will exit in %i seconds if no "\
"connections with clients exist" % (self.timeout))
ppc.start_thread("timeout_check", self.check_timeout)
示例14: on_search
def on_search(args):
# TODO: Decode via actual tty encoding
try:
q = args.q[0].decode("utf-8")
except AttributeError:
q = args.q[0]
pkg_names = set()
# First, check for exact case-insensitive name matches
for pkg in session.query(Package).filter(collate(Package.name,"NOCASE")==q).all():
pkg_names.add(pkg.name)
# Check for substring name matches
for pkg in session.query(Package).filter(Package.name.like(u('%{0}%').format(q))).all():
pkg_names.add(pkg.name)
# Check for description matches
for pkg in session.query(Package).filter(Package.description.like(u('%{0}%').format(q))).all():
pkg_names.add(pkg.name)
if len(pkg_names) == 0:
print_(u('No matching packages found.'))
return
# Nice column formatting
max_len_name = max( len(name) for name in pkg_names )
for pkg_name in sorted(pkg_names):
pkg = session.query(Package).get(pkg_name)
print_(u('{name:{max_len_name}} {version:10} {desc}'.format(name=pkg.name, version=pkg.version, desc=pkg.description, max_len_name=max_len_name)))
示例15: _create
def _create(self, name, stack_id, username=None, ssh_keys=None,
user_scripts=None, node_groups=None, connectors=None,
wait=False):
"""
CLI-only; cluster create command
"""
if ssh_keys is None:
ssh_keys = [DEFAULT_SSH_KEY]
try:
return self.create(name, stack_id, username, ssh_keys,
user_scripts, node_groups, connectors, wait)
except error.RequestError as exc:
if not (ssh_keys == [DEFAULT_SSH_KEY] and
'Cannot find requested ssh_keys' in str(exc)):
raise
six.print_('SSH key does not exist; creating...')
# Create the SSH key for the user and then attempt to create the
# cluster again
with open(expand('$HOME/.ssh/id_rsa.pub')) as f:
self._client.credentials.create_ssh_key(
DEFAULT_SSH_KEY,
f.read().strip())
return self.create(name, stack_id, username, ssh_keys,
user_scripts, node_groups, connectors, wait)