本文整理汇总了Python中datastore.DataStore.addAndMarkArchiveManagerJobToDataBaseAsUnkown方法的典型用法代码示例。如果您正苦于以下问题:Python DataStore.addAndMarkArchiveManagerJobToDataBaseAsUnkown方法的具体用法?Python DataStore.addAndMarkArchiveManagerJobToDataBaseAsUnkown怎么用?Python DataStore.addAndMarkArchiveManagerJobToDataBaseAsUnkown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datastore.DataStore
的用法示例。
在下文中一共展示了DataStore.addAndMarkArchiveManagerJobToDataBaseAsUnkown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DecryptorWatcher
# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import addAndMarkArchiveManagerJobToDataBaseAsUnkown [as 别名]
class DecryptorWatcher(LoggingEventHandler):
'''
This class enters all file 'created' events to a database pointed to by dbFolder
'''
def __init__(self, pathStructure, dbFolder):
super(LoggingEventHandler, self).__init__()
self.pathStructure = pathStructure
self.dataStore = DataStore(dbFolder)
def on_modified(self, event):
if os.path.isdir(event.src_path):
info = "Modified: " + event.src_path + " " + str(getsizeFolder(event.src_path))
logging.debug(info)
else:
info = "Modified: " + event.src_path + " " + str(os.path.getsize(event.src_path))
logging.debug(info)
def on_created(self, event):
'''
if the path is a folder, then retrieve the archive manager request, save the the result to a new table called amjobs.
the table will have the following columns id, data, complete. The data will have the json data from which i can retrieve
all of the files.
'''
if os.path.isdir(os.path.abspath(event.src_path)):
info = "Created Folder: " + event.src_path + " " + str(getsizeFolder(event.src_path))
logging.debug(info)
try:
droppedFolder = event.src_path.split(self.pathStructure['inBox'])[1].split(os.sep)[1]
pathComponents = [elem for elem in droppedFolder.split(os.sep) if elem != '']
if len(pathComponents) == 1:
info = "will add " + droppedFolder + " to path"
logging.debug(info)
amDataAsString = jsonStringForAMNumber(droppedFolder)
if isAMDataValid(amDataAsString) == False:
self.dataStore.addAndMarkArchiveManagerJobToDataBaseAsUnkown(droppedFolder, event.src_path)
errorString = '''A folder was added to the Decrypt Path %s for which no Archive Manager Data was found. Check the name of the folder that was dropped and make sure that the Archive Manager request exists and that the Archive Manager is accessible. Files added to this folder will not be Decrypted until the error is resolved.'''
errorString = errorString % self.pathStructure['inBox']
raise Exception(errorString)
uuid = createFileWithUUIDatPath(event.src_path)
self.dataStore.addArchiveManagerJobToDataBaseWithUUID(droppedFolder, amDataAsString, event.src_path, uuid)
elif len(pathComponents) > 1:
logging.debug('This folder path is nested and will not be accepted')
raise Exception('failed to get data from server')
except Exception as e:
info = e.message
logging.debug(info)
sendFailureEmail(info)
else:
#file
try:
droppedFile = event.src_path.split(self.pathStructure['inBox'])[1]
pathComponents = [elem for elem in droppedFile.split(os.sep) if elem != '']
if os.path.basename(event.src_path) in ['Thumbs.db', '.DS_Store']:
pass
elif os.path.basename(event.src_path).startswith('UUID_'):
pass
elif len(pathComponents) == 1:
#single file
pathToAdd = pathComponents[0]
self.dataStore.addFilePathToDataBaseStoreWithType(os.path.abspath(event.src_path), self.pathStructure['watchType'], self.pathStructure['name'])
info = "Created: " + pathToAdd + " " + str(os.path.getsize(event.src_path))
logging.debug(info)
elif len(pathComponents) == 2:
#ADD BATCH FLAG AND AM FOLDER NAME
batchName = pathComponents[0]
self.dataStore.addBatchFilePathToDataBaseStoreWithType(os.path.abspath(event.src_path), self.pathStructure['watchType'], self.pathStructure['name'], batchName)
info = "Created File: " + event.src_path + " " + str(os.path.getsize(event.src_path))
logging.debug(info)
info = "will add " + str(pathComponents) + " to path"
logging.debug(info)
else:
raise Exception('This file path is nested OR incomplete and will not be accepted')
except Exception as e:
#GENERATE ERROR EMAIL
info = e.message
logging.debug(info)
sendFailureEmail(info)