blob: 7427783ed5acc561e99a4a9f9e83d4be00cc4b3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/python3
import sys
class OutputManager:
def __init__(self):
self.last_line_length = 0
self.echo_output = True
def line_break(self):
if self.echo_output:
sys.stdout.write('\n')
sys.stdout.flush()
return self
def error(self, string):
if self.echo_output:
self._erase_line()
string = '[-] ' + string
self.last_line_length = len(string)
sys.stdout.write(string)
sys.stdout.flush()
return self
def normal(self, string):
if self.echo_output:
self._erase_line()
self.last_line_length = len(string)
sys.stdout.write(string)
sys.stdout.flush()
return self
def _erase_line(self):
sys.stdout.write('\r' + ' ' * self.last_line_length + '\r')
return self
|