Skip to content

Commit

Permalink
use entry_points
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Aug 12, 2017
1 parent 3ed3a5d commit dea2729
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
'PyYAML'
]

scripts = [
'bin/wms-downloader'
console_scripts = [
'wms-downloader=wms_downloader.download:main'
]

setup(
Expand All @@ -33,5 +33,7 @@
packages=find_packages(),
install_requires=requirements,
classifiers=[],
scripts=scripts,
entry_points={
'console_scripts': console_scripts
}
)
16 changes: 8 additions & 8 deletions wms_downloader/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

def main():
parser = argparse.ArgumentParser(usage='Downloads large geo TIFF files from a WMS service.')
parser.add_argument('config', nargs='?', default='config.yml', help='config file [default: config.yml]')
parser.add_argument('config', help='config file')
args = parser.parse_args()

with open(args.config) as f:
Expand All @@ -54,15 +54,14 @@ def download_images(config):

for west in west_range:
for south in south_range:
filename = '%(directory)s/%(west)s_%(south)s_%(resolution)s.gdal.tif' % {
'directory': config['directory'],
filename = os.path.join(config['directory'], '%(west)s_%(south)s_%(resolution)s.gdal.tif' % {
'west': west,
'south': south,
'resolution': config['resolution']
}
})

if not os.path.exists(filename + '.aux.xml'):
print(filename)
print('fetching %s' % filename)

xml_params = {
'west': west,
Expand All @@ -83,9 +82,10 @@ def download_images(config):


def create_vrt_file(config):
args = ['gdalbuildvrt', '-a_srs', config['projection'], '-overwrite', config['vrtfile']]
args += glob.glob('%s/*.gdal.tif' % config['directory'])
subprocess.check_call(args)
if not os.path.exists(config['vrtfile']):
args = ['gdalbuildvrt', '-a_srs', config['projection'], config['vrtfile']]
args += glob.glob('%s/*.gdal.tif' % config['directory'])
subprocess.check_call(args)


def arange(start, stop, step):
Expand Down

0 comments on commit dea2729

Please sign in to comment.