import os
import sys

from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

from optparse import make_option

from rldjango.apps.crm.bulkloader import bulkload

class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
#        make_option('--format', default='json', dest='format',
#            help='Specifies the output serialization format for fixtures.'),
# etc
    )
    help = 'Load in the given field to create leads from the database.'
    args = '[filename.csv ...]'

    def handle(self, *app_labels, **options):

        dataDir = os.path.join(os.path.dirname(settings.PROJECT_DIR), 'data')
        dataFile = os.path.join(dataDir, 'initial_data_1.csv')
        bulkload(dataFile)
#        except Exception, e:
#            if show_traceback:
#                raise
#            raise CommandError("Unable to serialize database: %s" % e)
