-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatusUpdater.py
56 lines (47 loc) · 1.48 KB
/
StatusUpdater.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import enum
import os
import sys
class StatusUpdater:
def __init__(self):
self.status = self.UploadState
self.previousState = self.status.setup
self.LOGGING = False
self.clear = True
class UploadState(enum.Enum):
setup = 1
openingFile = 2
openingBatch = 3
uploadingFile = 4
uploadingBatch = 5
interpretingReply = 6
interpretingReplies = 7
waitingForSuccessfulUpload = 8
uploadSuccessful = 9
uploadUnsuccessful = 10
queueOverloadDelay = 11
uploadTimeout = 12
class UploadStateDescriptions(enum.Enum):
setup = 'Initializing'
openingFile = 'Opening file'
openingBatch = 'Opening the batch of files'
uploadingFile = 'Uploading file'
uploadingBatch = 'Uploading the batch of files'
interpretingReply = 'Interpreting reply'
interpretingReplies = 'Interpeties replies of the batch upload'
waitingForSuccessfulUpload = 'Waiting for replay to be parsed'
uploadSuccessful = 'Replay successfully uploaded'
uploadUnsuccessful = 'Replay was not uploaded successfully'
queueOverloadDelay = 'Delaying the next upload to not overload the queue'
uploadTimeout = 'Replay parsing has taken too long'
def clearScreen(self):
if self.clear:
os.system('cls' if os.name == 'nt' else 'clear')
def update(self, state, status):
if not self.LOGGING:
return
sys.stdout.write('\n\n\r')
sys.stdout.flush()
if state != self.previousState:
sys.stdout.write('Current state: ' + str(state.name) + ' ' * 40)
self.previousState = state
sys.stdout.flush()