Exemplo n.º 1
0
    def fetchFolderTree(self, path='/content/dam', csv_file='output/folder_tree.csv', props=['jcr:path', 'jcr:content/jcr:title']):
        '''
        Fetches the folder structure under the given path and writes it to an output csv file 
        '''
        folder_data = []
        url = Assets.URL['fetchFolderTree'] + path
        url = url.replace('$props', ' '.join(props))
        
        logging.debug(url)

        response = self.conn.get(url)
        if response.success:
            folder_data.append(props)
            for folder in response.data[Assets.CFG['assets_key']]:
                folder_props = []
                for key in props:
                    folder_props.append(self._metaVal(folder, key))
                folder_data.append(folder_props)
            logging.debug("Writing folder list to : " + csv_file)
            dir, fname = dir_n_file(csv_file, 'csv')
            env = Env(dir)
            env.writeCSV(fname, data=folder_data)
        else:
            logging.error('Error fetching folder list')
            logging.error('Failed due to : '+response.message)
            logging.error('Empty list returned')
        return folder_data
Exemplo n.º 2
0
    def list(self, path='/content/dam', csv_dump=False, csv_file='output/asset_list.csv'):
        '''
        Get the list of all assets under the path given as parameter and optionally write it to a CSV file
        '''
    
        asset_list = []
        url = Assets.URL['list'] + path

        logging.debug('URL : '+url)

        response = self.conn.get(url)

        if response.success:
            for e in response.data[Assets.CFG['assets_key']]:
                asset_list.append(e[Assets.CFG['path_key']])    
        else:
            logging.error('Error getting the assets list')
            logging.error('Failed due to : '+response.message)
            logging.error('Empty list returned')
        if csv_dump or csv_file:
            logging.debug("Writing asset list of assets to : " + csv_file)
            dir, fname = dir_n_file(csv_file, 'csv')
            env = Env(dir)
            env.writeCSV(fname, list=asset_list)
        return asset_list
Exemplo n.º 3
0
    def xprops(self, path='/content/dam', props=['jcr:path','jcr:content/metadata/dc:title'], csv_file='output/asset_props.csv'):
        '''
        Extracts the metadata properties of the assets under the given path and writes it to an output csv file 
        '''
        asset_data = []
        url = Assets.URL['xprops'] + path
        url = url.replace('$props', ' '.join(props))
        
        logging.debug(url)

        response = self.conn.get(url)
        if response.success:
            asset_data.append(props)
            for asset in response.data[Assets.CFG['assets_key']]:
                asset_props = []
                for key in props:
                    asset_props.append(self._metaVal(asset, key))
                asset_data.append(asset_props)
            logging.debug("Writing asset list of assets to : " + csv_file)
            dir, fname = dir_n_file(csv_file, 'csv')
            env = Env(dir)
            env.writeCSV(fname, data=asset_data)
            return True
        else:
            logging.error('Error extracting asset properties')
            logging.error('Failed due to : '+response.message)
            logging.error('Empty list returned')
        return False