37 lines
682 B
Python
37 lines
682 B
Python
|
#!/usr/bin/python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
import json
|
||
|
import urllib2
|
||
|
import sys
|
||
|
import time
|
||
|
import host
|
||
|
|
||
|
address = 'http://'+host.concordia_host
|
||
|
if len(host.concordia_port) > 0:
|
||
|
address += ':'+host.concordia_port
|
||
|
|
||
|
|
||
|
with open(sys.argv[1]) as sources_file:
|
||
|
counter = 0
|
||
|
for line in sources_file:
|
||
|
counter += 1
|
||
|
idStr, link, name = line.rstrip().split('\t')
|
||
|
|
||
|
|
||
|
data = {
|
||
|
'operation': 'addSource',
|
||
|
'externalId':int(idStr),
|
||
|
'name':name,
|
||
|
'link':link
|
||
|
}
|
||
|
|
||
|
req = urllib2.Request(address)
|
||
|
req.add_header('Content-Type', 'application/json')
|
||
|
urllib2.urlopen(req, json.dumps(data)).read()
|
||
|
|
||
|
if counter % 1000 == 0:
|
||
|
print("Done %d sources" % counter)
|
||
|
|
||
|
|