Skip to content

Commit

Permalink
[enh] new script to update all the current meps in the db with parltr…
Browse files Browse the repository at this point in the history
…ack data
  • Loading branch information
Psycojoker committed Jul 28, 2011
1 parent fb4d1a8 commit c3bfbed
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
27 changes: 27 additions & 0 deletions parltrack/update_meps.py
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:
11 changes: 11 additions & 0 deletions parltrack/update_meps.sh
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"

0 comments on commit c3bfbed

Please sign in to comment.