- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
for row in rows:
service = row[0].split('_')
if row[0].find('lk_s_du') > -1:
loki_cursor.execute("""select tariff_id from inet_inetsessionlog where id = %s;""", (service[-1],))
tariff_id = str(loki_cursor.fetchall()[0][0])
else:
if row[1] == 'inet_dynamic_ip':
cursor.execute('select tariff_plan from inet_dynamic_ip_services where id = %s', (service[-1],))
tariff = str(cursor.fetchall()[0][0])
elif row[1] == 'inet_fixed_ip':
if row[0].split('_')[-1].find('.') == -1:
cursor.execute('select tariff_plan from inet_fixed_ip_services where id = %s', (service[-1],))
else:
cursor.execute('select tariff_plan from inet_fixed_ip_services where id = %s', (service[-2],))
tariff = str(cursor.fetchall()[0][0])
loki_cursor.execute("select tariff_ptr_id from inet_inettariff where cherry_id = %s", (tariff,))
tariff_id = str(loki_cursor.fetchall()[0][0])
loki_cursor.execute("select * from inet_inettariff where tariff_ptr_id = %s", (tariff_id,))
tariff = loki_cursor.fetchall()[0]
tariff = dict(zip(('tariff_ptr_id', 'price_per_unit', 'is_dynamic', 'cherry_id', 'ie_price_first', 'ie_price_second', 'ie_price_switch', 'oe_price_first', 'oe_price_second', 'oe_price_switch', 'il_price_first', 'il_price_second', 'il_price_switch', 'ol_price_first', 'ol_price_second', 'ol_price_switch'), tariff))
if login in row[0]:
print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').encode('utf-8')
else:
print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').replace(date_start,u'Суммарно').encode('utf-8')
else:
price = str(row[7]).replace('.',',')
if login in row[0]:
print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').encode('utf-8')
else:
print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').replace(date_start,u'Суммарно').encode('utf-8')