def Setup(self, collection_type): self.collection_type = collection_type try: # get output directory print "here 0" chem_dir = self.director.GetBiochemicalFileDirectory() # print "chem_dir: "+chem_dir try: os.makedirs(chem_dir) except OSError as exc: # Python >2.5 if exc.errno == errno.EEXIST and os.path.isdir(chem_dir): pass else: raise # open output files if self.collection_type == "baseline": chem_file_1_path = os.path.join(chem_dir,"baseline_chem_file_1") else: chem_file_1_path = os.path.join(chem_dir,"chem_file_1") self.chem_file_1 = open(chem_file_1_path,"w") # load configuration parameters into sensor aController = AlgorithmController(self.db, Algorithm, None, None) adController = AlgorithmDefaultsController(self.db, AlgorithmDefaults, None, None) algorithm = aController.getByName("biochemical sensor") # (names,values) = adController.getAllAsLists(algorithm.id) # self.sensor.createConfiguration(names, values) # self.sensor.configure() nReps = int(adController.getDefaultByName("numberReps", algorithm.id)) print "Configuring biochemical sensor for %d repetitions" % (nReps) self.sensor.configure(nReps) except PUFileDirectorException as e: self.message = e.to_string() except pu.BiochemicalSensorException as e: self.message = e.what() except Exception as e: print "Exception - ",e self.message = e