This repository has been archived by the owner on Nov 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGuiThread.py
58 lines (47 loc) · 1.71 KB
/
GuiThread.py
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
import threading
import time
from SearchPacket import SearchPacket
from SearchInterface import SearchInterface
from Attribute import Attribute
'''
This class controls the backend of the Whistleblower tools.
The GUI creates a multithreading environment to allow operations
via the backend to be controlled by the GUI.
Takes in a list of Attribute objects and a dictionary of
search arguments.
@author: Brenden Romanowski
@date: 17 March 2015
'''
class GuiThread(threading.Thread):
completed = False
def __init__(self, interface, attributes, args, progress_que):
if interface is None:
raise TypeError('interface argument required')
elif attributes is None:
raise TypeError('attributes argument required')
elif args is None:
raise TypeError('args argument required')
elif not isinstance(interface, SearchInterface):
raise TypeError('interface must be a subclass of SearchInterface')
elif not isinstance(attributes, list):
raise TypeError('attributes argument must be a list')
elif not isinstance(args, dict):
raise TypeError('args argument must be a dictionary')
elif not len(attributes) > 0:
raise TypeError('at least one Attribute required')
elif not isinstance(attributes[0], Attribute):
raise TypeError('Attributes list must contain Attribute instances')
threading.Thread.__init__(self)
#self.interface = SearchInterface()
self.interface = interface
self.search_packet = SearchPacket(attributes)
self.args = args
self.que = progress_que
def run(self):
self.interface.initialize_scorer(self.search_packet)
self.query = self.search_packet.getQuery()
self.interface.search(self.query, self.args)
time.sleep(1)
self.completed = True
def stop(self):
self.interface.stop_search()