Skip to content
Snippets Groups Projects
Commit 6b714820 authored by Daniel Neuwirth's avatar Daniel Neuwirth
Browse files

removed pdftotext

parent 0c7e6d6c
No related branches found
No related tags found
No related merge requests found
...@@ -10,26 +10,30 @@ import hashlib ...@@ -10,26 +10,30 @@ import hashlib
import binascii import binascii
import ckan.plugins.toolkit as toolkit import ckan.plugins.toolkit as toolkit
import ckan.logic as logic import ckan.logic as logic
#from extension
import pdftotext
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def get_filename_from_context(context): def get_filename_from_context(context):
package = context.get('package') package = context.get('package')
package_id = package.id package_id = package.id
return thumbnail return thumbnail
def get_filepath_for_thumbnail(filename): def get_filepath_for_thumbnail(filename):
if filename: if filename:
return config.get('ckan.storage_path') + "/thumbnail/" + filename return config.get('ckan.storage_path') + "/thumbnail/" + filename
return config.get('ckan.storage_path') + "/thumbnail/" return config.get('ckan.storage_path') + "/thumbnail/"
def concatenate_filename(filename): def concatenate_filename(filename):
return filename + ".jpg" return filename + ".jpg"
def get_filepath_to_resource(resource): def get_filepath_to_resource(resource):
resource_id = resource.get('id') resource_id = resource.get('id')
directory = config.get('ckan.storage_path') + '/resources/' directory = config.get('ckan.storage_path') + '/resources/'
...@@ -37,6 +41,7 @@ def get_filepath_to_resource(resource): ...@@ -37,6 +41,7 @@ def get_filepath_to_resource(resource):
path = directory + resource_id[0:3] + '/' + resource_id[3:6] + '/' + resource_id[6:] path = directory + resource_id[0:3] + '/' + resource_id[3:6] + '/' + resource_id[6:]
return path return path
def hash_filename(package_id, private): def hash_filename(package_id, private):
hash = hashlib.sha256(str(private) + 'ajsdpfawdgfacasdfvffffas' + package_id).hexdigest() hash = hashlib.sha256(str(private) + 'ajsdpfawdgfacasdfvffffas' + package_id).hexdigest()
filename = 'thumbnail_picture_' + hash filename = 'thumbnail_picture_' + hash
...@@ -76,7 +81,6 @@ def create_thumbnail_from_file(file, package_id, private): ...@@ -76,7 +81,6 @@ def create_thumbnail_from_file(file, package_id, private):
) )
def create_thumbnail_from_memory(resource, private): def create_thumbnail_from_memory(resource, private):
log.debug('create_thumbnail_from_memory') log.debug('create_thumbnail_from_memory')
path = get_filepath_to_resource(resource) path = get_filepath_to_resource(resource)
...@@ -91,12 +95,14 @@ def create_thumbnail_from_memory(resource, private): ...@@ -91,12 +95,14 @@ def create_thumbnail_from_memory(resource, private):
is_PDF = False is_PDF = False
return is_PDF return is_PDF
def remove_thumbnail(package_id, private): def remove_thumbnail(package_id, private):
filename = hash_filename(package_id, private) + '.jpg' filename = hash_filename(package_id, private) + '.jpg'
filepath = get_filepath_for_thumbnail(filename) filepath = get_filepath_for_thumbnail(filename)
if os.path.exists(filepath): if os.path.exists(filepath):
os.remove(filepath) os.remove(filepath)
def create_thumbnail(resource, private): def create_thumbnail(resource, private):
log.debug('create_thumbnail') log.debug('create_thumbnail')
resource_path = get_filepath_to_resource(resource) resource_path = get_filepath_to_resource(resource)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment