Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Transparenzportal
ckanext-odsh
Commits
0c7e6d6c
Commit
0c7e6d6c
authored
5 years ago
by
Daniel Neuwirth
Browse files
Options
Downloads
Patches
Plain Diff
enqueuedsaved
parent
4bb6998c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ckanext/odsh/pdf_to_thumbnail/enqueue.py
+3
-80
3 additions, 80 deletions
ckanext/odsh/pdf_to_thumbnail/enqueue.py
with
3 additions
and
80 deletions
ckanext/odsh/pdf_to_thumbnail/enqueue.py
+
3
−
80
View file @
0c7e6d6c
from
__future__
import
absolute_import
,
print_function
,
unicode_literals
#Note to change it to a background job, just this file would need to be be edited
#please look up the branch URL_Upload
from
.thumbnail
import
create_thumbnail
,
create_thumbnail_for_last_resource
from
.thumbnail
import
create_thumbnail
,
create_thumbnail_for_last_resource
import
ckan.plugins.toolkit
as
toolkit
import
ckan.plugins.toolkit
as
toolkit
from
pylons
import
config
import
logging.config
import
os.path
import
paste.deploy
from
paste.registry
import
Registry
from
pylons
import
config
,
translator
from
ckan.plugins
import
toolkit
from
ckan.config.environment
import
load_environment
from
ckan.lib.cli
import
MockTranslator
# Adapted from ckanext-archiver
def
_register_translator
():
"""
Register a translator in this thread.
"""
global
registry
try
:
registry
except
NameError
:
registry
=
Registry
()
registry
.
prepare
()
global
translator_obj
try
:
translator_obj
except
NameError
:
translator_obj
=
MockTranslator
()
registry
.
register
(
translator
,
translator_obj
)
# Adapted from ckanext-archiver
def
load_config
(
ini_path
):
"""
Load CKAN configuration.
"""
ini_path
=
os
.
path
.
abspath
(
ini_path
)
logging
.
config
.
fileConfig
(
ini_path
,
disable_existing_loggers
=
False
)
conf
=
paste
.
deploy
.
appconfig
(
'
config:
'
+
ini_path
)
load_environment
(
conf
.
global_conf
,
conf
.
local_conf
)
_register_translator
()
def
job_after_create
(
ini_path
,
resource
,
private
):
load_config
(
ini_path
)
create_thumbnail
(
resource
,
private
)
def
enqueue_after_create
(
context
,
resource
):
def
enqueue_after_create
(
context
,
resource
):
package
=
context
.
get
(
'
package
'
)
package
=
context
.
get
(
'
package
'
)
private
=
package
.
private
private
=
package
.
private
...
@@ -61,19 +11,6 @@ def enqueue_after_create(context, resource):
...
@@ -61,19 +11,6 @@ def enqueue_after_create(context, resource):
# without the background job
# 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)
def
job_after_update
(
ini_path
,
resources
,
private
,
package_id
):
load_config
(
ini_path
)
create_thumbnail_for_last_resource
(
resources
,
private
,
package_id
)
def
enqueue_after_update
(
context
,
resource
):
def
enqueue_after_update
(
context
,
resource
):
package
=
context
.
get
(
'
package
'
)
package
=
context
.
get
(
'
package
'
)
private
=
package
.
private
private
=
package
.
private
...
@@ -84,15 +21,6 @@ def enqueue_after_update(context, resource):
...
@@ -84,15 +21,6 @@ def enqueue_after_update(context, resource):
# without the background job
# without the background job
create_thumbnail_for_last_resource
(
resources
,
private
,
package_id
)
create_thumbnail_for_last_resource
(
resources
,
private
,
package_id
)
#background job
#args = (config['__file__'], resources, private, package_id)
#title = 'Thumbnail updating for resource {}'.format(resource['id'])
#toolkit.enqueue_job(job_after_update, args=args, title=title)
def
job_after_delete
(
ini_path
,
resources
,
private
,
package_id
):
load_config
(
ini_path
)
create_thumbnail_for_last_resource
(
resources
,
private
,
package_id
)
def
enqueue_after_delete
(
context
,
resources
):
def
enqueue_after_delete
(
context
,
resources
):
if
len
(
resources
)
>
0
:
if
len
(
resources
)
>
0
:
package
=
context
.
get
(
'
package
'
)
package
=
context
.
get
(
'
package
'
)
...
@@ -103,11 +31,6 @@ def enqueue_after_delete(context, resources):
...
@@ -103,11 +31,6 @@ def enqueue_after_delete(context, resources):
# without the background job
# without the background job
create_thumbnail_for_last_resource
(
resources
,
private
,
package_id
)
create_thumbnail_for_last_resource
(
resources
,
private
,
package_id
)
#background job
#args = (config['__file__'], resources, private, package_id)
#title = 'Thumbnail deleting for resource {}'.format(package_id)
#toolkit.enqueue_job(job_after_delete, args=args, title=title)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment