ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since ab7e3a4 was
dbc5dc9b,
checked in by Jae Cho <jhjcho@…>, 12 years ago
|
added a pdb reader
|
-
Property mode set to
100644
|
File size:
2.5 KB
|
Line | |
---|
1 | """ |
---|
2 | Thread handler used to load data |
---|
3 | """ |
---|
4 | import time |
---|
5 | import wx |
---|
6 | from data_util.calcthread import CalcThread |
---|
7 | from sans.dataloader.loader import Loader |
---|
8 | |
---|
9 | class DataReader(CalcThread): |
---|
10 | """ |
---|
11 | Load a data given a filename |
---|
12 | """ |
---|
13 | def __init__(self, path, completefn=None, |
---|
14 | updatefn = None, |
---|
15 | yieldtime = 0.01, |
---|
16 | worktime = 0.01 |
---|
17 | ): |
---|
18 | CalcThread.__init__(self, completefn, |
---|
19 | updatefn, |
---|
20 | yieldtime, |
---|
21 | worktime) |
---|
22 | self.path = path |
---|
23 | #Instantiate a loader |
---|
24 | self.loader = Loader() |
---|
25 | self.starttime = 0 |
---|
26 | |
---|
27 | def isquit(self): |
---|
28 | """ |
---|
29 | @raise KeyboardInterrupt: when the thread is interrupted |
---|
30 | """ |
---|
31 | try: |
---|
32 | CalcThread.isquit(self) |
---|
33 | except KeyboardInterrupt: |
---|
34 | raise KeyboardInterrupt |
---|
35 | |
---|
36 | |
---|
37 | def compute(self): |
---|
38 | """ |
---|
39 | read some data |
---|
40 | """ |
---|
41 | self.starttime = time.time() |
---|
42 | try: |
---|
43 | data = self.loader.load(self.path) |
---|
44 | self.complete(data=data) |
---|
45 | except KeyboardInterrupt: |
---|
46 | # Thread was interrupted, just proceed and re-raise. |
---|
47 | # Real code should not print, but this is an example... |
---|
48 | raise |
---|
49 | |
---|
50 | class GenReader(CalcThread): |
---|
51 | """ |
---|
52 | Load a sld data given a filename |
---|
53 | """ |
---|
54 | def __init__(self, path, loader, |
---|
55 | completefn=None, |
---|
56 | updatefn = None, |
---|
57 | yieldtime = 0.01, |
---|
58 | worktime = 0.01 |
---|
59 | ): |
---|
60 | CalcThread.__init__(self, completefn, |
---|
61 | updatefn, |
---|
62 | yieldtime, |
---|
63 | worktime) |
---|
64 | self.path = path |
---|
65 | #Instantiate a loader |
---|
66 | self.loader = loader |
---|
67 | self.starttime = 0 |
---|
68 | |
---|
69 | def isquit(self): |
---|
70 | """ |
---|
71 | @raise KeyboardInterrupt: when the thread is interrupted |
---|
72 | """ |
---|
73 | try: |
---|
74 | CalcThread.isquit(self) |
---|
75 | except KeyboardInterrupt: |
---|
76 | raise KeyboardInterrupt |
---|
77 | |
---|
78 | |
---|
79 | def compute(self): |
---|
80 | """ |
---|
81 | read some data |
---|
82 | """ |
---|
83 | self.starttime = time.time() |
---|
84 | try: |
---|
85 | data = self.loader.read(self.path) |
---|
86 | self.complete(data=data) |
---|
87 | except: |
---|
88 | # Thread was interrupted, just proceed and re-raise. |
---|
89 | # Real code should not print, but this is an example... |
---|
90 | raise |
---|
91 | |
---|
Note: See
TracBrowser
for help on using the repository browser.