Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added URL Correction Code and Skipping Existing Files #13

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions DataServicePillager.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_all_the_layers(service_endpoint, tokenstring):
if service_endpoint.endswith(folder):
service_url = service_endpoint + '/' + sname + '/' + servicetype

service_layers_to_walk.append(service_url)
service_layers_to_walk.append(urllib.parse.quote(service_url, safe='/:?=&'))

if len(service_layers_to_walk) == 0:
# no services or folders
Expand Down Expand Up @@ -629,6 +629,15 @@ def main():

info_filename = service_name_cl + "_info.txt"
info_file = os.path.join(output_folder, info_filename)

if output_type == "Folder":
final_fc = os.path.join(output_workspace, service_name_cl + ".shp")
else:
final_fc = os.path.join(output_workspace, service_name_cl)

if arcpy.Exists(final_fc):
output_msg("Skipping download, final output already exists: '{0}'".format(final_fc))
continue # Skip to the next layer if the final output exists

# write out the service info for reference
with open(info_file, 'w') as i_file:
Expand Down Expand Up @@ -732,11 +741,6 @@ def main():
raise ValueError("Aaar, plunderin' failed, feature OIDs is None")

# download complete, create a final output
if output_type == "Folder":
final_fc = os.path.join(output_workspace, service_name_cl + ".shp")
else:
final_fc = os.path.join(output_workspace, service_name_cl)

output_msg("Stashin' all the booty in '{0}'".format(final_fc))

#combine all the data
Expand Down