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 from __future__ import with_statement
28
29 __authors__ = ["Jérôme Kieffer"]
30 __contact__ = "Jerome.Kieffer@esrf.eu"
31 __license__ = "LGPLv3+"
32 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
33 __date__ = "20110919"
34 __status__ = "Stable"
35
36 from EDVerbose import EDVerbose
37 from threading import Semaphore
40 """
41 This static class keeps track of plugins under execution and which have succeeded or failed
42 """
43 __listRunning = []
44 __listSuccess = []
45 __listFailure = []
46 __sem = Semaphore()
47
48
49 @classmethod
52
53
54 @classmethod
57
58
59 @classmethod
62
63
64 @classmethod
66 """
67 Tell the strPluginId has started.
68 @param strPluginId: concatenation of the plugin-name and plugin-Id
69 """
70 with cls.__sem:
71 cls.__listRunning.append(strPluginId)
72
73
74 @classmethod
76 """
77 Tell the strPluginId has finished with success.
78 @param strPluginId: concatenation of the plugin-name and plugin-Id
79 """
80 with cls.__sem:
81 try:
82 cls.__listRunning.remove(strPluginId)
83 except ValueError:
84 EDVerbose.ERROR("Unable to remove %s from running plugins' list" % strPluginId)
85 else:
86 cls.__listSuccess.append(strPluginId)
87
88
89 @classmethod
91 """
92 Tell the strPluginId has finished with failure.
93 @param strPluginId: concatenation of the plugin-name and plugin-Id
94 """
95 with cls.__sem:
96 try:
97 cls.__listRunning.remove(strPluginId)
98 except ValueError:
99 EDVerbose.ERROR("Unable to remove %s from running plugins' list" % strPluginId)
100 else:
101 cls.__listFailure.append(strPluginId)
102