Exemplo n.º 1
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")
Exemplo n.º 2
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))
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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")