<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Harvesting ArcGIS REST endpoints
Config
Sensitive information and related configuration, such as CKAN URLs and credentials, are stored in a separate file.
To use this workbook on your own CKAN instance, write or append the following contents into a file secret.py in the same directory as this workbook
Step1:  Setup
From the config, we'll grab the base URL and folders to be harvested.
Step2:  Harvest
Hammertime? Hammertime.
<ASSISTANT_TASK:>
Python Code:
import ckanapi 
from datetime import datetime
import json
import os
import requests
from slugify import slugify
from harvest_helpers import *
from secret import CKAN, ARCGIS
print("The ARCGIS REST service endpoint QC lives at {0}".format(ARCGIS["SLIPFUTURE"]["url"]))
print("The catalogue \"ca\" lives at {0}".format(CKAN["ca"]["url"]))
print("The catalogue \"cb\" lives at {0}".format(CKAN["cb"]["url"]))
print("The catalogue \"ct\" lives at {0}".format(CKAN["ct"]["url"]))
## enable one of:
#ckan = ckanapi.RemoteCKAN(CKAN["ct"]["url"], apikey=CKAN["ct"]["key"])
ckan = ckanapi.RemoteCKAN(CKAN["ca"]["url"], apikey=CKAN["ca"]["key"])
#ckan = ckanapi.RemoteCKAN(CKAN["cb"]["url"], apikey=CKAN["cb"]["key"])
print("Using CKAN {0}".format(ckan.address))
Explanation: Harvesting ArcGIS REST endpoints
Config
Sensitive information and related configuration, such as CKAN URLs and credentials, are stored in a separate file.
To use this workbook on your own CKAN instance, write or append the following contents into a file secret.py in the same directory as this workbook:
ARCGIS = {
  "SLIPFUTURE" : {
    "url": "http://services.slip.wa.gov.au/arcgis/rest/services",
    "folders": ["QC", ...]
 },
 ...
}
Insert your ArcGIS REST endpoints and service names.
End of explanation
baseurl = ARCGIS["SLIPFUTURE"]["url"]
folders = ARCGIS["SLIPFUTURE"]["folders"]
print("The base URL {0} contains folders {1}\n".format(baseurl, str(folders)))
services = get_arc_services(baseurl, folders[0])
print("The services in folder {0} are:\n{1}\n".format(str(folders), str(services)))
service_url = services[0]
mrwa = get_arc_servicedict(services[0])
print("Service {0}\ncontains layers and extensions:\n{1}".format(services[0], mrwa))
Explanation: Setup
From the config, we'll grab the base URL and folders to be harvested.
End of explanation
harvest_arcgis_service(services[0],
                       ckan,
                       owner_org_id = ckan.action.organization_show(id="mrwa")["id"],
                       author = "Main Roads Western Australia",
                       author_email = "irissupport@mainroads.wa.gov.au",
                       debug=False)
a = ["SLIP Classic", "Harvested"]
a.append("test")
a
Explanation: Harvest
Hammertime? Hammertime.
End of explanation
<END_TASK>