Skip to content
Snippets Groups Projects
Verified Commit d0a8929d authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

Cesiumplus fallbacks

parent 8d80db72
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ import plyvel, json, urllib.request, networkx, random, math, re, utils ...@@ -4,7 +4,7 @@ import plyvel, json, urllib.request, networkx, random, math, re, utils
from math import * from math import *
from utils import * from utils import *
CESIUMPLUS_URL = "https://g1.data.presles.fr" CESIUMPLUS_URL = "https://g1.data.le-sou.org,https://g1.data.e-is.pro,https://g1.data.adn.life,https://g1.data.presles.fr"
DUNITER_PATH = "~/.config/duniter/duniter_default" DUNITER_PATH = "~/.config/duniter/duniter_default"
OUTPUT_PATH = "www/data" OUTPUT_PATH = "www/data"
OVERLAY_PRECISION = "0.5" OVERLAY_PRECISION = "0.5"
...@@ -65,7 +65,7 @@ Duniter must not be running while extracting LevelDB data. ...@@ -65,7 +65,7 @@ Duniter must not be running while extracting LevelDB data.
Only compatible with Duniter >=1.7.9. Only compatible with Duniter >=1.7.9.
Options: Options:
-c <url> Cesium+ URL (default={}) -c <url> Cesium+ URLs separated by commas (default={})
-d <path> Duniter profile path (default={}) -d <path> Duniter profile path (default={})
-e <path> Output dir (default={}) -e <path> Output dir (default={})
-o Do not generate image overlays -o Do not generate image overlays
...@@ -81,6 +81,8 @@ Options: ...@@ -81,6 +81,8 @@ Options:
antispam = "--spam" in sys.argv antispam = "--spam" in sys.argv
cesiumplus_urls = getargv("-c", CESIUMPLUS_URL).split(",")
output_dir = format_path(getargv("-e", OUTPUT_PATH)) output_dir = format_path(getargv("-e", OUTPUT_PATH))
try: try:
os.mkdir(output_dir) os.mkdir(output_dir)
...@@ -116,21 +118,24 @@ Options: ...@@ -116,21 +118,24 @@ Options:
"size": 10000, "size": 10000,
"_source": ["title", "geoPoint", "avatar._content_type"] "_source": ["title", "geoPoint", "avatar._content_type"]
} }
log("Request Cesium+", LOG_TRACE)
for cesiumplus_url in cesiumplus_urls:
log("Request Cesium+ {}".format(cesiumplus_url), LOG_TRACE)
try: try:
resp = json.loads(urllib.request.urlopen( resp = json.loads(urllib.request.urlopen(
getargv("-c", CESIUMPLUS_URL)+"/user/profile/_search?scroll=2m", cesiumplus_url+"/user/profile/_search?scroll=2m",
json.dumps(query).encode() json.dumps(query).encode()
).read().decode()) ).read().decode())
except urllib.error.HTTPError as err: except urllib.error.HTTPError as err:
log("Cesium+ HTTP Error: {}".format(err), LOG_ERROR) log("Cesium+ HTTP Error: {}".format(err), LOG_ERROR)
continue
results += resp["hits"]["hits"] results += resp["hits"]["hits"]
scroll_id = resp.get("_scroll_id") scroll_id = resp.get("_scroll_id")
for i in range(100): for i in range(100):
log("Request Cesium+: scroll {}".format(i), LOG_TRACE) log("Request Cesium+: scroll {}".format(i), LOG_TRACE)
try: try:
resp = json.loads(urllib.request.urlopen( resp = json.loads(urllib.request.urlopen(
getargv("-c", CESIUMPLUS_URL)+"/_search/scroll", cesiumplus_url+"/_search/scroll",
json.dumps({ json.dumps({
"scroll": "1m", "scroll": "1m",
"scroll_id": scroll_id "scroll_id": scroll_id
...@@ -142,6 +147,7 @@ Options: ...@@ -142,6 +147,7 @@ Options:
scroll_id = resp.get("scroll_id") scroll_id = resp.get("scroll_id")
if not scroll_id: if not scroll_id:
break break
break
log("Cesium+ accounts: {}".format(len(results)), LOG_INFO) log("Cesium+ accounts: {}".format(len(results)), LOG_INFO)
log("Opening DBs") log("Opening DBs")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment