mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Remove logging code
This commit is contained in:
parent
b0cf581da9
commit
8f3517d5b6
@ -7,7 +7,6 @@ from . import db
|
||||
from . import login_manager
|
||||
import os
|
||||
import shutil
|
||||
import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
@ -226,13 +225,10 @@ class User(UserMixin, db.Model):
|
||||
Delete user from database. Also delete all associated jobs and corpora
|
||||
files.
|
||||
"""
|
||||
logger = logging.getLogger(__name__)
|
||||
delete_path = os.path.join('/mnt/opaque/', str(self.id))
|
||||
logger.warning('Delete path for user is: {}'.format(delete_path))
|
||||
while os.path.exists(delete_path):
|
||||
try:
|
||||
shutil.rmtree(delete_path, ignore_errors=True)
|
||||
logger.warning('Path does still exist.')
|
||||
except OSError:
|
||||
pass
|
||||
db.session.delete(self)
|
||||
@ -383,14 +379,11 @@ class Job(db.Model):
|
||||
for good.
|
||||
See: https://docs.docker.com/engine/swarm/swarm-tutorial/delete-service/
|
||||
"""
|
||||
logger = logging.getLogger(__name__)
|
||||
delete_path = os.path.join('/mnt/opaque/', str(self.user_id), 'jobs',
|
||||
str(self.id))
|
||||
logger.warning('Delete path is: {}'.format(delete_path))
|
||||
while os.path.exists(delete_path):
|
||||
try:
|
||||
shutil.rmtree(delete_path, ignore_errors=True)
|
||||
logger.warning('Path does still exist.')
|
||||
except OSError:
|
||||
pass
|
||||
db.session.delete(self)
|
||||
@ -412,15 +405,12 @@ class CorpusFile(db.Model):
|
||||
corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id'))
|
||||
|
||||
def delete(self):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning('Called CorpusFile.delete')
|
||||
path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||
self.dir,
|
||||
self.filename)
|
||||
try:
|
||||
os.remove(path)
|
||||
except:
|
||||
logger.warning('[ERROR] CorpusFile.delete')
|
||||
return
|
||||
self.corpus.status = 'unprepared'
|
||||
db.session.delete(self)
|
||||
@ -473,24 +463,15 @@ class Corpus(db.Model):
|
||||
'user_id': self.user_id}
|
||||
|
||||
def delete(self):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning('Called Corpus.delete')
|
||||
for corpus_file in self.files:
|
||||
corpus_file.delete()
|
||||
logger.warning('bis hierhin und nicht weiter')
|
||||
logger.warning('base_dir: {}'.format(current_app.config['OPAQUE_STORAGE_DIRECTORY']))
|
||||
logger.warning('user_id: {}'.format(self.user_id))
|
||||
logger.warning('id: {}'.format(self.id))
|
||||
path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||
str(self.user_id),
|
||||
'corpora',
|
||||
str(self.id))
|
||||
logger.warning(path)
|
||||
try:
|
||||
logger.warning('Try to remove {}'.format(path))
|
||||
shutil.rmtree(path)
|
||||
except:
|
||||
logger.warning('[ERROR] Corpus.delete')
|
||||
return
|
||||
db.session.delete(self)
|
||||
db.session.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user