forked from mparisot-wescale/memopol2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enh] new script to update all the current meps in the db with parltr…
…ack data
- Loading branch information
1 parent
fb4d1a8
commit c3bfbed
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/python | ||
# -*- coding:Utf-8 -*- | ||
|
||
import json | ||
|
||
from urllib import urlopen | ||
|
||
from django.conf import settings | ||
|
||
from meps.models import MEP | ||
|
||
from current_meps_json_2_sql import clean_existant_data, manage_mep | ||
|
||
if __name__ == "__main__": | ||
print "load json" | ||
meps = json.load(urlopen(settings.PARLTRACK_URL + "/search?s_meps=on&q=+&format=json")) | ||
a = 0 | ||
for mep_json in meps["items"]: | ||
a += 1 | ||
print a, "-", mep_json["Name"]["full"] | ||
in_db_mep = MEP.objects.filter(ep_id=mep_json["UserID"]) | ||
if in_db_mep: | ||
mep = in_db_mep[0] | ||
clean_existant_data(mep) | ||
manage_mep(mep, mep_json) | ||
|
||
# vim:set shiftwidth=4 tabstop=4 expandtab: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
export PYTHONPATH="../:"$PYTHONPATH | ||
export PYTHONPATH="../apps/:"$PYTHONPATH | ||
export DJANGO_SETTINGS_MODULE="memopol2.settings" | ||
|
||
echo "Starting the update" | ||
python ./update_meps.py || (echo "import json data into the database failed" && echo "end" && exit 1) | ||
|
||
echo | ||
echo "successful end" |