예제 #1
0
	def serializeJobList(self):
		jobListPath = os.path.join(self.serverScriptDirectory,"jobList.serpent")
		with self.serializedJobListLock:
			try:
				serpent.dump(self.jobs, open(jobListPath,"wb"))
			except:
				logging.error("unable to serializeJobList")
예제 #2
0
	def serializeJobID(self):
		jobIDPath = os.path.join(self.serverScriptDirectory,"jobIDCounter.serpent")
		with self.jobIDLock:        
			try:
				serpent.dump(self.jobID, open(jobIDPath,"wb"))
				logging.info("job ID serpent file edited. Current ID = {0}".format(self.jobID))
			except:
				logging.error("unable to serialize job ID counter")
예제 #3
0
	def loadSerializedJobHist(self):
		jobHistPath = os.path.join(self.serverScriptDirectory,"jobHist.serpent")
		with self.serializedJobHistLock:
			if os.path.isfile(jobHistPath):
				self.jobHist = serpent.load(open(jobHistPath,"rb"))
			else:
				self.jobHist = []
				serpent.dump(self.jobHist, open(jobHistPath, "wb"))
				logging.info("created job history serpent file")
예제 #4
0
	def loadSerializedJobID(self):
		jobIDPath = os.path.join(self.serverScriptDirectory,"jobIDCounter.serpent")
		if os.path.isfile(jobIDPath):
			self.jobID = serpent.load(open(jobIDPath, "rb"))
			logging.info("job ID serpent file opened. Current ID = {0}".format(self.jobID))
		else:
			self.jobID = 0
			serpent.dump(self.jobID, open(jobIDPath, "wb"))
			logging.info("created job ID serpent file: {0}".format(self.jobID))
예제 #5
0
 def test_pickle_api(self):
     ser = serpent.dumps([1, 2, 3])
     serpent.loads(ser)
     tmpfn = tempfile.mktemp()
     with open(tmpfn, "wb") as outf:
         serpent.dump([1, 2, 3], outf, indent=True, set_literals=True)
     with open(tmpfn, "rb") as inf:
         data = serpent.load(inf)
         self.assertEqual([1, 2, 3], data)
     os.remove(tmpfn)
예제 #6
0
 def test_pickle_api(self):
     ser = serpent.dumps([1, 2, 3])
     serpent.loads(ser)
     tmpfn = tempfile.mktemp()
     with open(tmpfn, "wb") as outf:
         serpent.dump([1, 2, 3], outf, indent=True, set_literals=True)
     with open(tmpfn, "rb") as inf:
         data = serpent.load(inf)
         self.assertEqual([1, 2, 3], data)
     os.remove(tmpfn)
예제 #7
0
	def initSerializedJobList(self):
		jobListPath = os.path.join(self.serverScriptDirectory,"jobList.serpent")
		with self.jobListLock:
			if os.path.isfile(jobListPath):
				self.jobs = serpent.load(open(jobListPath,"rb"))
				for job in self.jobs:
					job["jobData"]["status"] = "MACHINE ERROR"
					logging.info("Job {0} removed from queue (jobList) due to daemon initialization".format(job["jobData"]["jobID"]))
					self.jobHist.insert(0,job)
					self.serializeJobHist()
					indexToRemove = self.jobs.index(job)
					removedItem = self.jobs.pop(indexToRemove)
					self.serializeJobList()
			else:
				self.jobs = []
				serpent.dump(self.jobs, open(jobListPath, "wb"))
				logging.info("created job list serpent file")