Commit 24cd6f49 authored by sim's avatar sim

[FIX] Django settings import

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