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 378d2eb was
378d2eb,
checked in by Gervaise Alina <gervyh@…>, 14 years ago
|
working on the 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, filename='',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.filename = filename |
---|
24 | self.path = path |
---|
25 | #Instantiate a loader |
---|
26 | self.loader = Loader() |
---|
27 | self.starttime = 0 |
---|
28 | |
---|
29 | def isquit(self): |
---|
30 | """ |
---|
31 | @raise KeyboardInterrupt: when the thread is interrupted |
---|
32 | """ |
---|
33 | try: |
---|
34 | CalcThread.isquit(self) |
---|
35 | except KeyboardInterrupt: |
---|
36 | raise KeyboardInterrupt |
---|
37 | |
---|
38 | |
---|
39 | def compute(self): |
---|
40 | """ |
---|
41 | read some data |
---|
42 | """ |
---|
43 | self.starttime = time.time() |
---|
44 | try: |
---|
45 | data = self.loader.load(self.path) |
---|
46 | elapsed = time.time() - self.starttime |
---|
47 | self.complete(data=data, filename=self.filename) |
---|
48 | except KeyboardInterrupt: |
---|
49 | # Thread was interrupted, just proceed and re-raise. |
---|
50 | # Real code should not print, but this is an example... |
---|
51 | raise |
---|
52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.