def reconnect():
conn_names = []
pids = psutil.pids()
for pid in pids:
pid = psutil.Process(pid)
if (pid.name() == 'openvpn'):
print(pid.connections()[0].status)
Traceback (most recent call last):
File "vpn_v.py", line 100, in <module>
reconnect()
File "vpn_v.py", line 69, in reconnect
print(pid.connections()[0].status)
IndexError: list index out of range
var connection = mysql.createConnection({
host : '127.0.0.1',
user : 'root',
password : 'password',
database : 'database'
});
connection.connect();
var obj = {};
obj.one = 'http://blablabla'; //big big big json
obj.two = 'http://blablabla'; //big big big json
obj.three = 'http://blablabla'; //big big big json
function doparse(url){
//Тут получаем данные json по url и преобразуем их в объект
body = JSON.parse(body);
var events = body['events'];
async.each(events, function(event, callback){
var markets = event['markets'];
markets.forEach(function(market){
var runners = market['runners'];
runners.forEach(function(runner){
prices = runner['prices'];
prices.forEach(function(price){
var inserted_data = [...........]; //вставляемые данные
connection.query('INSERT blablabla', inserted_data, function(err, result){
//Обработка ошибок и просто console.log
});
});
});
});
});
}
async.each(obj, function(url, callback){
doparse(url);
});