Script to add SIRENE to API
"""
from datetime import datetime
import os

from api_helpers import APIConnection

# =============================================================================
# Define how to connect to API
# =============================================================================
PROTOCOL = 'http://'
HOST = '51.15.221.77:5000'
PRINT = True
PRINT_CHAR_LIMIT = 10000

c = APIConnection(PROTOCOL, HOST, PRINT, PRINT_CHAR_LIMIT)

# =============================================================================
# Load parameters for pipeline
# =============================================================================

params = {
    "new_project": {
        "description":
        "Base SIRENE ({0})".format(datetime.now().isoformat()[:10]),
        "display_name": "SIRENE",
        "public": True
    },
    'file_path':
    '/home/m75380/Documents/eig/the-magical-csv-merge-machine/merge_machine/local_test_data/sirene/sirene_filtered.csv',
    'columns_to_index': {
# =============================================================================
# Check that we are selecting either by project_id or by display name
# =============================================================================
assert int(display_name is None) + int(project_id is None) == 1

# =============================================================================
# Define how to connect to API
# =============================================================================
conn_params = json.load(open(connection_config_path))
PROTOCOL = conn_params['PROTOCOL']
HOST = conn_params['HOST']
PRINT = conn_params['PRINT']
PRINT_CHAR_LIMIT = conn_params['PRINT_CHAR_LIMIT']

c = APIConnection(PROTOCOL, HOST, PRINT, PRINT_CHAR_LIMIT)

# =============================================================================
# Load logs
# =============================================================================
if os.path.isfile(logs_path):
    logs = json.load(open(logs_path))
else:
    logs = dict()

# =============================================================================
# Delete project with same display_name or project id
# =============================================================================
if display_name is not None:
    project_id = logs[display_name]