本文整理汇总了Python中datastore.DataStore.updateArchiveManagerJobErrorString方法的典型用法代码示例。如果您正苦于以下问题:Python DataStore.updateArchiveManagerJobErrorString方法的具体用法?Python DataStore.updateArchiveManagerJobErrorString怎么用?Python DataStore.updateArchiveManagerJobErrorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datastore.DataStore
的用法示例。
在下文中一共展示了DataStore.updateArchiveManagerJobErrorString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: decrypt
# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import updateArchiveManagerJobErrorString [as 别名]
#.........这里部分代码省略.........
datastore = DataStore(dbPath)
loopcount = 0
while True:
sleep(5)
if loopcount % 10 == 0:
logging.debug('Decryptor Process is alive')
loopcount += 1
data = datastore.recordsReadyToDecrypt()
for record in data:
logging.debug(record)
key_id = record.id
filePath = record.fileName
pathStructureName = record.pathStructureName
isBatch = record.isBatch
batchName = record.batchName
if not os.path.exists(filePath):
logging.debug('Decryptor: will update record status as the file no longer exists')
datastore.updateRecordAsMissingWithID(key_id)
else:
options = configurationOptions()
currentPathStructure = options.pathStructureWithName(pathStructureName)
decryptionErrorPath = currentPathStructure['errorBox']
decryptionInterimPath = currentPathStructure['interimBox']
options.inputPath = filePath
decryptedFilePath = os.path.join(decryptionInterimPath, os.path.basename(filePath))
operationStart = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
nextStatusValue = datastore.operationCompleteStatusCode()
message = 'Decryptor: decrypting file ' + filePath
logging.debug(message)
##UPDATE OPERATION START
datastore.updateRecordStatusWithOperationStart(operationStart, key_id)
args = [options.decryptorApplicationPath, filePath, decryptedFilePath]
process = subprocess.Popen(args)
out, err = process.communicate()
returnCode = process.returncode
message = 'Decryptor: decrypted file with return code ' + str(returnCode)
logging.debug(message)
operationStop = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
if returnCode != 0:
info = 'An error occurred with the Decryption operation when decrypting %s.' % (filePath)
logging.debug(info)
operationStart = datetime.datetime(2000,1,1)
operationStop = datetime.datetime(2000,1,1)
if isBatch == 0:
nextStatusValue = datastore.operationFailedStatusCode()
if os.path.abspath(os.path.dirname(filePath)) != os.path.abspath(decryptionErrorPath):
logging.debug('moving file to error path')
if os.path.exists(decryptionErrorPath):
# shutil.move(filePath, decryptionErrorPath)
# newPath = os.path.join(decryptionErrorPath, os.path.basename(filePath))
newPath = pathAfterSafelyMovingFileToDestinationFolder(filePath, decryptionErrorPath)
if not os.path.exists(newPath):
logging.debug('Decryptor: Error moving file')
nextStatusValue = datastore.errorMovingFileStatusCode()
else:
logging.debug('Decryptor: decryptionErrorPath doesnt exist')
nextStatusValue = datastore.errorPathDoesntExistStatusCode()
else:
#don't move batch files, just update the batch's am errorString to reflect the problem
#the file's checksum will fail
#we don't update the batch file's status
amRecord = datastore.recordWithNumberFromAMJobsTable(batchName)
if amRecord == None:
#This should not happen as we don't even allow for the logic to proceed to this point without
#a valid Archive Manager Record
info = 'An error occurred where no data was found for the Archive Manager job ' + batchName + '\n'
info = info + 'This error should not happen. Please check ' + os.path.dirname(filePath) + '\n'
info = info + 'The files will need to be manually removed from the Decryption Queue.'
logging.debug(info)
sendFailureEmail(info)
continue
errorString = 'A problem was encountered while decrypting %s.' % (filePath)
errorString = errorString + 'The file\'s checksum will be calculated and compared against that in Daisy should the error have occurred ater the file was decrypted.'
if amRecord.errorString != '':
amRecord.errorString = amRecord.errorString + '\n' + errorString
else:
amRecord.errorString = errorString
datastore.updateArchiveManagerJobErrorString(amRecord, amRecord.errorString)
# we update the status value
datastore.updateRecordStatusWithDecryptedFileNameAndStartAndEndTime(nextStatusValue, decryptedFilePath, operationStart, operationStop, key_id)