Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
f6b14153
Commit
f6b14153
authored
Apr 16, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Admin utils, check if user has a folder. Please this function.
parent
4e74b74e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
utils.py
admin/utils.py
+11
-0
views_optimized.py
gargantext_web/views_optimized.py
+4
-5
views.py
scrappers/scrap_pubmed/views.py
+4
-0
No files found.
admin/utils.py
0 → 100644
View file @
f6b14153
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
)
gargantext_web/views_optimized.py
View file @
f6b14153
...
...
@@ -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
)
...
...
scrappers/scrap_pubmed/views.py
View file @
f6b14153
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment