mirror of https://github.com/WikiTeam/wikiteam
Force str() everywhere (also misc stdout formatting)
Signed-off-by: Elsie Hupp <github@elsiehupp.com>pull/446/head
parent
a436ea191c
commit
efcde3006e
Binary file not shown.
Binary file not shown.
@ -1,8 +1,37 @@
|
||||
import itertools
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
def delay(config={}, session=None):
|
||||
"""Add a delay if configured for that"""
|
||||
if config["delay"] > 0:
|
||||
print("Sleeping... %.2f seconds..." % (config["delay"]))
|
||||
time.sleep(config["delay"])
|
||||
class Delay:
|
||||
|
||||
done: bool = True
|
||||
ellipses: str = "."
|
||||
|
||||
def animate(self):
|
||||
try:
|
||||
while not self.done:
|
||||
sys.stdout.write("\r " + self.ellipses)
|
||||
sys.stdout.flush()
|
||||
self.ellipses += "."
|
||||
time.sleep(0.1)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit()
|
||||
|
||||
def __init__(self, config={}, session=None):
|
||||
"""Add a delay if configured for that"""
|
||||
if config["delay"] > 0:
|
||||
self.done = False
|
||||
|
||||
ellipses_animation = threading.Thread(target=self.animate)
|
||||
ellipses_animation.start()
|
||||
|
||||
# sys.stdout.write("\rSleeping %.2f seconds..." % (config["delay"]))
|
||||
# sys.stdout.flush()
|
||||
|
||||
time.sleep(config["delay"])
|
||||
self.done = True
|
||||
|
||||
sys.stdout.write("\r \r")
|
||||
sys.stdout.flush()
|
||||
|
Loading…
Reference in New Issue