当前位置: 首页>>代码示例>>Python>>正文


Python DataStore.addFilePathToDataBaseStoreWithType方法代码示例

本文整理汇总了Python中datastore.DataStore.addFilePathToDataBaseStoreWithType方法的典型用法代码示例。如果您正苦于以下问题:Python DataStore.addFilePathToDataBaseStoreWithType方法的具体用法?Python DataStore.addFilePathToDataBaseStoreWithType怎么用?Python DataStore.addFilePathToDataBaseStoreWithType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datastore.DataStore的用法示例。


在下文中一共展示了DataStore.addFilePathToDataBaseStoreWithType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EncryptorWatcher

# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import addFilePathToDataBaseStoreWithType [as 别名]
class EncryptorWatcher(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):
        path = os.path.join(self.pathStructure['inBox'], event.src_path)
        logging.debug("encryptorWatch on_modified file")
        info = "Modified: " +  event.src_path + " " + str(os.path.getsize(path))
        logging.debug(info)

    def on_created(self, event):
        path = os.path.join(self.pathStructure['inBox'], event.src_path)
        
        if os.path.isdir(os.path.abspath(event.src_path)):
            logging.debug('WatchProcess: Folder Encryption is not supported.')
            return

        self.dataStore.addFilePathToDataBaseStoreWithType(os.path.abspath(event.src_path), self.pathStructure['watchType'], self.pathStructure['name'])

        info = "Created: " +  event.src_path + " " + str(os.path.getsize(path))
        logging.debug("encryptorWatch on_created file")
        logging.debug(info)
开发者ID:patrickcusack,项目名称:BWF,代码行数:29,代码来源:watchpathsubprocess.py

示例2: DecryptorWatcher

# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import addFilePathToDataBaseStoreWithType [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)
开发者ID:patrickcusack,项目名称:BWF,代码行数:89,代码来源:watchpathsubprocess.py


注:本文中的datastore.DataStore.addFilePathToDataBaseStoreWithType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。