Commit 0a3dd01f authored by jtchilders's avatar jtchilders
Browse files

changed id to job_id, change serialize method of balsam job

parent 6b5a4867
import common.Serializer as Serializer
from django.core import serializers
import logging,sys
logger = logging.getLogger(__name__)
from common import Serializer
class SerializeFailed(Exception): pass
class DeserializeFailed(Exception): pass
class BalsamJobStatus:
def __init__(self,job=None,message=None):
self.id = None
self.job_id = None
self.serialized_job = None
self.message = message
if job is not None:
self.set_job(job)
def set_job(self,job):
self.id = job.balsam_job_id
self.job_id = job.job_id
try:
self.serialized_job = serializers.serialize('json',[job])
self.serialized_job = job.serialize()
except Exception,e:
logger.exception('serialize failed: ' + str(job.__dict__))
raise SerializeFailed('Received exception while serializing BalsamJob')
def get_job(self):
def get_job(self,job):
if self.serialized_job is not None:
try:
balsam_jobs = serializers.deserialize('json',self.serialized_job)
return balsam_jobs.next().object
job.deserialize(self.serialized_job)
return job
except Exception,e:
logger.exception('deserialize failed: ' + str(self.serialized_job))
raise DeserializeFailed('Received exception while deserializing BalsamJob')
......@@ -42,7 +42,7 @@ class BalsamJobStatus:
def deserialize(self,text):
try:
self.__dict__ = Serializer.deserialize(text)
self.id = int(str(self.id))
self.job_id = int(str(self.job_id))
except Exception,e:
logger.exception('deserialize failed')
raise DeserializeFailed('Received exception while deserializing BalsamJobStatus: ' + str(e))
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