# Path: eff_site/eff/models.py



import sys
import os
from datetime import datetime
from eff_site.eff.models import ExternalSource, Client
from dotproject import fetch_all

path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
sys.path.insert(1, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'eff_site.settings'



if __name__ == '__main__':

    date_format = "%Y%m%d%H%M"
    args = sys.argv[1:]

    if len(args) != 4:
        print ("Usage: $ dp2eff.py <client-name> <source-name>"
               " <from-date> <to-date>")
        print "date format: %s" % date_format
        print "example: 201008190000"
        sys.exit(0)

    client_name, source_name = args[0:2]
    from_date = datetime.strptime(args[2], date_format)
    to_date = datetime.strptime(args[3], date_format)

    try:
        source = ExternalSource.objects.get(name=source_name)
    except ExternalSource.DoesNotExist:
        print 'Source with name: %s does not exist' % source_name
        sys.exit(1)

    try:

# Path: eff_site/eff/models.py



# Path: eff_site/scripts/dp2eff.py
import sys
import os
from datetime import datetime
from eff_site.eff.models import ExternalSource, Client
from dotproject import fetch_all


path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
sys.path.insert(1, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'eff_site.settings'



if __name__ == '__main__':

    date_format = "%Y%m%d%H%M"
    args = sys.argv[1:]

    if len(args) != 4:
        print ("Usage: $ dp2eff.py <client-name> <source-name>"
               " <from-date> <to-date>")
        print "date format: %s" % date_format
        print "example: 201008190000"
        sys.exit(0)

    client_name, source_name = args[0:2]
    from_date = datetime.strptime(args[2], date_format)
    to_date = datetime.strptime(args[3], date_format)

    try:
        source = ExternalSource.objects.get(name=source_name)
    except ExternalSource.DoesNotExist:
        print 'Source with name: %s does not exist' % source_name
        sys.exit(1)

    try:

        client = Client.objects.get(name=client_name)