Repository for M.A.I.L system's recording client.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

main.py 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import tkinter
  2. import json
  3. import paramiko
  4. import time
  5. from tkinter import messagebox
  6. window = tkinter.Tk()
  7. settings =[]
  8. customer_code = ''
  9. surgery_date = str(time.strftime('%Y%m%d', time.localtime(time.time())))
  10. with open('./settings.json', encoding='utf-8')as json_file:
  11. json_data = json.load(json_file)
  12. settings.append(json_data['window_name'])
  13. settings.append(json_data['window_position'])
  14. settings.append(json_data['branch_location'])
  15. settings.append(json_data['surgery_room_number'])
  16. settings.append(json_data['ddns'])
  17. settings.append(json_data['account']) #settings[5]
  18. settings.append(json_data['password']) #settings[6]
  19. window.title(settings[0])
  20. window.geometry(settings[1])
  21. window.resizable(False,False)
  22. def sshConnect():
  23. ssh = paramiko.SSHClient()
  24. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  25. ssh.connect(settings[4],port= settings[3], username=settings[5], password=settings[6])
  26. stdin, stdout, stderr = ssh.exec_command('echo this is paramiko')
  27. # TODO: 여기에 스크립트 명령어 입력
  28. print(stdout.readlines())
  29. label_branch = tkinter.Label(window, text = '지점 위치: ' + settings[2] + ' / 수술방 번호: ' + str(settings[3]))
  30. label_customer_code = tkinter.Label(window, text="고객번호(지점 번호 포함 9자리)")
  31. def dummyexit():
  32. pass
  33. def askInformation(customer_code,surgery_date):
  34. cs = customer_code
  35. sd = surgery_date
  36. if len(cs) != 9:
  37. err_box = messagebox.showerror("고객 번호 오류", '지점 번호를 포함한 9자리를 입력해주세요.')
  38. else:
  39. msg_box = messagebox.askquestion("입력 정보 확인", "입력하신 정보가 정확한지 확인해주세요.\n고객 번호: "+customer_code + '\n 수술일자: ' + surgery_date +'\n\nYes를 눌러 기록 시작을,\n입력 정보의 수정을 원하시면 No을 눌러 변경해주세요.')
  40. #TODO: try: 형태로 고칠 것. Err 메세지도 종류 정할 것
  41. if msg_box == 'yes':
  42. err_status = True
  43. if err_status == False:
  44. label_recording = tkinter.Label(window, text='분석 PC에 문제가 발생하였습니다.\nHOBIT LAB으로 연락 부탁드립니다.\n내선번호: 1237 \n에러 코드: REQUEST TIME OUT')
  45. label_recording.pack()
  46. else:
  47. #TODO: paramiko로 ssh 접속 후 도커 명령어 보낼 것
  48. button_confirm['text'] = '기록 종료'
  49. window.protocol('WM_DELETE_WINDOW', dummyexit)
  50. label_recording = tkinter.Label(window, text='MAIL system에 수술을 기록 중입니다.\n기록 중단을 원할 시 \n기록 종료 버튼을 눌러주세요.')
  51. label_recording.pack()
  52. def askQuit():
  53. msg_box = messagebox.askquestion("기록 중지 확인", '기록을 중지하시겠습니까?')
  54. if msg_box == 'yes':
  55. #TODO: docker 중지 명령어 보내기
  56. sshConnect()
  57. window.destroy()
  58. def buttonAction(event):
  59. if button_confirm['text'] == '입력완료':
  60. customer_code = str(entry_customer_code.get())
  61. askInformation(customer_code, surgery_date)
  62. else:
  63. askQuit()
  64. # def fillSurgeryDate():
  65. entry_customer_code = tkinter.Entry(window)
  66. entry_surgery_date = tkinter.Entry(window)
  67. button_confirm = tkinter.Button(window, text="입력완료", width=20, height=2)
  68. button_confirm.bind("<Button-1>", buttonAction)
  69. label_branch.pack()
  70. label_customer_code.pack()
  71. entry_customer_code.pack()
  72. button_confirm.pack()
  73. window.mainloop()