2010-05-11 17:04:40 +02:00
|
|
|
#!/usr/bin/python
|
2010-05-16 22:42:35 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-05-11 17:04:40 +02:00
|
|
|
|
2017-02-10 18:09:22 +01:00
|
|
|
import random
|
|
|
|
import sys
|
|
|
|
import traceback
|
|
|
|
|
2010-05-07 19:32:39 +02:00
|
|
|
from helpers import *
|
2017-02-20 13:19:03 +01:00
|
|
|
from text_interface.addstock import AddStockMenu
|
|
|
|
from text_interface.buymenu import BuyMenu
|
|
|
|
from text_interface.editing import *
|
|
|
|
from text_interface.faq import FAQMenu
|
|
|
|
from text_interface.helpermenus import Menu
|
|
|
|
from text_interface.mainmenu import MainMenu
|
|
|
|
from text_interface.miscmenus import ProductSearchMenu, TransferMenu, AdjustCreditMenu, UserListMenu, ShowUserMenu, \
|
|
|
|
ProductListMenu
|
2017-03-22 18:02:11 +01:00
|
|
|
from text_interface.printermenu import PrintLabelMenu
|
2017-02-20 13:19:03 +01:00
|
|
|
from text_interface.stats import *
|
2010-05-07 19:32:39 +02:00
|
|
|
|
2011-03-07 10:01:43 +01:00
|
|
|
random.seed()
|
2010-05-08 02:23:21 +02:00
|
|
|
|
2011-03-06 21:15:38 +01:00
|
|
|
|
2017-02-20 13:19:03 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
if not conf.stop_allowed:
|
|
|
|
signal.signal(signal.SIGQUIT, signal.SIG_IGN)
|
|
|
|
|
|
|
|
if not conf.stop_allowed:
|
|
|
|
signal.signal(signal.SIGTSTP, signal.SIG_IGN)
|
|
|
|
|
|
|
|
main = MainMenu('Dibbler main menu',
|
|
|
|
items=[BuyMenu(),
|
|
|
|
ProductListMenu(),
|
|
|
|
ShowUserMenu(),
|
|
|
|
UserListMenu(),
|
|
|
|
AdjustCreditMenu(),
|
|
|
|
TransferMenu(),
|
|
|
|
AddStockMenu(),
|
|
|
|
Menu('Add/edit',
|
|
|
|
items=[AddUserMenu(),
|
|
|
|
EditUserMenu(),
|
|
|
|
AddProductMenu(),
|
|
|
|
EditProductMenu(),
|
|
|
|
AdjustStockMenu(),
|
|
|
|
CleanupStockMenu(), ]),
|
|
|
|
ProductSearchMenu(),
|
|
|
|
Menu('Statistics',
|
|
|
|
items=[ProductPopularityMenu(),
|
|
|
|
ProductRevenueMenu(),
|
|
|
|
BalanceMenu(),
|
|
|
|
LoggedStatisticsMenu()]),
|
2017-03-22 18:02:11 +01:00
|
|
|
FAQMenu(),
|
|
|
|
PrintLabelMenu()
|
2017-02-20 13:19:03 +01:00
|
|
|
],
|
|
|
|
exit_msg='happy happy joy joy',
|
|
|
|
exit_confirm_msg='Really quit Dibbler?')
|
|
|
|
if not conf.quit_allowed:
|
|
|
|
main.exit_disallowed_msg = 'You can check out any time you like, but you can never leave.'
|
|
|
|
while True:
|
|
|
|
# noinspection PyBroadException
|
2015-10-03 20:41:29 +02:00
|
|
|
try:
|
2017-02-20 13:19:03 +01:00
|
|
|
main.execute()
|
|
|
|
except KeyboardInterrupt:
|
2018-08-19 16:38:45 +02:00
|
|
|
print('')
|
|
|
|
print('Interrupted.')
|
2017-02-20 13:19:03 +01:00
|
|
|
except:
|
2018-08-19 16:38:45 +02:00
|
|
|
print('Something went wrong.')
|
|
|
|
print('%s: %s' % (sys.exc_info()[0], sys.exc_info()[1]))
|
2017-02-20 13:19:03 +01:00
|
|
|
if conf.show_tracebacks:
|
|
|
|
traceback.print_tb(sys.exc_info()[2])
|
2015-10-03 20:41:29 +02:00
|
|
|
else:
|
2017-02-20 13:19:03 +01:00
|
|
|
break
|
2018-08-19 16:38:45 +02:00
|
|
|
print('Restarting main menu.')
|