Commit 51424960 authored by janis.streib's avatar janis.streib 🦉
Browse files

UPD: use internal json encoder

parent 39812bfa
......@@ -18,7 +18,7 @@ class MacFinderJob(DBObject):
self.status = None
self.mac = format_mac(mac)
self.vendor = OUI_DB.get(self.mac[:8], None)
self.vlan = VLAN(**vlan)
self.vlan = vlan if type(vlan) == VLAN else VLAN(**vlan)
self.bcd = bcd
def poll(self, session, db, connection):
......@@ -63,14 +63,7 @@ def create_job():
created_jobs.append(job_id)
pipe = r.pipeline()
pipe.multi()
pipe.set(job_id, json.dumps(
{
'mac': request.json['mac'],
'job_id': job_id,
'vlan': {'id': vlan.id, 'name': vlan.name},
'bcd': vlan.bcd
}
))
pipe.set(job_id, app.json_encoder.encode(MacFinderJob(job_id=job_id, mac=request.json['mac'], vlan=vlan, bcd=request.json['bcd'])))
pipe.expire(job_id, 60 * 60 * 12)
pipe.execute()
return jsonify({'success': True, 'job_ids': created_jobs})
......@@ -85,7 +78,7 @@ def poll(job_id):
job.poll(session, db, get_db_conn())
pipe = r.pipeline()
pipe.multi()
pipe.set(job_id, json.dumps(job.__dict__))
pipe.set(job_id, app.json_encoder.encode(job))
pipe.expire(job_id, 60 * 60 * 12)
pipe.execute()
return jsonify(job)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment