def storeToken(self, tokenObject): self.resetErrors() index = "resumptionTokens-STORE" table = "resumptionTokens" fields = { "token": tokenObject.getToken(), "metadataPrefix": tokenObject.getMetadataPrefix(), "expiry": Timestamp(tokenObject.getExpiry()), "nextToken": tokenObject.getNextToken(), "resultJson": "" } FileUtils.writeStringToFile( File( FascinatorHome.getPath("oaipmh-results") + "/" + tokenObject.getToken()), tokenObject.getResultJson()) #self.log.debug("=== storeToken()") #self.log.debug("=== TOKEN: '{}'", tokenObject.getToken()) #self.log.debug("=== METADATAPREFIX: '{}'", tokenObject.getMetadataPrefix()) #self.log.debug("=== EXPIRY: '{}'", tokenObject.getExpiry()) #self.log.debug("=== TOTALFOUND: '{}'", tokenObject.getTotalFound()) #self.log.debug("=== START: '{}'", tokenObject.getStart()) try: self.db.insert(self.dbName, index, table, fields) except Exception, e: msg = self.parseError(e) if msg == "Duplicate record!": # Expected failure self.log.error("Duplicate record already exists in table!") else: # Something is wrong self.log.error("ERROR: ", e) self.error = True self.errorMsg = msg
def storeToken(self, tokenObject): self.resetErrors() index = "resumptionTokens-STORE" table = "resumptionTokens" fields = { "token": tokenObject.getToken(), "metadataPrefix": tokenObject.getMetadataPrefix(), "expiry": Timestamp(tokenObject.getExpiry()), "nextToken": tokenObject.getNextToken(), "resultJson": "" } FileUtils.writeStringToFile(File(FascinatorHome.getPath("oaipmh-results")+ "/"+tokenObject.getToken()),tokenObject.getResultJson()) #self.log.debug("=== storeToken()") #self.log.debug("=== TOKEN: '{}'", tokenObject.getToken()) #self.log.debug("=== METADATAPREFIX: '{}'", tokenObject.getMetadataPrefix()) #self.log.debug("=== EXPIRY: '{}'", tokenObject.getExpiry()) #self.log.debug("=== TOTALFOUND: '{}'", tokenObject.getTotalFound()) #self.log.debug("=== START: '{}'", tokenObject.getStart()) try: self.db.insert(self.dbName, index, table, fields) except Exception, e: msg = self.parseError(e) if msg == "Duplicate record!": # Expected failure self.log.error("Duplicate record already exists in table!") else: # Something is wrong self.log.error("ERROR: ", e) self.error = True self.errorMsg = msg
def getKeysArray(self): keysFile = FileUtils.getFile(self.systemConfig.getString("", "api", "apiKeyFile")) keysFile.createNewFile() try: keysJsonSimple = JsonSimple(keysFile) except IOException, ParseException: self.log.warn("File may be blank. Creating empty json api keys file...") FileUtils.writeStringToFile(keysFile, '{"api": {"clients": []}}') keysJsonSimple = JsonSimple(keysFile)
def writeResponseToStatusResponseCache(self, jobId, jobStatus): curationStatusRespones = File(FascinatorHome.getPath() + "/curation-status-responses") if curationStatusRespones.exists(): FileUtils.forceMkdir(curationStatusRespones) FileUtils.writeStringToFile( File(curationStatusRespones.getPath() + "/" + Integer(jobId).toString() + ".json"), jobStatus.toString(True))
def writeResponseToStatusResponseCache(self, jobId, jobStatus): curationStatusRespones = File(FascinatorHome.getPath()+ "/curation-status-responses") if curationStatusRespones.exists(): FileUtils.forceMkdir(curationStatusRespones) FileUtils.writeStringToFile(File(curationStatusRespones.getPath()+ "/" + Integer(jobId).toString() + ".json"), jobStatus.toString(True))
def saveGitBranch(branch): RELOAD_LOCK.lock() try: FileUtils.writeStringToFile(File(getGitBranchFile()), branch) finally: RELOAD_LOCK.unlock()
def saveGitUrl(url): RELOAD_LOCK.lock() try: FileUtils.writeStringToFile(File(getGitUrlFile()), url) finally: RELOAD_LOCK.unlock()