MCPcopy
hub / github.com/Gallopsled/pwntools / pause

Function pause

pwnlib/ui.py:258–304  ·  view source on GitHub ↗

r"""Waits for either user input or a specific number of seconds. Examples: >>> with context.local(log_level="INFO"): ... pause(1) [x] Waiting [x] Waiting: 1... [+] Waiting: Done >>> pause("whatever") Traceback (most recent call last):

(n=None)

Source from the content-addressed store, hash-verified

256 return x - 1
257
258def pause(n=None):
259 r"""Waits for either user input or a specific number of seconds.
260
261 Examples:
262
263 >>> with context.local(log_level="INFO"):
264 ... pause(1)
265 [x] Waiting
266 [x] Waiting: 1...
267 [+] Waiting: Done
268 >>> pause("whatever")
269 Traceback (most recent call last):
270 ...
271 ValueError: pause(): n must be a number or None
272
273 Tests:
274
275 >>> saved_stdin = sys.stdin
276 >>> try:
277 ... sys.stdin = io.TextIOWrapper(io.BytesIO(b"\n"))
278 ... with context.local(log_level="INFO"):
279 ... pause()
280 ... finally:
281 ... sys.stdin = saved_stdin
282 [*] Paused (press enter to continue)
283 >>> p = testpwnproc("pause()")
284 >>> b"Paused" in p.recvuntil(b"press any")
285 True
286 >>> p.send(b"x")
287 >>> _ = p.recvall()
288 """
289
290 if n is None:
291 if term.term_mode:
292 log.info('Paused (press any to continue)')
293 term.getkey()
294 else:
295 log.info('Paused (press enter to continue)')
296 raw_input('')
297 elif isinstance(n, six.integer_types):
298 with log.waitfor("Waiting") as l:
299 for i in range(n, 0, -1):
300 l.status('%d... ' % i)
301 time.sleep(1)
302 l.success()
303 else:
304 raise ValueError('pause(): n must be a number or None')
305
306def more(text):
307 r"""more(text)

Callers 2

mainFunction · 0.85
indented.pyFile · 0.85

Calls 5

raw_inputFunction · 0.90
infoMethod · 0.80
waitforMethod · 0.45
statusMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected