Commit f6b14153 authored by Administrator's avatar Administrator

[FEAT] Admin utils, check if user has a folder. Please this function.

parent 4e74b74e
import os
from gargantext_web.settings import MEDIA_ROOT
def ensure_dir(user):
# If user is new, folder does not exist yet, create it then
dirpath = '%s/corpora/%s' % (MEDIA_ROOT, user.username)
if not os.path.exists(dirpath):
print("Creating folder %s" % dirpath)
os.makedirs(dirpath)
......@@ -26,6 +26,9 @@ from parsing.corpustools import add_resource, parse_resources, extract_ngrams, c
from gargantext_web.celery import apply_workflow
from admin.utils import ensure_dir
def project(request, project_id):
# do we have a valid project id?
......@@ -140,11 +143,7 @@ def project(request, project_id):
session.commit()
# If user is new, folder does not exist yet, create it then
dirpath = '%s/corpora/%s' % (MEDIA_ROOT, request.user.username)
if not os.path.exists(dirpath):
print("Creating folder %s" % dirpath)
os.makedirs(dirpath)
ensure_dir(request.user)
# Save the uploaded file
filepath = '%s/corpora/%s/%s' % (MEDIA_ROOT, request.user.username, thefile._name)
......
......@@ -37,6 +37,8 @@ from parsing.corpustools import add_resource, parse_resources, extract_ngrams, c
from gargantext_web.celery import apply_workflow
from time import sleep
from admin.utils import ensure_dir
def getGlobalStats(request ):
print(request.method)
alist = ["bar","foo"]
......@@ -141,7 +143,9 @@ def doTheQuery(request , project_id):
# """
ensure_dir(request.user)
tasks = MedlineFetcher()
for i in range(8):
t = threading.Thread(target=tasks.worker2) #thing to do
t.daemon = True # thread dies when main thread (only non-daemon thread) exits.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment