Details
Description
Syncronize collections
ERROR:root:UNHANDLED EXCEPTION (2011-10-13 17:15:19.878807)
Working directory: /opt/noc
<type 'exceptions.AttributeError'>
'JSONDecoder' object has no attribute 'object_pairs_hook'
START OF TRACEBACK
------------------------------------------------------------------------
File: /opt/noc/contrib/lib/django/utils/simplejson/decoder.py (Line: 319)
Function: _init_
312 self.parse_float = parse_float or float
313 self.parse_int = parse_int or int
314 self.parse_constant = parse_constant or CONSTANTS.getitem_
315 self.strict = strict
316 self.parse_object = JSONObject
317 self.parse_array = JSONArray
318 self.parse_string = scanstring
319 ==> self.scan_once = make_scanner(self)
320
321 def decode(self, s, _w=WHITESPACE.match):
322 """Return the Python representation of ``s`` (a ``str`` or ``unicode``
323 instance containing a JSON document)
324
325 """
Variables:
parse_constant = None
parse_float = None
object_hook = None
encoding = 'utf-8'
self = <django.utils.simplejson.decoder.JSONDecoder object at 0x807879dd0>
parse_int = None
strict = True
------------------------------------------------------------------------
File: /opt/noc/lib/serialize.py (Line: 29)
Function: _simplejson_decode
22
23
24 def _simplejson_encode(obj):
25 return simplejson_encoder(ensure_ascii=False).encode(obj)
26
27
28 def _simplejson_decode(s):
29 ==> return simplejson_decoder(encoding="utf-8").decode(s)
30
31 ## Install handlers
32 logging.info("Using JSON library: %s" % JSON_TYPE)
33 if JSON_TYPE == "cjson":
34 json_encode = cjson.encode
35 json_decode = cjson.decode
Variables:
s = '[\n
,\n \n {\n "name": "Container | Freespace",\n "description": "Generic free space",\n "multi_connection": true,\n "model_attributes": [\n
{\n "name": "width_mm",\n "type": "int"\n },\n
{\n "name": "height_mm",\n "type": "int"\n },\n
{\n "name": "depth_mm",\n "type": "int"\n }\n ]\n }\n]'
------------------------------------------------------------------------
File: /opt/noc/main/management/commands/sync-collections.py (Line: 46)
Function: get_data
39 continue
40 self.paths += [os.path.join(dirpath, f)]
41
42 def get_data(self):
43 for path in self.paths:
44 with open(path, "r") as jf:
45 try:
46 ==> data = json_decode(jf.read())
47 except ValueError, why:
48 self.die("JSON error in %s: %s" % (path, why))
49 # Data must be either dict or list
50 if type(data) == type({}):
51 # Convert dict to list
52 data = [data]
Variables:
path = 'inv/collections/sockets/container.json'
jf = <closed file 'inv/collections/sockets/container.json', mode 'r' at 0x807634db0>
self = <noc.main.management.commands.sync-collections.CollectionSync object at 0x807871390>
------------------------------------------------------------------------
File: /opt/noc/main/management/commands/sync-collections.py (Line: 191)
Function: sync
184 # Define set of unique fields
185 self.unique = set()
186 for index in self.doc._meta["unique_indexes"]:
187 for f, flag in index:
188 self.unique.add(f)
189 # Sync items
190 retry = []
191 ==> for d in self.get_data():
192 item_id, to_retry = self.sync_item(d, True)
193 try:
194 self.builtin_ids.remove(item_id)
195 except KeyError:
196 pass
197 if to_retry:
Variables:
index = [('name', 1)]
retry = []
f = 'name'
self = <noc.main.management.commands.sync-collections.CollectionSync object at 0x807871390>
o = <Socket: Juniper | MX | SFM>
flag = 1
------------------------------------------------------------------------
File: /opt/noc/main/management/commands/sync-collections.py (Line: 258)
Function: handle
251 if not a:
252 raise CommandError("Invalid collection: %s" % name)
253 CollectionSync(*a)
254 else:
255 # Sync all collections
256 for app, collections in self.collections:
257 for collection, doc in collections:
258 ==> CollectionSync(app, collection, doc).sync()
259 except CommandError, why:
260 raise CommandError(why)
261 except:
262 error_report()
Variables:
doc = <class 'noc.inv.models.Socket'>
app = 'inv'
args = ()
collection = 'sockets'
self = <noc.main.management.commands.sync-collections.Command object at 0x8077cef50>
collections = [('sockets', <class 'noc.inv.models.Socket'>), ('vendors', <class 'noc.inv.models.Vendor'>), ('models', <class 'noc.inv.models.Model'>)]
options =
------------------------------------------------------------------------
END OF TRACEBACK