Commit 24cd6f49 authored by sim's avatar sim

[FIX] Django settings import

parent b8d171bd
...@@ -13,7 +13,8 @@ django.setup() ...@@ -13,7 +13,8 @@ django.setup()
# ...to be able to import gargantext. # ...to be able to import gargantext.
from gargantext import settings, models from django.conf import settings
from gargantext import models
# this is the Alembic Config object, which provides # this is the Alembic Config object, which provides
# access to the values within the .ini file in use. # access to the values within the .ini file in use.
......
...@@ -37,7 +37,7 @@ import re ...@@ -37,7 +37,7 @@ import re
import importlib import importlib
from gargantext.util.lists import * from gargantext.util.lists import *
from gargantext.util import datetime, convert_to_datetime from gargantext.util import datetime, convert_to_datetime
from .settings import BASE_DIR from django.conf import settings
# types & models (nodes, lists, hyperdata, resource) --------------------------------------------- # types & models (nodes, lists, hyperdata, resource) ---------------------------------------------
LISTTYPES = { LISTTYPES = {
...@@ -398,7 +398,7 @@ DEFAULT_CSV_DELIM_GROUP = '|&|' ...@@ -398,7 +398,7 @@ DEFAULT_CSV_DELIM_GROUP = '|&|'
# Files ---------------------------------------------------------------- # Files ----------------------------------------------------------------
# uploads/.gitignore prevents corpora indexing # uploads/.gitignore prevents corpora indexing
# copora can be either a folder or symlink towards specific partition # copora can be either a folder or symlink towards specific partition
UPLOAD_DIRECTORY = os.path.join(BASE_DIR, 'uploads/corpora') UPLOAD_DIRECTORY = os.path.join(settings.BASE_DIR, 'uploads/corpora')
UPLOAD_LIMIT = 1024 * 1024 * 1024 UPLOAD_LIMIT = 1024 * 1024 * 1024
DOWNLOAD_DIRECTORY = UPLOAD_DIRECTORY DOWNLOAD_DIRECTORY = UPLOAD_DIRECTORY
......
...@@ -12,7 +12,7 @@ import random ...@@ -12,7 +12,7 @@ import random
import urllib.parse as uparse import urllib.parse as uparse
from lxml import etree from lxml import etree
from gargantext.settings import API_TOKENS from django.conf import settings
from ._Crawler import Crawler from ._Crawler import Crawler
from gargantext.util.timeit_damnit import timing from gargantext.util.timeit_damnit import timing
...@@ -21,7 +21,7 @@ from gargantext.util.timeit_damnit import timing ...@@ -21,7 +21,7 @@ from gargantext.util.timeit_damnit import timing
class CernCrawler(Crawler): class CernCrawler(Crawler):
'''CERN SCOAP3 API Interaction''' '''CERN SCOAP3 API Interaction'''
def __init__(self): def __init__(self):
API = API_TOKENS["CERN"] API = settings.API_TOKENS["CERN"]
self.apikey = API["APIKEY"].encode("utf-8") self.apikey = API["APIKEY"].encode("utf-8")
self.secret = bytearray(API["APISECRET"].encode("utf-8")) self.secret = bytearray(API["APISECRET"].encode("utf-8"))
self.BASE_URL = u"http://api.scoap3.org/search?" self.BASE_URL = u"http://api.scoap3.org/search?"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
from ._Crawler import * from ._Crawler import *
import json import json
from gargantext.settings import API_TOKENS from django.conf import settings
from gargantext.constants import UPLOAD_DIRECTORY from gargantext.constants import UPLOAD_DIRECTORY
from math import trunc from math import trunc
from gargantext.util.files import save from gargantext.util.files import save
...@@ -17,7 +17,7 @@ class MultivacCrawler(Crawler): ...@@ -17,7 +17,7 @@ class MultivacCrawler(Crawler):
''' Multivac API CLIENT''' ''' Multivac API CLIENT'''
def __init__(self): def __init__(self):
self.apikey = API_TOKENS["MULTIVAC"] self.apikey = settings.API_TOKENS["MULTIVAC"]
# Main EndPoints # Main EndPoints
self.BASE_URL = "https://api.iscpif.fr/v2" self.BASE_URL = "https://api.iscpif.fr/v2"
...@@ -37,7 +37,7 @@ class MultivacCrawler(Crawler): ...@@ -37,7 +37,7 @@ class MultivacCrawler(Crawler):
querystring = { "q" : query querystring = { "q" : query
, "count" : count , "count" : count
, "from" : fromPage , "from" : fromPage
, "api_key" : API_TOKENS["MULTIVAC"]["APIKEY"] , "api_key" : settings.API_TOKENS["MULTIVAC"]["APIKEY"]
} }
if lang is not None: if lang is not None:
......
...@@ -13,7 +13,6 @@ import datetime ...@@ -13,7 +13,6 @@ import datetime
from os import path from os import path
import threading import threading
from traceback import print_tb from traceback import print_tb
#from gargantext.settings import MEDIA_ROOT, BASE_DIR
from ._Crawler import Crawler from ._Crawler import Crawler
import requests import requests
from lxml import etree from lxml import etree
......
import importlib import importlib
from django.conf import settings
from gargantext.constants import RESOURCETYPES from gargantext.constants import RESOURCETYPES
from gargantext.settings import DEBUG
#if DEBUG: print("Loading available Crawlers") #if settings.DEBUG: print("Loading available Crawlers")
base_parser = "gargantext.util.crawlers" base_parser = "gargantext.util.crawlers"
for resource in RESOURCETYPES: for resource in RESOURCETYPES:
...@@ -14,7 +14,7 @@ for resource in RESOURCETYPES: ...@@ -14,7 +14,7 @@ for resource in RESOURCETYPES:
module = base_parser+".%s" %(filename) module = base_parser+".%s" %(filename)
importlib.import_module(module) importlib.import_module(module)
#if DEBUG: print("\t-", name) #if settings.DEBUG: print("\t-", name)
except Exception as e: except Exception as e:
print("Check constants.py RESOURCETYPES declaration %s \nCRAWLER %s is not available for %s" %(str(e), resource["crawler"], resource["name"])) print("Check constants.py RESOURCETYPES declaration %s \nCRAWLER %s is not available for %s" %(str(e), resource["crawler"], resource["name"]))
......
import subprocess import subprocess
import re import re
from django.conf import settings
from .sparql import Service from .sparql import Service
from gargantext.settings import BOOL_TOOLS_PATH
#from sparql import Service
def bool2sparql(rawQuery, count=False, offset=None, limit=None): def bool2sparql(rawQuery, count=False, offset=None, limit=None):
""" """
...@@ -13,7 +12,7 @@ def bool2sparql(rawQuery, count=False, offset=None, limit=None): ...@@ -13,7 +12,7 @@ def bool2sparql(rawQuery, count=False, offset=None, limit=None):
See: https://github.com/delanoe/bool2sparql See: https://github.com/delanoe/bool2sparql
""" """
query = re.sub("\"", "\'", rawQuery) query = re.sub("\"", "\'", rawQuery)
bashCommand = [BOOL_TOOLS_PATH + "/bool2sparql-exe","-q",query] bashCommand = [settings.BOOL_TOOLS_PATH + "/bool2sparql-exe","-q",query]
if count is True : if count is True :
bashCommand.append("-c") bashCommand.append("-c")
......
import os
from gargantext.settings import MEDIA_ROOT
from datetime import MINYEAR from datetime import MINYEAR
from dateutil.parser import parse as parse_datetime_flexible from dateutil.parser import parse as parse_datetime_flexible
from django.utils.dateparse import parse_datetime from django.utils.dateparse import parse_datetime
......
from gargantext import settings from django.conf import settings
from gargantext.util.json import json_dumps from gargantext.util.json import json_dumps
......
...@@ -6,7 +6,7 @@ from django import forms ...@@ -6,7 +6,7 @@ from django import forms
from urllib.parse import quote_plus as urlencode from urllib.parse import quote_plus as urlencode
from gargantext import settings from django.conf import settings
from sqlalchemy.orm.exc import DetachedInstanceError from sqlalchemy.orm.exc import DetachedInstanceError
from traceback import print_tb from traceback import print_tb
......
import importlib import importlib
from gargantext.constants import RESOURCETYPES from gargantext.constants import RESOURCETYPES
from gargantext.settings import DEBUG from django.conf import settings
if DEBUG: if settings.DEBUG:
print("Loading available PARSERS:") print("Loading available PARSERS:")
base_parser = "gargantext.util.parsers" base_parser = "gargantext.util.parsers"
for resource in RESOURCETYPES: for resource in RESOURCETYPES:
...@@ -12,6 +12,6 @@ for resource in RESOURCETYPES: ...@@ -12,6 +12,6 @@ for resource in RESOURCETYPES:
module = base_parser+".%s" %(fname.upper()) module = base_parser+".%s" %(fname.upper())
#parser module is has shown in constants #parser module is has shown in constants
parser = importlib.import_module(module) parser = importlib.import_module(module)
if DEBUG: if settings.DEBUG:
print("\t-", resource["parser"]) print("\t-", resource["parser"])
getattr(parser,resource["parser"]) getattr(parser,resource["parser"])
...@@ -42,8 +42,8 @@ def scheduled_celery(func): ...@@ -42,8 +42,8 @@ def scheduled_celery(func):
return go return go
from gargantext.settings import DEBUG from django.conf import settings
if DEBUG: if settings.DEBUG:
# scheduled = scheduled_now # scheduled = scheduled_now
scheduled = scheduled_thread scheduled = scheduled_thread
else: else:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from gargantext.models.users import User from gargantext.models.users import User
from gargantext.util.db import session from gargantext.util.db import session
from django.core.mail import send_mail from django.core.mail import send_mail
from gargantext.settings import BASE_URL from django.conf import settings
...@@ -65,7 +65,7 @@ drafts = { ...@@ -65,7 +65,7 @@ drafts = {
def notification(corpus, draft, subject='Update'): def notification(corpus, draft, subject='Update'):
user = session.query(User).filter(User.id == corpus.user_id).first() user = session.query(User).filter(User.id == corpus.user_id).first()
message = draft % (corpus.name, BASE_URL, corpus.parent_id, corpus.id) message = draft % (corpus.name, settings.BASE_URL, corpus.parent_id, corpus.id)
if user.email != "" : if user.email != "" :
send_mail('[Gargantext] %s' % subject send_mail('[Gargantext] %s' % subject
......
from gargantext.settings import DEBUG from django.conf import settings
from .parsing import parse from .parsing import parse
from .ngrams_extraction import extract_ngrams from .ngrams_extraction import extract_ngrams
from .hyperdata_indexing import index_hyperdata from .hyperdata_indexing import index_hyperdata
...@@ -176,7 +176,7 @@ def parse_extract_indexhyperdata(corpus): ...@@ -176,7 +176,7 @@ def parse_extract_indexhyperdata(corpus):
session.commit() session.commit()
if DEBUG is False: if settings.DEBUG is False:
print('CORPUS #%d: [%s] FINISHED Sending email notification' % (corpus.id, t())) print('CORPUS #%d: [%s] FINISHED Sending email notification' % (corpus.id, t()))
notify_owner(corpus) notify_owner(corpus)
...@@ -299,7 +299,7 @@ def recount(corpus_id): ...@@ -299,7 +299,7 @@ def recount(corpus_id):
corpus.save_hyperdata() corpus.save_hyperdata()
session.commit() session.commit()
if not DEBUG: if not settings.DEBUG:
print('RECOUNT #%d: [%s] FINISHED Sending email notification' % (corpus.id, t())) print('RECOUNT #%d: [%s] FINISHED Sending email notification' % (corpus.id, t()))
notify_recount(corpus) notify_recount(corpus)
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
COOCS COOCS
(this is the full SQL version, should be more reliable on outerjoin) (this is the full SQL version, should be more reliable on outerjoin)
""" """
from gargantext import settings
from sqlalchemy import exc from sqlalchemy import exc
from gargantext.util.lists import WeightedMatrix from gargantext.util.lists import WeightedMatrix
from gargantext.util.db import get_engine from gargantext.util.db import get_engine
......
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