本文整理汇总了Python中__builtin__.print方法的典型用法代码示例。如果您正苦于以下问题:Python __builtin__.print方法的具体用法?Python __builtin__.print怎么用?Python __builtin__.print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类__builtin__
的用法示例。
在下文中一共展示了__builtin__.print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _menu_egg
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def _menu_egg(self, params):
eggs = [
'Number? Really? What do you think this is?',
'Roses are red, violets are blue..',
'Do you know what you are doing?',
'*grunt* *grunt* Nope. I got nothin\'.',
'Type that number again for super secret mode.',
'This is not Metasploit.',
'I think we need to go back to HowToH@ck 101.',
'Something something do more CTFs something something',
'Attempting to start Metasploit...',
'ctfhacker.com is the place to be.'
]
print(random.choice(eggs))
return
#==================================================
# WORKSPACE METHODS
#==================================================
示例2: show_banner
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def show_banner(self):
banner = open(os.path.join(self.data_path, 'banner.txt')).read()
banner_len = len(max(banner.split('\n'), key=len)) / 2
print(framework.Colors.N + banner + framework.Colors.N)
# print('{0:^{1}}'.format('%s[%s v%s, %s]%s' % (framework.Colors.G, self._name, __version__, __author__, framework.Colors.N), banner_len+8)) # +8 compensates for the color bytes
# print('%s[%s v%s, %s]%s' % (framework.Colors.B, self._name, __version__, __author__, framework.Colors.N), banner_len+8) # +8 compensates for the color bytes
print('')
counts = [(self.loaded_category[x], x) for x in self.loaded_category]
count_len = len(max([str(x[0]) for x in counts], key=len))
for count in sorted(counts, reverse=True):
cnt = '[%d]' % (count[0])
print('%s%s %s modules%s' % (framework.Colors.B, cnt.ljust(count_len+2), count[1].title(), framework.Colors.N))
# create dynamic easter egg command based on counts
setattr(self, 'do_%d' % count[0], self._menu_egg)
print('')
#==================================================
# COMMAND METHODS
#==================================================
示例3: do_workspaces
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def do_workspaces(self, params):
'''Manages workspaces'''
if not params:
self.help_workspaces()
return
params = params.split()
arg = params.pop(0).lower()
if arg == 'list':
self.table([[x] for x in self._get_workspaces()], header=['Workspaces'])
elif arg in ['add', 'select']:
if len(params) == 1:
if not self.init_workspace(params[0]):
self.output('Unable to initialize \'%s\' workspace.' % (params[0]))
else: print('Usage: workspace [add|select] <name>')
elif arg == 'delete':
if len(params) == 1:
if not self.delete_workspace(params[0]):
self.output('Unable to delete \'%s\' workspace.' % (params[0]))
else: print('Usage: workspace delete <name>')
else:
self.help_workspaces()
示例4: _menu_egg
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def _menu_egg(self, params):
self.logger.debug('')
eggs = [
'Really? A menu option? Try again.',
'You clearly need \'help\'.',
'That makes no sense to me.',
'*grunt* *grunt* Nope. I got nothin\'.',
'Wait for it...',
'This is not the Social Engineering Toolkit.',
'Don\'t you think if that worked the numbers would at least be in order?',
'Reserving that option for the next-NEXT generation of the framework.',
'You\'ve clearly got the wrong framework. Attempting to start SET...',
'Your mother called. She wants her menu driven UI back.',
'What\'s the samurai password?'
]
print(random.choice(eggs))
return
# ==================================================
# WORKSPACE METHODS
# ==================================================
示例5: _menu_egg
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def _menu_egg(self, params):
eggs = [
'Really? A menu option? Try again.',
'You clearly need \'help\'.',
'That makes no sense to me.',
'*grunt* *grunt* Nope. I got nothin\'.',
'Wait for it...',
'This is not the Social Engineering Toolkit.',
'Don\'t you think if that worked the numbers would at least be in order?',
'Reserving that option for the next-NEXT generation of the framework.',
'You\'ve clearly got the wrong framework. Attempting to start SET...',
'Your mother called. She wants her menu driven UI back.',
'What\'s the samurai password?'
]
print(random.choice(eggs))
return
#==================================================
# WORKSPACE METHODS
#==================================================
示例6: flaky_print
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def flaky_print(*args):
"""Wrapper for print that retries in case of IOError.
"""
count = 0
while count < 5:
count += 1
try:
orig_print(*args)
break
except IOError:
if count >= 5:
raise
pass
示例7: test_examples
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def test_examples(frontend, f):
# Test the examples with all available front-ends
print('frontend = %s. f = %s' % (frontend, f))
if not frontends[frontend]:
pytest.skip('%s is not installed. Skipping tests' % frontend)
utils.testFile(f[0], f[1], utils.sys.executable, frontend)
示例8: print
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def print(*args, **kwargs):
file = kwargs.get("file", _coconut_sys.stdout)
flush = kwargs.get("flush", False)
if "flush" in kwargs:
del kwargs["flush"]
if _coconut.hasattr(file, "encoding") and file.encoding is not None:
_coconut_print(*(_coconut_unicode(x).encode(file.encoding) for x in args), **kwargs)
else:
_coconut_print(*(_coconut_unicode(x).encode() for x in args), **kwargs)
if flush:
file.flush()
示例9: spool_print
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def spool_print(*args, **kwargs):
with _print_lock:
if framework.Framework._spool:
framework.Framework._spool.write('%s\n' % (args[0]))
framework.Framework._spool.flush()
if 'console' in kwargs and kwargs['console'] is False:
return
# new print function must still use the old print function via the backup
__builtin__._print(*args, **kwargs)
# make a builtin backup of the original print function
示例10: do_snapshots
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def do_snapshots(self, params):
'''Manages workspace snapshots'''
if not params:
self.help_snapshots()
return
params = params.split()
arg = params.pop(0).lower()
if arg == 'list':
snapshots = self._get_snapshots()
if snapshots:
self.table([[x] for x in snapshots], header=['Snapshots'])
else:
self.output('This workspace has no snapshots.')
elif arg == 'take':
from datetime import datetime
snapshot = 'snapshot_%s.db' % (datetime.strftime(datetime.now(), '%Y%m%d%H%M%S'))
src = os.path.join(self.workspace, 'data.db')
dst = os.path.join(self.workspace, snapshot)
shutil.copyfile(src, dst)
self.output('Snapshot created: %s' % (snapshot))
elif arg == 'load':
if len(params) == 1:
# warn about overwriting current state
if params[0] in self._get_snapshots():
src = os.path.join(self.workspace, params[0])
dst = os.path.join(self.workspace, 'data.db')
shutil.copyfile(src, dst)
self.output('Snapshot loaded: %s' % (params[0]))
else:
self.error('No snapshot named \'%s\'.' % (params[0]))
else: print('Usage: snapshots [load] <name>')
elif arg == 'delete':
if len(params) == 1:
if params[0] in self._get_snapshots():
os.remove(os.path.join(self.workspace, params[0]))
self.output('Snapshot removed: %s' % (params[0]))
else:
self.error('No snapshot named \'%s\'.' % (params[0]))
else: print('Usage: snapshots [delete] <name>')
else:
self.help_snapshots()
示例11: help_workspaces
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def help_workspaces(self):
print(getattr(self, 'do_workspaces').__doc__)
print('')
print('Usage: workspaces [list|add|select|delete]')
print('')
示例12: help_snapshots
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def help_snapshots(self):
print(getattr(self, 'do_snapshots').__doc__)
print('')
print('Usage: snapshots [list|take|load|delete]')
print('')
#==================================================
# COMPLETE METHODS
#==================================================
示例13: spool_print
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def spool_print(*args, **kwargs):
with _print_lock:
if framework.Framework._spool:
framework.Framework._spool.write('%s\n' % (args[0]))
framework.Framework._spool.flush()
if 'console' in kwargs and kwargs['console'] is False:
return
# new print function must still use the old print function
# via the backup
__builtin__._print(*args, **kwargs)
# make a builtin backup of the original print function
示例14: show_banner
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def show_banner(self):
self.logger.debug('')
banner = self.read_file(os.path.join(self.data_path, 'banner.txt'))
banner_len = len(max(banner.split('\n'), key=len))
print(banner)
print('{0:^{1}}'.format('%s[%s v%s, %s]%s' % (
framework.Colors.O,
self._name,
__version__,
__author__,
framework.Colors.N), banner_len+8))
# +8 compensates for the color bytes
print('')
counts = [(self.loaded_category[x], x) for x in self.loaded_category]
count_len = len(max([str(x[0]) for x in counts], key=len))
# modules info
for count in sorted(counts, reverse=True):
cnt = '[%d]' % (count[0])
print('%s%s %s modules%s' % (
framework.Colors.B,
cnt.ljust(count_len+2),
count[1].title(),
framework.Colors.N))
# create dynamic easter egg command based on counts
setattr(self, 'do_%d' % count[0], self._menu_egg)
print('')
# ==================================================
# COMMAND METHODS
# ==================================================
示例15: do_workspaces
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import print [as 别名]
def do_workspaces(self, params):
'''Manages workspaces'''
self.logger.debug('')
if not params:
self.help_workspaces()
return
params = params.split()
arg = params.pop(0).lower()
if arg == 'list':
self.table([[x] for x in self._get_workspaces()],
header=['Workspaces'])
elif arg in ['add', 'select']:
if len(params) == 1:
if not self.init_workspace(params[0]):
self.output(
'Unable to initialize \'%s\' workspace.' % (params[0]))
else:
print('Usage: workspace [add|select] <name>')
elif arg == 'delete':
if len(params) == 1:
if not self.delete_workspace(params[0]):
self.output(
'Unable to delete \'%s\' workspace.' % (params[0]))
else:
print('Usage: workspace delete <name>')
else:
self.help_workspaces()