fail_file = file_csv + ".fail"
    max_connection = int(args.worker)

if args.fail:
    file_csv = fail_file
    fail_file = fail_file + ".bis"
    batch_size = 1
    max_connection = 1
    


semaphore = threading.BoundedSemaphore(int(max_connection))
max_thread_semaphore = threading.BoundedSemaphore(int(max_connection) * 10)

file_ref = open(file_csv, 'r')
reader = UnicodeReader(file_ref, delimiter=';')
print 'open', file_csv


connection = conf_lib.get_server_connection(config_file)
object_registry = connection.get_model(model)
ir_model_registry = connection.get_model('ir.model.data')

header = reader.next()
header_len = 0

for head in header:
    if head:
        header_len += 1
    else:
        break
# -*- coding: utf-8 -*-
from lib.csv_reader import UnicodeReader
from lib import conf_lib
import sys
from lib.etl_helper import *

config_file = sys.argv[1]
file_csv = conf_lib.get_file(config_file)

file_ref = open(file_csv, 'r')
reader = UnicodeReader(file_ref, delimiter=';')

head = reader.next()


basic_header = ['id', 'name']
PARTNER_PREFIX = "DEMO_PRODUCT_RES_PARTNER."
partner_header = ['id', 'name', 'is_company', 'supplier', 'customer']
partner_data = set()

SELLER_PREFIX = 'DEMO_PRODUCT_SUPPLIERINFO.'
seller_data = []
seller_header = ['id', 'name/id', 'product_tmpl_id/id', 'product_code']

TEMPLATE_PREFIX =  "DEMO_PRODUCT."
product_template_header = ['id', 'barcode', 'taxes_id', 'standard_price', 'lst_price', 'name', 'description']
product_template_line = []

default_code = set([])
i = 2
for line in reader: