| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- import tkinter
- import json
- import paramiko
- import time
- from tkinter import messagebox
-
-
- window = tkinter.Tk()
- settings =[]
- customer_code = ''
- surgery_date = str(time.strftime('%Y%m%d', time.localtime(time.time())))
-
-
- with open('./settings.json', encoding='utf-8')as json_file:
- json_data = json.load(json_file)
- settings.append(json_data['window_name'])
- settings.append(json_data['window_position'])
- settings.append(json_data['branch_location'])
- settings.append(json_data['surgery_room_number'])
- settings.append(json_data['ddns'])
- settings.append(json_data['account']) #settings[5]
- settings.append(json_data['password']) #settings[6]
-
- window.title(settings[0])
- window.geometry(settings[1])
- window.resizable(False,False)
-
- def sshConnect(cs, sd):
- cs = cs
- sd = sd
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(settings[4],port= settings[3], username=settings[5], password=settings[6])
- data_root_dir = './data/'+cs+sd
- stdin, stdout, stderr = ssh.exec_command('mkdir ' + data_root_dir)
- #TODO: 여기에 도커 명령어 및 동시 녹화 코드 입력
- stdin, stdout, stderr = ssh.exec_command('docker run --rm --name mail_recorder --gpus 1 --privileged -v /dev:/dev -v /home/mc365/sources:/sources -v /home/mc365/data/'+cs+sd+':/data/'+cs+sd+' stereolabs/zed:3.5-gl-devel-cuda11.0-ubuntu18.04 python3 /sources/recorder.py')
-
- print(stdout.readlines())
-
- def sshQuit(cs, sd):
- cs = cs
- sd = sd
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(settings[4],port= settings[3], username=settings[5], password=settings[6])
-
- stdin, stdout, stderr = ssh.exec_command('docker stop mail_recorder')
- stdin, stdout, stderr = ssh.exec_command('docker run --rm --name extract_01 --gpus 0 --privileged -v /dev:/dev -v /home/mc365/sources:/sources -v /home/mc365/data/'+cs+sd+':/data/'+cs+sd+' ellishuntingmoon/mailsys_extract:latest python3 /sources/extract_01.py')
- stdin, stdout, stderr = ssh.exec_command('docker run --rm --name extract_02 --gpus 1 --privileged -v /dev:/dev -v /home/mc365/sources:/sources -v /home/mc365/data/'+cs+sd+':/data/'+cs+sd+' ellishuntingmoon/mailsys_extract:latest python3 /sources/extract_02.py')
-
- # TODO: 여기에 스크립트 명령어 입력
- print(stdout.readlines())
-
-
- label_branch = tkinter.Label(window, text = '지점 위치: ' + settings[2] + ' / 수술방 번호: ' + str(settings[3]))
- label_customer_code = tkinter.Label(window, text="고객번호(지점 번호 포함 9자리)")
-
-
- def dummyexit():
- pass
-
- def askInformation(customer_code,surgery_date):
- cs = customer_code
- sd = surgery_date
-
- if len(cs) != 9:
- err_box = messagebox.showerror("고객 번호 오류", '지점 번호를 포함한 9자리를 입력해주세요.')
- else:
- msg_box = messagebox.askquestion("입력 정보 확인", "입력하신 정보가 정확한지 확인해주세요.\n고객 번호: "+customer_code + '\n 수술일자: ' + surgery_date +'\n\nYes를 눌러 기록 시작을,\n입력 정보의 수정을 원하시면 No을 눌러 변경해주세요.')
- #TODO: try: 형태로 고칠 것. Err 메세지도 종류 정할 것
- if msg_box == 'yes':
- err_status = True
-
- if err_status == False:
- label_recording = tkinter.Label(window, text='분석 PC에 문제가 발생하였습니다.\nHOBIT LAB으로 연락 부탁드립니다.\n내선번호: 1237 \n에러 코드: REQUEST TIME OUT')
- label_recording.pack()
- else:
- #TODO: paramiko로 ssh 접속 후 도커 명령어 보낼 것
- sshConnect(cs, sd)
- button_confirm['text'] = '기록 종료'
- window.protocol('WM_DELETE_WINDOW', dummyexit)
-
- label_recording = tkinter.Label(window, text='MAIL system에 수술을 기록 중입니다.\n기록 중단을 원할 시 \n기록 종료 버튼을 눌러주세요.')
- label_recording.pack()
-
- def askQuit(customer):
- msg_box = messagebox.askquestion("기록 중지 확인", '기록을 중지하시겠습니까?')
- if msg_box == 'yes':
- #TODO: docker 중지 명령어 보내기
- sshQuit()
- window.destroy()
-
-
-
- def buttonAction(event):
- if button_confirm['text'] == '입력완료':
- customer_code = str(entry_customer_code.get())
- askInformation(customer_code, surgery_date)
- else:
- askQuit(customer_code, surgery_date)
- # def fillSurgeryDate():
-
-
-
-
- entry_customer_code = tkinter.Entry(window)
- entry_surgery_date = tkinter.Entry(window)
- button_confirm = tkinter.Button(window, text="입력완료", width=20, height=2)
- button_confirm.bind("<Button-1>", buttonAction)
-
- label_branch.pack()
- label_customer_code.pack()
- entry_customer_code.pack()
-
-
-
- button_confirm.pack()
-
- window.mainloop()
|