Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import yaml
  2. from getpass import getpass
  3. from common.general import clear_screen
  4. import os, sys
  5.  
  6. menu = {}
  7. menu[1] = {'text': 'Dump owners', 'command': 'dump_owners.py'}
  8. menu[2] = {'text': 'Run spreadsheets proof', 'command': 'run_proofs.py {last_report_date} all'}
  9. menu[3] = {'text': 'Dump owners', 'command': 'dump_owners.py'}
  10. menu[99] = {'text': 'Exit', 'command': 'exit'}
  11.  
  12. # clear_screen()
  13. print('')
  14. print('')
  15.  
  16. with open('config.yaml', "r") as f:
  17. cfg = yaml.load(f)
  18.  
  19. last_report_date = cfg['config']['last_report_date']
  20.  
  21.  
  22.  
  23. while True:
  24. for key, value in menu.items():
  25. print('{0:>4}. {1}'.format(key, value['text']))
  26.  
  27. while True:
  28. try:
  29. option = input("Enter menu item (or x to cancel): ")
  30. if option == 'x':
  31. os._exit(0)
  32.  
  33. option = int(option)
  34. if option in menu:
  35. print('')
  36. break
  37. except:
  38. print('invalid response... please try again.')
  39.  
  40. command = menu[option]
  41. if command['command'] == 'exit':
  42. sys.exit()
  43.  
  44. cmd = command['command'].replace('{last_report_date}', last_report_date)
  45.  
  46. print('Running: ' + cmd)
  47.  
  48. os.system('python ' + cmd)
  49. print('')
  50.  
  51.  
  52. # print(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement