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

without background

parent a730e316
Branches
No related tags found
No related merge requests found
......@@ -59,12 +59,12 @@ def enqueue_after_create(context, resource):
private = package.private
# without the background job
#create_thumbnail(resource, private)
create_thumbnail(resource, private)
#background job
args = (config['__file__'], resource, private)
title = 'Thumbnail creating for resource {}'.format(resource['id'])
toolkit.enqueue_job(job_after_create, args=args, title=title)
#args = (config['__file__'], resource, private)
#title = 'Thumbnail creating for resource {}'.format(resource['id'])
#toolkit.enqueue_job(job_after_create, args=args, title=title)
......
......@@ -55,8 +55,7 @@ def change_filepath(package_id, old_private, new_private):
def create_thumbnail_from_file(file, package_id, private):
log.debug("create_thumbnail_from_file")
log.warning("create_thumbnail_from_file")
log.debug('create_thumbnail_from_file')
width = config.get('ckan.thumbnail.size.width', 410)
filename = hash_filename(package_id, private)
file.seek(0)
......@@ -71,7 +70,6 @@ def create_thumbnail_from_file(file, package_id, private):
#size=(width, None),
output_folder=directory,
output_file=filename,
single_file=True,
first_page=0,
last_page=0,
fmt='jpg'
......@@ -80,6 +78,7 @@ def create_thumbnail_from_file(file, package_id, private):
def create_thumbnail_from_memory(resource, private):
log.debug('create_thumbnail_from_memory')
path = get_filepath_to_resource(resource)
file_type = magic.from_file(path, mime = True)
if file_type == 'application/pdf' and os.path.exists(path):
......@@ -99,6 +98,7 @@ def remove_thumbnail(package_id, private):
os.remove(filepath)
def create_thumbnail(resource, private):
log.debug('create_thumbnail')
resource_path = get_filepath_to_resource(resource)
if os.path.exists(resource_path):
return create_thumbnail_from_memory(resource, private)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment