-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py.bak
110 lines (85 loc) · 2.65 KB
/
run.py.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# -*- coding: utf-8 -*-
import time
import tkinter.ttk as ttk
from tkinter import filedialog
import tkinter.font as tkFont
from tkinter import *
import os
import subprocess
import sys
import threading
global output
output = []
def initUI():
window = Tk()
window.title("네카라쿠배 v1.0")
window.geometry("640x480")
frame = Frame(window, width=640, height=480,)
frame.place(x=0, y=0)
lblText = StringVar()
lblText.set("Not search dir")
path_font = tkFont.Font(size=14)
def openDir():
global path
dir_path = filedialog.askdirectory(parent=window, initialdir="/home/stud/Desktop/", title="Select dir")
path = dir_path
lblText.set('Selected\n' + path)
outputBox = Text(window)
outputBox.pack(expand = True)
outputBox.configure(font=("Times", 12))
def delMal():
comm = ['python', 'k2.py']
comm.append('-l')
comm.append(path)
print comm
p = subprocess.call(comm)
'''
while True:
res = p.stdout.readline()
if res == '' and p.poll() is not None: break
if res:
outputBox.insert('end', res.strip() + '\n')
outputBox.see(END)
'''
popUp.destroy()
def midDel():
t2 = threading.Thread(target=delMal)
t2.start()
def run():
comm = ['python', 'k2.py']
comm.append('-f')
comm.append(path)
print comm
p = subprocess.Popen(comm, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = False)
while True:
res = p.stdout.readline()
if res == '' and p.poll() is not None: break
if res:
outputBox.insert('end', res.strip() + '\n')
outputBox.see(END)
rc = p.poll()
global popUp
popUp = Tk()
popUp.title("Finished Scan")
popUp.geometry("320x240")
popUpLbl = Label(popUp, text = 'Delete?')
popUpLbl.pack()
btnDelete = Button(popUp, text='Delete', command = midDel)
btnDelete.pack()
popUp.mainloop()
def midRun():
t1 = threading.Thread(target=run)
t1.start()
lbl = Label(window, textvariable = lblText, font=path_font)
lbl.pack(pady=10)
cancleBtn = Button(window, width=12, text="Quit", command=window.destroy)
cancleBtn.pack(side="right", padx=5, pady=10)
startBtn = Button(window, width=12, text="start", command = midRun)
startBtn.pack(side="right", padx=5)
openBtn = Button(window, width=12, text="Select Folder", command = openDir)
openBtn.pack(side="right", padx=5)
window.mainloop()
def main():
initUI()
if __name__ == '__main__':
main()