mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Add secure filename for modesl and services
This commit is contained in:
parent
4f5aeed215
commit
241a40ef44
@ -297,6 +297,7 @@ class Job(db.Model):
|
|||||||
end_date = db.Column(db.DateTime())
|
end_date = db.Column(db.DateTime())
|
||||||
mem_mb = db.Column(db.Integer)
|
mem_mb = db.Column(db.Integer)
|
||||||
n_cores = db.Column(db.Integer)
|
n_cores = db.Column(db.Integer)
|
||||||
|
secure_filename = db.Column(db.String(32))
|
||||||
service = db.Column(db.String(64))
|
service = db.Column(db.String(64))
|
||||||
'''
|
'''
|
||||||
' Service specific arguments as string list.
|
' Service specific arguments as string list.
|
||||||
@ -323,8 +324,7 @@ class Job(db.Model):
|
|||||||
"""
|
"""
|
||||||
Takes the job.title string nad cratesa a secure filename from this.
|
Takes the job.title string nad cratesa a secure filename from this.
|
||||||
"""
|
"""
|
||||||
filename = secure_filename(self.title)
|
self.secure_filename = secure_filename(self.title)
|
||||||
return filename
|
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""
|
"""
|
||||||
|
@ -37,12 +37,9 @@ def service(service):
|
|||||||
return make_response(add_job_form.errors, 400)
|
return make_response(add_job_form.errors, 400)
|
||||||
service_args = []
|
service_args = []
|
||||||
if service == 'nlp':
|
if service == 'nlp':
|
||||||
logger.warning(add_job_form.check_encoding)
|
|
||||||
service_args.append('-l {}'.format(add_job_form.language.data))
|
service_args.append('-l {}'.format(add_job_form.language.data))
|
||||||
logger.warning("Service args: {}".format(service_args))
|
|
||||||
if add_job_form.check_encoding.data:
|
if add_job_form.check_encoding.data:
|
||||||
service_args.append('--check-encoding')
|
service_args.append('--check-encoding')
|
||||||
logger.warning("Service args: {}".format(service_args))
|
|
||||||
if service == 'ocr':
|
if service == 'ocr':
|
||||||
service_args.append('-l {}'.format(add_job_form.language.data))
|
service_args.append('-l {}'.format(add_job_form.language.data))
|
||||||
if not add_job_form.binarization.data:
|
if not add_job_form.binarization.data:
|
||||||
@ -54,6 +51,8 @@ def service(service):
|
|||||||
service=service, service_args=json.dumps(service_args),
|
service=service, service_args=json.dumps(service_args),
|
||||||
service_version=add_job_form.version.data,
|
service_version=add_job_form.version.data,
|
||||||
status='preparing', title=add_job_form.title.data)
|
status='preparing', title=add_job_form.title.data)
|
||||||
|
if job.service != 'corpus_analysis':
|
||||||
|
job.create_secure_filename()
|
||||||
db.session.add(job)
|
db.session.add(job)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
relative_dir = os.path.join(str(job.user_id), 'jobs', str(job.id))
|
relative_dir = os.path.join(str(job.user_id), 'jobs', str(job.id))
|
||||||
|
28
migrations/versions/7378391345fa_.py
Normal file
28
migrations/versions/7378391345fa_.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 7378391345fa
|
||||||
|
Revises: 6227310c2112
|
||||||
|
Create Date: 2020-02-17 12:29:17.851954
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '7378391345fa'
|
||||||
|
down_revision = '6227310c2112'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('jobs', sa.Column('secure_filename', sa.String(length=32), nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('jobs', 'secure_filename')
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user