Skip to content

Commit

Permalink
fixed Census tool for symbology; fixed makeaddin.py
Browse files Browse the repository at this point in the history
So, makeaddin.py fails if README.txt doesn’t exist. That’s really
stupid, so I modified the script to not include the README file.
  • Loading branch information
johnjreiser committed Dec 4, 2013
1 parent 5e80798 commit 39ed448
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CensusAPIs/Install/census_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[api.census.gov]
key=insert_your_key_here
Binary file added CensusAPIs/Install/census_geometry.lyr
Binary file not shown.
13 changes: 8 additions & 5 deletions CensusAPIs/Install/query_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
## Python Add-in Tools:
## http://resources.arcgis.com/en/help/main/10.2/index.html#/Tool/014p00000027000000/

## change this key to your Census API key.
## request an API key here: http://www.census.gov/developers/tos/key_request.html
censusAPIkey = ''

import arcpy, pythonaddins
import urllib2, json
import urllib2, json, os
import ConfigParser

config = ConfigParser.ConfigParser()
config.read(os.path.join(os.path.dirname(__file__), r'census_config.txt'))
censusAPIkey = config.get('api.census.gov', 'key')

class QueryCensus2010(object):
def __init__(self):
Expand Down Expand Up @@ -77,6 +78,8 @@ def onMouseUpMap(self, x, y, button, shift):
### TODO: dynamically add fields to store the API information (self.Census['tables'])
### so that everything can be in an ArcGIS Feature Class element
censuslyr = arcpy.mapping.ListLayers(df, "census_geometry")[0]
symbollyr = arcpy.mapping.Layer( os.path.join(os.path.dirname(__file__), r'census_geometry.lyr') )
arcpy.mapping.UpdateLayer(df, censuslyr, symbollyr, True)
# if already exists, remove features from the Census Geometry layer
else:
censuslyr = arcpy.mapping.ListLayers(df, "census_geometry")[0]
Expand Down
2 changes: 1 addition & 1 deletion CensusAPIs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Python-based Add-in for ArcGIS Desktop. Upon clicking a location within the Unit
You do not need to download any Census GIS data for this tool to work. It will request the geometry and attribute data for you! Works with nearly any projection in ArcMap.

##Install
Request a [Census API key](http://www.census.gov/developers/tos/key_request.html). Open the `Install/query_census.py` file and paste your API key into the `CensusAPIkey` variable.
Request a [Census API key](http://www.census.gov/developers/tos/key_request.html). Open the `Install/census_config.txt` file and paste in your API key, replacing `insert_your_key_here`.

Double-click `makeaddin.py` to create the `.esriaddin` file. Double-click the `.esriaddin` file to install the add-in in ArcMap.

Expand Down
2 changes: 1 addition & 1 deletion CensusAPIs/makeaddin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def looks_like_a_backup(filename):
return bool(BACKUP_FILE_PATTERN.match(filename))

with zipfile.ZipFile(out_zip_name, 'w', zipfile.ZIP_DEFLATED) as zip_file:
for filename in ('config.xml', 'README.txt', 'makeaddin.py'):
for filename in ('config.xml', 'makeaddin.py'):
zip_file.write(os.path.join(current_path, filename), filename)
dirs_to_add = ['Images', 'Install']
for directory in dirs_to_add:
Expand Down
3 changes: 3 additions & 0 deletions LaunchWebMaps/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Images/* : all UI images for the project (icons, images for buttons,
Install/* : The Python project used for the implementation of the
AddIn. The specific python script to be used as the root
module is specified in config.xml.


*NOTE: DO NOT REMOVE THIS FILE OR makeaddin.py WILL NO LONGER WORK.
2 changes: 1 addition & 1 deletion LaunchWebMaps/makeaddin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def looks_like_a_backup(filename):
return bool(BACKUP_FILE_PATTERN.match(filename))

with zipfile.ZipFile(out_zip_name, 'w', zipfile.ZIP_DEFLATED) as zip_file:
for filename in ('config.xml', 'README.txt', 'makeaddin.py'):
for filename in ('config.xml', 'makeaddin.py'):
zip_file.write(os.path.join(current_path, filename), filename)
dirs_to_add = ['Images', 'Install']
for directory in dirs_to_add:
Expand Down
2 changes: 1 addition & 1 deletion NJServices/makeaddin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def looks_like_a_backup(filename):
return bool(BACKUP_FILE_PATTERN.match(filename))

with zipfile.ZipFile(out_zip_name, 'w', zipfile.ZIP_DEFLATED) as zip_file:
for filename in ('config.xml', 'README.txt', 'makeaddin.py'):
for filename in ('config.xml', 'makeaddin.py'):
zip_file.write(os.path.join(current_path, filename), filename)
dirs_to_add = ['Images', 'Install']
for directory in dirs_to_add:
Expand Down

0 comments on commit 39ed448

Please sign in to comment.