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 cbaa2f4 was
7dca26e,
checked in by Gervaise Alina <gervyh@…>, 15 years ago
|
small change on slit length calculator
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | |
---|
2 | import time |
---|
3 | import sys |
---|
4 | |
---|
5 | |
---|
6 | from data_util.calcthread import CalcThread |
---|
7 | from DataLoader.loader import Loader |
---|
8 | |
---|
9 | |
---|
10 | class DataReader(CalcThread): |
---|
11 | """ |
---|
12 | Load a data given a filename |
---|
13 | """ |
---|
14 | def __init__(self, path, completefn=None, |
---|
15 | updatefn = None, |
---|
16 | yieldtime = 0.01, |
---|
17 | worktime = 0.01 |
---|
18 | ): |
---|
19 | CalcThread.__init__(self, completefn, |
---|
20 | updatefn, |
---|
21 | yieldtime, |
---|
22 | worktime) |
---|
23 | self.path = path |
---|
24 | #Instantiate a loader |
---|
25 | self.loader = Loader() |
---|
26 | self.starttime = 0 |
---|
27 | |
---|
28 | def isquit(self): |
---|
29 | """ |
---|
30 | @raise KeyboardInterrupt: when the thread is interrupted |
---|
31 | """ |
---|
32 | try: |
---|
33 | CalcThread.isquit(self) |
---|
34 | except KeyboardInterrupt: |
---|
35 | raise KeyboardInterrupt |
---|
36 | |
---|
37 | |
---|
38 | def compute(self): |
---|
39 | """ |
---|
40 | read some data |
---|
41 | """ |
---|
42 | self.starttime = time.time() |
---|
43 | try: |
---|
44 | data = self.loader.load(self.path) |
---|
45 | elapsed = time.time() - self.starttime |
---|
46 | self.complete(data=data) |
---|
47 | except KeyboardInterrupt: |
---|
48 | # Thread was interrupted, just proceed and re-raise. |
---|
49 | # Real code should not print, but this is an example... |
---|
50 | raise |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.