change all userinputs to new function
This commit is contained in:
81
timeTrack.py
81
timeTrack.py
@@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# timeTrack.py
|
# timeTrack.py
|
||||||
# by 4nima
|
# by 4nima
|
||||||
# v.2.1.0
|
# v.2.1.1
|
||||||
#
|
#
|
||||||
#########################
|
#########################
|
||||||
# simple time tracking with database
|
# simple time tracking with database
|
||||||
@@ -417,31 +417,25 @@ class TimeTrack:
|
|||||||
else:
|
else:
|
||||||
logging.debug('Event younger than 1 day')
|
logging.debug('Event younger than 1 day')
|
||||||
print('Vergangene Zeit: >{} Stunden'.format(int(elapsed.seconds/3600)))
|
print('Vergangene Zeit: >{} Stunden'.format(int(elapsed.seconds/3600)))
|
||||||
|
|
||||||
|
printtext = [
|
||||||
|
'Wie soll mit dem Event verfahren werden?',
|
||||||
|
'[1] fortsetzen',
|
||||||
|
'[2] löschen',
|
||||||
|
'[0] abbrechen'
|
||||||
|
]
|
||||||
|
userinput = self.userchoise(printtext, 3)
|
||||||
|
self.clear_screen()
|
||||||
|
|
||||||
userinput = 0
|
if userinput == 1:
|
||||||
while not 0 < int(userinput) < 4:
|
|
||||||
print('Soll das Event fortgesetzt oder gelöscht werden?')
|
|
||||||
print('[1] für fortsetzen')
|
|
||||||
print('[2] für löschen')
|
|
||||||
print('[3] für abbrechen')
|
|
||||||
userinput = input('Aktion: ')
|
|
||||||
logging.debug('User input: {}'.format(userinput))
|
|
||||||
try:
|
|
||||||
int(userinput)
|
|
||||||
except ValueError:
|
|
||||||
userinput = 0
|
|
||||||
self.clear_screen()
|
|
||||||
|
|
||||||
if userinput == "1":
|
|
||||||
logging.debug('Event should be continued')
|
logging.debug('Event should be continued')
|
||||||
self.time_stop()
|
self.time_stop()
|
||||||
elif userinput == "2":
|
elif userinput == 2:
|
||||||
logging.info('Event should be deleted (eventid: {})'.format(data[0]))
|
logging.info('Event should be deleted (eventid: {})'.format(data[0]))
|
||||||
self.delete_event(data[0])
|
self.delete_event(data[0])
|
||||||
self.time_start()
|
self.time_start()
|
||||||
else:
|
else:
|
||||||
logging.debug('Terminated by the user')
|
self.start_interactive_mode()
|
||||||
exit()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.debug('Event continues (eventid{})'.format(data[0]))
|
logging.debug('Event continues (eventid{})'.format(data[0]))
|
||||||
@@ -454,21 +448,16 @@ class TimeTrack:
|
|||||||
logging.debug('Event stop progess is started')
|
logging.debug('Event stop progess is started')
|
||||||
if data:
|
if data:
|
||||||
self.clear_screen()
|
self.clear_screen()
|
||||||
userinput = 0
|
printtext = [
|
||||||
while not 0 < int(userinput) < 4:
|
'Event von {} Uhr beenden?'.format(data[1].strftime("%H:%M")),
|
||||||
print('Event von {} Uhr beenden?'.format(data[1].strftime("%H:%M")))
|
'[1] für beenden',
|
||||||
print('[1] für beenden')
|
'[2] für löschen',
|
||||||
print('[2] für löschen')
|
'[0] für abbrechen'
|
||||||
print('[3] für abbrechen')
|
]
|
||||||
userinput = input('Aktion: ')
|
userinput = self.userchoise(printtext, 3)
|
||||||
logging.debug('User input: {}'.format(userinput))
|
self.clear_screen()
|
||||||
try:
|
|
||||||
int(userinput)
|
|
||||||
except ValueError:
|
|
||||||
userinput = 0
|
|
||||||
self.clear_screen()
|
|
||||||
|
|
||||||
if userinput == "1":
|
if userinput == 1:
|
||||||
logging.debug('Event is ended')
|
logging.debug('Event is ended')
|
||||||
print('Eingabe beenden mittels doppelter Leerzeile.')
|
print('Eingabe beenden mittels doppelter Leerzeile.')
|
||||||
print('Durchgeführte Tätigkeiten:')
|
print('Durchgeführte Tätigkeiten:')
|
||||||
@@ -510,30 +499,24 @@ class TimeTrack:
|
|||||||
self.clear_screen()
|
self.clear_screen()
|
||||||
self.print_time_entry(STARTTIME=data[1], ENDTIME=endtime, ACTIVITY=action)
|
self.print_time_entry(STARTTIME=data[1], ENDTIME=endtime, ACTIVITY=action)
|
||||||
print('Zeiteintrag wurde gespeichert.')
|
print('Zeiteintrag wurde gespeichert.')
|
||||||
userinput = 0
|
printtext = [
|
||||||
while not 0 < int(userinput) < 3:
|
'Nächsten Zeiteintrag beginnen ?',
|
||||||
print('Nächsten Zeiteintrag beginnen ?')
|
'[1] Ja',
|
||||||
print('[1] Ja')
|
'[0] Nein'
|
||||||
print('[2] Nein')
|
]
|
||||||
userinput = input('Aktion: ')
|
userinput = self.userchoise(printtext)
|
||||||
logging.debug('User input: {}'.format(userinput))
|
self.clear_screen()
|
||||||
try:
|
|
||||||
int(userinput)
|
|
||||||
except ValueError:
|
|
||||||
userinput = 0
|
|
||||||
self.clear_screen()
|
|
||||||
|
|
||||||
if userinput == "1":
|
if userinput == 1:
|
||||||
self.time_start()
|
self.time_start()
|
||||||
else:
|
else:
|
||||||
self.start_interactive_mode()
|
self.start_interactive_mode()
|
||||||
|
|
||||||
elif userinput == "2":
|
elif userinput == 2:
|
||||||
logging.info('Event should be deleted (eventid: {})'.format(data[0]))
|
logging.info('Event should be deleted (eventid: {})'.format(data[0]))
|
||||||
self.delete_event(data[0])
|
self.delete_event(data[0])
|
||||||
else:
|
else:
|
||||||
logging.debug('Terminated by the user')
|
self.start_interactive_mode()
|
||||||
exit()
|
|
||||||
|
|
||||||
## Interactive mode
|
## Interactive mode
|
||||||
#==================
|
#==================
|
||||||
|
|||||||
Reference in New Issue
Block a user