예제 #1
0
    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
예제 #2
0
 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
예제 #3
0
 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)
예제 #4
0
    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))
예제 #5
0
    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))
예제 #6
0
def saveGitBranch(branch):
    RELOAD_LOCK.lock()
    try:
        FileUtils.writeStringToFile(File(getGitBranchFile()), branch)
    finally:
        RELOAD_LOCK.unlock()
예제 #7
0
def saveGitUrl(url):
    RELOAD_LOCK.lock()
    try:
        FileUtils.writeStringToFile(File(getGitUrlFile()), url)
    finally:
        RELOAD_LOCK.unlock()