acdcserver 2.3.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. WMCore/ACDC/Collection.py +57 -0
  2. WMCore/ACDC/CollectionTypes.py +12 -0
  3. WMCore/ACDC/CouchCollection.py +67 -0
  4. WMCore/ACDC/CouchFileset.py +238 -0
  5. WMCore/ACDC/CouchService.py +73 -0
  6. WMCore/ACDC/DataCollectionService.py +485 -0
  7. WMCore/ACDC/Fileset.py +94 -0
  8. WMCore/ACDC/__init__.py +11 -0
  9. WMCore/Algorithms/ParseXMLFile.py +115 -0
  10. WMCore/Algorithms/Permissions.py +27 -0
  11. WMCore/Algorithms/__init__.py +7 -0
  12. WMCore/Configuration.py +651 -0
  13. WMCore/DataStructs/File.py +177 -0
  14. WMCore/DataStructs/Fileset.py +140 -0
  15. WMCore/DataStructs/Job.py +182 -0
  16. WMCore/DataStructs/JobGroup.py +142 -0
  17. WMCore/DataStructs/JobPackage.py +49 -0
  18. WMCore/DataStructs/LumiList.py +734 -0
  19. WMCore/DataStructs/Mask.py +219 -0
  20. WMCore/DataStructs/Pickleable.py +24 -0
  21. WMCore/DataStructs/Run.py +256 -0
  22. WMCore/DataStructs/Subscription.py +175 -0
  23. WMCore/DataStructs/WMObject.py +47 -0
  24. WMCore/DataStructs/WorkUnit.py +112 -0
  25. WMCore/DataStructs/Workflow.py +60 -0
  26. WMCore/DataStructs/__init__.py +8 -0
  27. WMCore/Database/CMSCouch.py +1349 -0
  28. WMCore/Database/ConfigDBMap.py +29 -0
  29. WMCore/Database/CouchUtils.py +118 -0
  30. WMCore/Database/DBCore.py +198 -0
  31. WMCore/Database/DBCreator.py +113 -0
  32. WMCore/Database/DBExceptionHandler.py +57 -0
  33. WMCore/Database/DBFactory.py +110 -0
  34. WMCore/Database/DBFormatter.py +177 -0
  35. WMCore/Database/Dialects.py +13 -0
  36. WMCore/Database/ExecuteDAO.py +327 -0
  37. WMCore/Database/MongoDB.py +241 -0
  38. WMCore/Database/MySQLCore.py +132 -0
  39. WMCore/Database/ResultSet.py +44 -0
  40. WMCore/Database/Transaction.py +91 -0
  41. WMCore/Database/__init__.py +9 -0
  42. WMCore/Database/ipy_profile_couch.py +438 -0
  43. WMCore/GroupUser/CouchObject.py +127 -0
  44. WMCore/GroupUser/Decorators.py +51 -0
  45. WMCore/GroupUser/Group.py +33 -0
  46. WMCore/GroupUser/Interface.py +73 -0
  47. WMCore/GroupUser/User.py +96 -0
  48. WMCore/GroupUser/__init__.py +11 -0
  49. WMCore/Lexicon.py +836 -0
  50. WMCore/Services/Requests.py +624 -0
  51. WMCore/Services/__init__.py +8 -0
  52. WMCore/Services/pycurl_manager.py +574 -0
  53. WMCore/WMException.py +183 -0
  54. WMCore/Wrappers/JsonWrapper/JSONThunker.py +342 -0
  55. WMCore/Wrappers/JsonWrapper/__init__.py +7 -0
  56. WMCore/Wrappers/__init__.py +6 -0
  57. WMCore/__init__.py +10 -0
  58. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/CouchDBLogo.png +0 -0
  59. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/DMWMLogo.png +0 -0
  60. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/collections.html +60 -0
  61. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/displaycollection.html +61 -0
  62. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/index.html +36 -0
  63. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/style/main.css +1 -0
  64. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_id +1 -0
  65. acdcserver-2.3.10.data/data/data/couchapps/ACDC/couchapp.json +4 -0
  66. acdcserver-2.3.10.data/data/data/couchapps/ACDC/filters/filterDeletedDocs.js +3 -0
  67. acdcserver-2.3.10.data/data/data/couchapps/ACDC/rewrites.json +81 -0
  68. acdcserver-2.3.10.data/data/data/couchapps/ACDC/validate_doc_update.js +9 -0
  69. acdcserver-2.3.10.data/data/data/couchapps/ACDC/vendor/acdc/_attachments/acdc.js +302 -0
  70. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/byCollectionName/map.js +9 -0
  71. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/byCollectionName/reduce.js +3 -0
  72. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/byTimestamp/map.js +10 -0
  73. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_count/map.js +9 -0
  74. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_count/reduce.js +1 -0
  75. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_docs/map.js +3 -0
  76. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_docs/reduce.js +3 -0
  77. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/.couchappignore +1 -0
  78. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/.couchapprc +1 -0
  79. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/_attachments/index.html +85 -0
  80. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/_attachments/style/main.css +1 -0
  81. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/_id +1 -0
  82. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/couchapp.json +4 -0
  83. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/updates/newgroup.js +18 -0
  84. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/updates/newuser.js +15 -0
  85. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/updates/ownthis.js +8 -0
  86. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/README.md +3 -0
  87. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/_attachments/jquery.couchapp.js +200 -0
  88. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/couchapp.js +1 -0
  89. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/date.js +23 -0
  90. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/metadata.json +4 -0
  91. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/path.js +77 -0
  92. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/template.js +33 -0
  93. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/groupuser/_attachments/groupuser.js +234 -0
  94. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/group_members/map.js +5 -0
  95. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/groups/map.js +5 -0
  96. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/name_map/map.js +5 -0
  97. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/owner_group_user/map.js +5 -0
  98. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/users/map.js +5 -0
  99. acdcserver-2.3.10.dist-info/LICENSE +202 -0
  100. acdcserver-2.3.10.dist-info/METADATA +17 -0
  101. acdcserver-2.3.10.dist-info/NOTICE +16 -0
  102. acdcserver-2.3.10.dist-info/RECORD +104 -0
  103. acdcserver-2.3.10.dist-info/WHEEL +5 -0
  104. acdcserver-2.3.10.dist-info/top_level.txt +1 -0
WMCore/WMException.py ADDED
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/python
2
+ """
3
+ _WMException_
4
+
5
+ General Exception class for WM modules
6
+
7
+ """
8
+
9
+ from builtins import str, bytes
10
+ from future.utils import viewitems
11
+
12
+ import inspect
13
+ import logging
14
+ import sys
15
+ import traceback
16
+
17
+ from Utils.Utilities import decodeBytesToUnicode
18
+ from WMCore.Configuration import PY3
19
+
20
+ WMEXCEPTION_START_STR = str("<@========== WMException Start ==========@>")
21
+ WMEXCEPTION_END_STR = str("<@---------- WMException End ----------@>")
22
+
23
+
24
+ class WMException(Exception):
25
+ """
26
+ _WMException_
27
+
28
+ Exception class which works out details of where
29
+ it was raised.
30
+
31
+ """
32
+
33
+ def __init__(self, message, errorNo=None, **data):
34
+ self.name = str(self.__class__.__name__)
35
+
36
+ # Fix for the unicode encoding issue, see #8056 and #8403
37
+ # interprets this string using utf-8 codec and ignoring any errors.
38
+ # using unicode sandwich pattern
39
+ message = decodeBytesToUnicode(message, "ignore")
40
+
41
+ Exception.__init__(self, self.name, message)
42
+
43
+ # //
44
+ # // Init data dictionary with defaults
45
+ # //
46
+ self.data = {}
47
+ self.data.setdefault("ClassName", None)
48
+ self.data.setdefault("ModuleName", None)
49
+ self.data.setdefault("MethodName", None)
50
+ self.data.setdefault("ClassInstance", None)
51
+ self.data.setdefault("FileName", None)
52
+ self.data.setdefault("LineNumber", None)
53
+ if errorNo is None:
54
+ self.data.setdefault("ErrorNr", 0)
55
+ else:
56
+ self.data.setdefault("ErrorNr", errorNo)
57
+
58
+ self._message = message
59
+ self.addInfo(**data)
60
+
61
+ # //
62
+ # // Automatically determine the module name
63
+ # // if not set
64
+ if self.data['ModuleName'] is None:
65
+ try:
66
+ frame = inspect.currentframe()
67
+ lastframe = inspect.getouterframes(frame)[1][0]
68
+ excepModule = inspect.getmodule(lastframe)
69
+ if excepModule is not None:
70
+ modName = excepModule.__name__
71
+ self.data['ModuleName'] = modName
72
+ finally:
73
+ frame = None
74
+
75
+ # //
76
+ # // Find out where the exception came from
77
+ # //
78
+ try:
79
+ stack = inspect.stack(1)[1]
80
+ self.data['FileName'] = stack[1]
81
+ self.data['LineNumber'] = stack[2]
82
+ self.data['MethodName'] = stack[3]
83
+ finally:
84
+ stack = None
85
+
86
+ # //
87
+ # // ClassName if ClassInstance is passed
88
+ # //
89
+ try:
90
+ if self.data['ClassInstance'] is not None:
91
+ self.data['ClassName'] = self.data['ClassInstance'].__class__.__name__
92
+ except Exception:
93
+ pass
94
+
95
+ # Determine the traceback at time of __init__
96
+ try:
97
+ self.traceback = "\n".join(traceback.format_tb(sys.exc_info()[2]))
98
+ except Exception:
99
+ self.traceback = "WMException error: Couldn't get traceback\n"
100
+ # using unicode sandwich pattern
101
+ self.traceback = decodeBytesToUnicode(self.traceback, "ignore")
102
+
103
+ def __getitem__(self, key):
104
+ """
105
+ make exception look like a dictionary
106
+ """
107
+ return self.data[key]
108
+
109
+ def __setitem__(self, key, value):
110
+ """
111
+ make exception look like a dictionary
112
+ """
113
+ # using unicode sandwich pattern
114
+ key = decodeBytesToUnicode(key, "ignore")
115
+ value = decodeBytesToUnicode(value, "ignore")
116
+ self.data[key] = value
117
+
118
+ def addInfo(self, **data):
119
+ """
120
+ _addInfo_
121
+
122
+ Add key=value information pairs to an
123
+ exception instance
124
+ """
125
+ for key, value in viewitems(data):
126
+ # assumption: value is not iterable (list, dict, tuple, ...)
127
+ # using unicode sandwich pattern
128
+ key = decodeBytesToUnicode(key, "ignore")
129
+ value = decodeBytesToUnicode(value, "ignore")
130
+ self.data[key] = value
131
+ return
132
+
133
+ def xml(self):
134
+ """create a xml string rep of this exception"""
135
+ strg = "<Exception>\n"
136
+ strg += "<Object>\n"
137
+ strg += "%s\n" % self.name
138
+ strg += "</Object>\n"
139
+ strg += "<Message>\n"
140
+ strg += self._message
141
+ strg += "</Message>\n"
142
+ strg += "<DataItems>\n"
143
+ for key, value in viewitems(self.data):
144
+ strg += "<DataItem>\n"
145
+ strg += "<Key>\n"
146
+ strg += str(key)
147
+ strg += "</Key>\n"
148
+ strg += "<Value>\n"
149
+ strg += str(value)
150
+ strg += "</Value>\n"
151
+ strg += "</DataItem>\n"
152
+ strg += "</DataItems>\n"
153
+ strg += "</Exception>\n"
154
+ logging.error(strg)
155
+ return strg
156
+
157
+ def __as_unicode(self):
158
+ """create a string rep of this exception"""
159
+ # WARNING: Do not change this string - it is used to extract error from log
160
+ strg = WMEXCEPTION_START_STR
161
+ strg += "\nException Class: %s\n" % self.name
162
+ strg += "Message: %s\n" % self._message
163
+ for key, value in viewitems(self.data):
164
+ strg += "\t%s : %s\n" % (key, value,)
165
+ strg += "\nTraceback: \n"
166
+ strg += self.traceback
167
+ strg += '\n'
168
+ strg += WMEXCEPTION_END_STR
169
+ return strg
170
+
171
+ def __as_bytes(self):
172
+ return self.__as_unicode().encode("utf-8")
173
+
174
+ if PY3:
175
+ __str__ = __as_unicode
176
+ else:
177
+ __str__ = __as_bytes
178
+ __unicode__ = __as_unicode
179
+ __repr__ = __str__
180
+
181
+
182
+ def message(self):
183
+ return self._message
@@ -0,0 +1,342 @@
1
+ from __future__ import print_function
2
+
3
+ from builtins import str, bytes, int
4
+ from future.utils import viewitems
5
+ from Utils.PythonVersion import PY2
6
+
7
+ import sys
8
+ import types
9
+
10
+
11
+ class _EmptyClass(object):
12
+ pass
13
+
14
+
15
+ class JSONThunker(object):
16
+ """
17
+ _JSONThunker_
18
+ Converts an arbitrary object to <-> from a jsonable object.
19
+
20
+ Will, for the most part "do the right thing" about various instance objects
21
+ by storing their class information along with their data in a dict. Handles
22
+ a recursion limit to prevent infinite recursion.
23
+
24
+ self.passThroughTypes - stores a list of types that should be passed
25
+ through unchanged to the JSON parser
26
+
27
+ self.blackListedModules - a list of modules that should not be stored in
28
+ the JSON.
29
+
30
+ """
31
+
32
+ def __init__(self):
33
+ self.passThroughTypes = (type(None),
34
+ bool,
35
+ int,
36
+ float,
37
+ complex,
38
+ str,
39
+ bytes,
40
+ )
41
+ # objects that inherit from dict should be treated as a dict
42
+ # they don't store their data in __dict__. There was enough
43
+ # of those classes that it warrented making a special case
44
+ self.dictSortOfObjects = (('WMCore.Datastructs.Job', 'Job'),
45
+ ('WMCore.WMBS.Job', 'Job'),
46
+ ('WMCore.Database.CMSCouch', 'Document'))
47
+ # ditto above, but for lists
48
+ self.listSortOfObjects = (('WMCore.DataStructs.JobPackage', 'JobPackage'),
49
+ ('WMCore.WMBS.JobPackage', 'JobPackage'),)
50
+
51
+ self.foundIDs = {}
52
+ # modules we don't want JSONed
53
+ self.blackListedModules = ('sqlalchemy.engine.threadlocal',
54
+ 'WMCore.Database.DBCore',
55
+ 'logging',
56
+ 'WMCore.DAOFactory',
57
+ 'WMCore.WMFactory',
58
+ 'WMFactory',
59
+ 'WMCore.Configuration',
60
+ 'WMCore.Database.Transaction',
61
+ 'threading',
62
+ 'datetime')
63
+
64
+ def checkRecursion(self, data):
65
+ """
66
+ handles checking for infinite recursion
67
+ """
68
+ if id(data) in self.foundIDs:
69
+ if self.foundIDs[id(data)] > 5:
70
+ self.unrecurse(data)
71
+ return "**RECURSION**"
72
+ else:
73
+ self.foundIDs[id(data)] += 1
74
+ return data
75
+ else:
76
+ self.foundIDs[id(data)] = 1
77
+ return data
78
+
79
+ def unrecurse(self, data):
80
+ """
81
+ backs off the recursion counter if we're returning from _thunk
82
+ """
83
+ try:
84
+ self.foundIDs[id(data)] -= 1
85
+ except:
86
+ print("Could not find count for id %s of type %s data %s" % (id(data), type(data), data))
87
+ raise
88
+
89
+ def checkBlackListed(self, data):
90
+ """
91
+ checks to see if a given object is from a blacklisted module
92
+ """
93
+ try:
94
+ # special case
95
+ if data.__class__.__module__ == 'WMCore.Database.CMSCouch' and data.__class__.__name__ == 'Document':
96
+ data.__class__ = type({})
97
+ return data
98
+ if data.__class__.__module__ in self.blackListedModules:
99
+ return "Blacklisted JSON object: module %s, name %s, str() %s" % \
100
+ (data.__class__.__module__, data.__class__.__name__, str(data))
101
+ else:
102
+ return data
103
+ except Exception:
104
+ return data
105
+
106
+ def thunk(self, toThunk):
107
+ """
108
+ Thunk - turns an arbitrary object into a JSONable object
109
+ """
110
+ self.foundIDs = {}
111
+ data = self._thunk(toThunk)
112
+ return data
113
+
114
+ def unthunk(self, data):
115
+ """
116
+ unthunk - turns a previously 'thunked' object back into a python object
117
+ """
118
+ return self._unthunk(data)
119
+
120
+ def handleSetThunk(self, toThunk):
121
+ toThunk = self.checkRecursion(toThunk)
122
+ tempDict = {'thunker_encoded_json': True, 'type': 'set'}
123
+ tempDict['set'] = self._thunk(list(toThunk))
124
+ self.unrecurse(toThunk)
125
+ return tempDict
126
+
127
+ def handleListThunk(self, toThunk):
128
+ toThunk = self.checkRecursion(toThunk)
129
+ for k, v in enumerate(toThunk):
130
+ toThunk[k] = self._thunk(v)
131
+ self.unrecurse(toThunk)
132
+ return toThunk
133
+
134
+ def handleDictThunk(self, toThunk):
135
+ toThunk = self.checkRecursion(toThunk)
136
+ special = False
137
+ tmpdict = {}
138
+ for k, v in viewitems(toThunk):
139
+ if type(k) == type(int):
140
+ special = True
141
+ tmpdict['_i:%s' % k] = self._thunk(v)
142
+ elif type(k) == type(float):
143
+ special = True
144
+ tmpdict['_f:%s' % k] = self._thunk(v)
145
+ else:
146
+ tmpdict[k] = self._thunk(v)
147
+ if special:
148
+ toThunk['thunker_encoded_json'] = self._thunk(True)
149
+ toThunk['type'] = self._thunk('dict')
150
+ toThunk['dict'] = tmpdict
151
+ else:
152
+ toThunk.update(tmpdict)
153
+ self.unrecurse(toThunk)
154
+ return toThunk
155
+
156
+ def handleObjectThunk(self, toThunk):
157
+ toThunk = self.checkRecursion(toThunk)
158
+ toThunk = self.checkBlackListed(toThunk)
159
+
160
+ if isinstance(toThunk, (str, bytes)):
161
+ # things that got blacklisted
162
+ return toThunk
163
+ if hasattr(toThunk, '__to_json__'):
164
+ # Use classes own json thunker
165
+ toThunk2 = toThunk.__to_json__(self)
166
+ self.unrecurse(toThunk)
167
+ return toThunk2
168
+ elif isinstance(toThunk, dict):
169
+ toThunk2 = self.handleDictObjectThunk(toThunk)
170
+ self.unrecurse(toThunk)
171
+ return toThunk2
172
+ elif isinstance(toThunk, list):
173
+ # a mother thunking list
174
+ toThunk2 = self.handleListObjectThunk(toThunk)
175
+ self.unrecurse(toThunk)
176
+ return toThunk2
177
+ else:
178
+ try:
179
+ thunktype = '%s.%s' % (toThunk.__class__.__module__,
180
+ toThunk.__class__.__name__)
181
+ tempDict = {'thunker_encoded_json': True, 'type': thunktype}
182
+ tempDict[thunktype] = self._thunk(toThunk.__dict__)
183
+ self.unrecurse(toThunk)
184
+ return tempDict
185
+ except Exception as e:
186
+ tempDict = {'json_thunk_exception_': "%s" % e}
187
+ self.unrecurse(toThunk)
188
+ return tempDict
189
+
190
+ def handleDictObjectThunk(self, data):
191
+ thunktype = '%s.%s' % (data.__class__.__module__,
192
+ data.__class__.__name__)
193
+ tempDict = {'thunker_encoded_json': True,
194
+ 'is_dict': True,
195
+ 'type': thunktype,
196
+ thunktype: {}}
197
+
198
+ for k, v in viewitems(data.__dict__):
199
+ tempDict[k] = self._thunk(v)
200
+ for k, v in viewitems(data):
201
+ tempDict[thunktype][k] = self._thunk(v)
202
+
203
+ return tempDict
204
+
205
+ def handleDictObjectUnThunk(self, value, data):
206
+ data.pop('thunker_encoded_json', False)
207
+ data.pop('is_dict', False)
208
+ thunktype = data.pop('type', False)
209
+
210
+ for k, v in viewitems(data):
211
+ if k == thunktype:
212
+ for k2, v2 in viewitems(data[thunktype]):
213
+ value[k2] = self._unthunk(v2)
214
+ else:
215
+ value.__dict__[k] = self._unthunk(v)
216
+ return value
217
+
218
+ def handleListObjectThunk(self, data):
219
+ thunktype = '%s.%s' % (data.__class__.__module__,
220
+ data.__class__.__name__)
221
+ tempDict = {'thunker_encoded_json': True,
222
+ 'is_list': True,
223
+ 'type': thunktype,
224
+ thunktype: []}
225
+ for k, v in enumerate(data):
226
+ tempDict['thunktype'].append(self._thunk(v))
227
+ for k, v in viewitems(data.__dict__):
228
+ tempDict[k] = self._thunk(v)
229
+ return tempDict
230
+
231
+ def handleListObjectUnThunk(self, value, data):
232
+ data.pop('thunker_encoded_json', False)
233
+ data.pop('is_list', False)
234
+ thunktype = data.pop('type')
235
+ for k, v in viewitems(data[thunktype]):
236
+ setattr(value, k, self._unthunk(v))
237
+
238
+ for k, v in viewitems(data):
239
+ if k == thunktype:
240
+ continue
241
+ value.__dict__ = self._unthunk(v)
242
+ return value
243
+
244
+ def _thunk(self, toThunk):
245
+ """
246
+ helper function for thunk, does the actual work
247
+ """
248
+ if isinstance(toThunk, self.passThroughTypes):
249
+ return toThunk
250
+ elif type(toThunk) is list:
251
+ return self.handleListThunk(toThunk)
252
+ elif type(toThunk) is dict:
253
+ return self.handleDictThunk(toThunk)
254
+ elif type(toThunk) is set:
255
+ return self.handleSetThunk(toThunk)
256
+ elif type(toThunk) is types.FunctionType:
257
+ self.unrecurse(toThunk)
258
+ return "function reference"
259
+ elif isinstance(toThunk, object):
260
+ return self.handleObjectThunk(toThunk)
261
+ else:
262
+ self.unrecurse(toThunk)
263
+ raise RuntimeError(type(toThunk))
264
+
265
+ def _unthunk(self, jsondata):
266
+ """
267
+ _unthunk - does the actual work for unthunk
268
+ """
269
+ if PY2 and type(jsondata) is str:
270
+ return jsondata.encode("utf-8")
271
+ if type(jsondata) is dict:
272
+ if 'thunker_encoded_json' in jsondata:
273
+ # we've got a live one...
274
+ if jsondata['type'] == 'set':
275
+ newSet = set()
276
+ for i in self._unthunk(jsondata['set']):
277
+ newSet.add(self._unthunk(i))
278
+ return newSet
279
+ if jsondata['type'] == 'dict':
280
+ # We have a "special" dict
281
+ data = {}
282
+ for k, v in viewitems(jsondata['dict']):
283
+ tmp = self._unthunk(v)
284
+ if k.startswith('_i:'):
285
+ data[int(k.lstrip('_i:'))] = tmp
286
+ elif k.startswith('_f:'):
287
+ data[float(k.lstrip('_f:'))] = tmp
288
+ else:
289
+ data[k] = tmp
290
+ return data
291
+ else:
292
+ # spawn up an instance.. good luck
293
+ # here be monsters
294
+ # inspired from python's pickle code
295
+ ourClass = self.getThunkedClass(jsondata)
296
+
297
+ value = _EmptyClass()
298
+ if hasattr(ourClass, '__from_json__'):
299
+ # Use classes own json loader
300
+ try:
301
+ value.__class__ = ourClass
302
+ except Exception:
303
+ value = ourClass()
304
+ value = ourClass.__from_json__(value, jsondata, self)
305
+ elif 'thunker_encoded_json' in jsondata and 'is_dict' in jsondata:
306
+ try:
307
+ value.__class__ = ourClass
308
+ except Exception:
309
+ value = ourClass()
310
+ value = self.handleDictObjectUnThunk(value, jsondata)
311
+ elif 'thunker_encoded_json' in jsondata:
312
+ try:
313
+ value.__class__ = ourClass
314
+ except Exception:
315
+ value = ourClass()
316
+ value = self.handleListObjectUnThunk(value, jsondata)
317
+ else:
318
+ raise RuntimeError('Could not unthunk a class. Code to try was removed because it had errors.')
319
+ return value
320
+ else:
321
+ data = {}
322
+ for k, v in viewitems(jsondata):
323
+ data[k] = self._unthunk(v)
324
+ return data
325
+
326
+ else:
327
+ return jsondata
328
+
329
+ @staticmethod
330
+ def getThunkedClass(jsondata):
331
+ """
332
+ Work out the class from it's thunked json representation
333
+ """
334
+ module = jsondata['type'].rsplit('.', 1)[0]
335
+ name = jsondata['type'].rsplit('.', 1)[1]
336
+ if (module == 'WMCore.Services.Requests') and (name == JSONThunker):
337
+ raise RuntimeError("Attempted to unthunk a JSONThunker..")
338
+
339
+ __import__(module)
340
+ mod = sys.modules[module]
341
+ ourClass = getattr(mod, name)
342
+ return ourClass
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: ISO-8859-1 -*-
3
+
4
+ """
5
+ We used to have a wrapper here to wrap different JSON implementations. No longer needed with python 2.7
6
+ """
7
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env python
2
+ #-*- coding: ISO-8859-1 -*-
3
+
4
+ """
5
+ WMCore wrappers.
6
+ """
WMCore/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env python
2
+ """
3
+ _WMCore_
4
+
5
+ Core libraries for Workload Management Packages
6
+
7
+ """
8
+
9
+ __version__ = '2.3.10'
10
+ __all__ = []
@@ -0,0 +1,60 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+
4
+ <html lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
+ <title>collections</title>
8
+ <meta name="generator" content="TextMate http://macromates.com/">
9
+ <meta name="author" content="Dave Evans">
10
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/fonts/fonts-min.css" />
11
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/container/assets/skins/sam/container.css" />
12
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
13
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/container/container-min.js"></script>
14
+
15
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.1/build/datatable/assets/skins/sam/datatable.css&2.8.1/build/logger/assets/skins/sam/logger.css">
16
+ <script type="text/javascript" src="http://yui.yahooapis.com/combo?2.8.1/build/yahoo/yahoo-debug.js&2.8.1/build/dom/dom-debug.js&2.8.1/build/event/event-debug.js&2.8.1/build/element/element-debug.js&2.8.1/build/datasource/datasource-debug.js&2.8.1/build/datatable/datatable-debug.js&2.8.1/build/logger/logger-debug.js"></script>
17
+
18
+ <script src="/_utils/script/json2.js"></script>
19
+ <script src="/_utils/script/jquery.js?1.3.1"></script>
20
+ <script src="/_utils/script/jquery.couch.js?0.9.0"></script>
21
+ <script src="vendor/acdc/acdc.js"></script>
22
+ <!-- Date: 2010-10-27 -->
23
+ <style>
24
+ #header {
25
+ background: #fff;
26
+ position: absolute;
27
+ top: 0px;
28
+ left: 0px;
29
+ width: 950px;
30
+ height: 100px;
31
+ }
32
+ #collections {
33
+ background: #fff;
34
+ position: absolute;
35
+ top: 100px;
36
+ left: 0px;
37
+ width: 950px;
38
+ height: 800px;
39
+ }
40
+ </style>
41
+
42
+ </head>
43
+ <body class="yui-skin-sam">
44
+
45
+ <div id="header"><h1>Collections Viewer</h1></div>
46
+ <div id="collections">
47
+ <div id="tablepanel"></div>
48
+ </div>
49
+
50
+ </body>
51
+ <script>
52
+ var dbname = document.location.href.split('/')[3];
53
+ $db = $.couch.db(dbname);
54
+ // set up the groupuser instance
55
+ acdc.setCouchDB($db);
56
+ acdc.buildCollectionDataTable("tablepanel");
57
+ acdc.fillCollectionTable();
58
+
59
+ </script>
60
+ </html>
@@ -0,0 +1,61 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+
4
+ <html lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
+ <title>displaycollection</title>
8
+ <meta name="generator" content="TextMate http://macromates.com/">
9
+ <meta name="author" content="Dave Evans">
10
+ <!-- Date: 2010-10-27 -->
11
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/fonts/fonts-min.css" />
12
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/container/assets/skins/sam/container.css" />
13
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
14
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/container/container-min.js"></script>
15
+
16
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.1/build/datatable/assets/skins/sam/datatable.css&2.8.1/build/logger/assets/skins/sam/logger.css">
17
+ <script type="text/javascript" src="http://yui.yahooapis.com/combo?2.8.1/build/yahoo/yahoo-debug.js&2.8.1/build/dom/dom-debug.js&2.8.1/build/event/event-debug.js&2.8.1/build/element/element-debug.js&2.8.1/build/datasource/datasource-debug.js&2.8.1/build/datatable/datatable-debug.js&2.8.1/build/logger/logger-debug.js"></script>
18
+
19
+ <script src="/_utils/script/json2.js"></script>
20
+ <script src="/_utils/script/jquery.js?1.3.1"></script>
21
+ <script src="/_utils/script/jquery.couch.js?0.9.0"></script>
22
+ <script src="vendor/acdc/acdc.js"></script>
23
+
24
+ <style>
25
+ #header {
26
+ background: #fff;
27
+ position: absolute;
28
+ top: 0px;
29
+ left: 0px;
30
+ width: 950px;
31
+ height: 100px;
32
+ }
33
+ #collections {
34
+ background: #fff;
35
+ position: absolute;
36
+ top: 100px;
37
+ left: 0px;
38
+ width: 950px;
39
+ height: 800px;
40
+ }
41
+ </style>
42
+ </head>
43
+ <body class="yui-skin-sam">
44
+ <div id="header"><h1>Collection Details</h1></div>
45
+ <div id="collections">
46
+ <div id="displaypanel"></div>
47
+ </div>
48
+ </body>
49
+
50
+ <script>
51
+ var dbname = document.location.href.split('/')[3];
52
+ $db = $.couch.db(dbname);
53
+ // set up the acdc instance
54
+ acdc.setCouchDB($db);
55
+ acdc.buildFilesetSummaryDataTable("displaypanel");
56
+ acdc.displayCollection();
57
+
58
+
59
+ </script>
60
+
61
+ </html>