chg: Use simplejson when possible & gunicorn for production.

pull/12/head
Raphaël Vinot 2018-11-27 11:03:18 +01:00
parent 07559a2ed8
commit af6189bbfd
15 changed files with 46 additions and 13 deletions

View File

@ -8,7 +8,10 @@ from dateutil.relativedelta import relativedelta
from collections import defaultdict from collections import defaultdict
import zipfile import zipfile
import logging import logging
import json try:
import simplejson as json
except ImportError:
import json
from .libs.helpers import safe_create_dir, set_running, unset_running from .libs.helpers import safe_create_dir, set_running, unset_running

View File

@ -1,7 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json try:
import simplejson as json
except ImportError:
import json
import re import re
import requests import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup

View File

@ -31,7 +31,7 @@ class DatabaseInsert():
while True: while True:
if shutdown_requested(): if shutdown_requested():
break break
uuids = self.redis_sanitized.spop('to_insert', 1000) uuids = self.redis_sanitized.spop('to_insert', 100)
if not uuids: if not uuids:
break break
p = self.redis_sanitized.pipeline(transaction=False) p = self.redis_sanitized.pipeline(transaction=False)

View File

@ -9,7 +9,10 @@ from redis import StrictRedis
from redis.exceptions import ConnectionError from redis.exceptions import ConnectionError
from datetime import datetime, timedelta from datetime import datetime, timedelta
import time import time
import json try:
import simplejson as json
except ImportError:
import json
from pyipasnhistory import IPASNHistory from pyipasnhistory import IPASNHistory

View File

@ -7,7 +7,10 @@ from datetime import datetime, timedelta
from ipaddress import IPv4Address, IPv6Address, IPv4Network, IPv6Network from ipaddress import IPv4Address, IPv6Address, IPv4Network, IPv6Network
from typing import TypeVar from typing import TypeVar
from .helpers import get_homedir, safe_create_dir from .helpers import get_homedir, safe_create_dir
import json try:
import simplejson as json
except ImportError:
import json
from dateutil.parser import parse from dateutil.parser import parse
import copy import copy

View File

@ -8,7 +8,10 @@ from hashlib import sha512 # Faster than sha256 on 64b machines.
from pathlib import Path from pathlib import Path
import logging import logging
from pid import PidFile, PidFileError from pid import PidFile, PidFileError
import json try:
import simplejson as json
except ImportError:
import json
from .libs.helpers import safe_create_dir, set_running, unset_running from .libs.helpers import safe_create_dir, set_running, unset_running

View File

@ -1,6 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json try:
import simplejson as json
except ImportError:
import json
from redis import StrictRedis from redis import StrictRedis
from .libs.helpers import get_socket_path, get_ipasn from .libs.helpers import get_socket_path, get_ipasn

View File

@ -4,7 +4,10 @@
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
import logging import logging
import json try:
import simplejson as json
except ImportError:
import json
import re import re
from redis import StrictRedis from redis import StrictRedis
from uuid import uuid4 from uuid import uuid4

View File

@ -35,7 +35,7 @@ class Sanitizer():
while True: while True:
if shutdown_requested(): if shutdown_requested():
break break
uuids = self.redis_intake.spop('intake', 1000) uuids = self.redis_intake.spop('intake', 100)
if not uuids: if not uuids:
break break
for_cache = [] for_cache = []

View File

@ -9,7 +9,10 @@ from typing import Tuple
from datetime import datetime, date from datetime import datetime, date
from pathlib import Path from pathlib import Path
from .libs.helpers import safe_create_dir, set_running, unset_running from .libs.helpers import safe_create_dir, set_running, unset_running
import json try:
import simplejson as json
except ImportError:
import json
class ShadowServerFetcher(): class ShadowServerFetcher():

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging import logging
import json try:
import simplejson as json
except ImportError:
import json
import asyncio import asyncio
from pathlib import Path from pathlib import Path
import aiohttp import aiohttp

View File

@ -5,6 +5,7 @@ git+https://github.com/jsommers/pytricia.git
git+https://github.com/trbs/pid.git git+https://github.com/trbs/pid.git
aiohttp aiohttp
requests requests
simplejson
git+https://github.com/MISP/PyTaxonomies git+https://github.com/MISP/PyTaxonomies
git+https://github.com/MISP/PyMISPGalaxies.git git+https://github.com/MISP/PyMISPGalaxies.git

View File

@ -4,6 +4,6 @@ Install the dependencies, run
```bash ```bash
export FLASK_APP=${BGPRANKING_HOME}/website/web/__init__.py export FLASK_APP=${BGPRANKING_HOME}/website/web/__init__.py
flask run --port 5005 gunicorn --worker-class gevent -w 10 -b 127.0.0.1:5005 web:app
``` ```

View File

@ -1,6 +1,8 @@
# Web thing # Web thing
flask flask
flask-bootstrap flask-bootstrap
gunicorn[gevent]
# Other # Other
pycountry pycountry

View File

@ -1,7 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json try:
import simplejson as json
except ImportError:
import json
from flask import Flask, render_template, request, session, Response from flask import Flask, render_template, request, session, Response
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap