本文整理匯總了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()