Add temp dir to variable used by osmosis startup script to prevent crash on run

This commit is contained in:
Mike C 2016-01-12 19:00:16 -05:00
parent b6b11a9318
commit 258bc7c8c6

View file

@ -15,6 +15,7 @@
import subprocess, sys, os, pprint, datetime, argparse, time import subprocess, sys, os, pprint, datetime, argparse, time
base_path = os.path.dirname(os.path.realpath(__file__)) base_path = os.path.dirname(os.path.realpath(__file__))
env = os.environ.copy()
FNULL = open(os.devnull, 'w') FNULL = open(os.devnull, 'w')
@ -65,13 +66,14 @@ if __name__ == '__main__':
subprocess.run([bunzip2_cmd, os.path.join(dirpath, file)]) subprocess.run([bunzip2_cmd, os.path.join(dirpath, file)])
print('Processing maps using osmosis') print('Processing maps using osmosis')
env['JAVACMD_OPTIONS'] = '-Djava.io.tmpdir=' + os.path.join(base_path, 'tmp') # Setup java temp dir to something a bit more sane (tmpfs /tmp for the loss)
files_to_process = [] files_to_process = []
for dirpath, dirnames, filenames in os.walk('dl'): for dirpath, dirnames, filenames in os.walk('dl'):
for file in filenames: for file in filenames:
print(' Found map: ', end='') print(' Found map: ', end='')
print(os.path.join(dirpath, file)) print(os.path.join(dirpath, file))
files_to_process.append(os.path.join(dirpath, file)) files_to_process.append(os.path.join(dirpath, file))
osmosis_cmd = [os.path.join(base_path, 'bin', 'osmosis', 'bin', 'osmosis'), '-Djava.io.tmpdir=' + os.path.join(base_path, 'tmp')] osmosis_cmd = [os.path.join(base_path, 'bin', 'osmosis', 'bin', 'osmosis')]
for file in files_to_process: for file in files_to_process:
if file.endswith('osm'): if file.endswith('osm'):
osmosis_cmd.extend(['--rx', 'file=' + file]) osmosis_cmd.extend(['--rx', 'file=' + file])
@ -80,5 +82,6 @@ if __name__ == '__main__':
for x in range(0, len(files_to_process) - 1): for x in range(0, len(files_to_process) - 1):
osmosis_cmd.append('--merge') osmosis_cmd.append('--merge')
osmosis_cmd.extend(['--mapfile-writer', 'file=output.map', 'type=hd']) osmosis_cmd.extend(['--mapfile-writer', 'file=output.map', 'type=hd'])
subprocess.run(osmosis_cmd) cmd = subprocess.Popen(osmosis_cmd, env=env)
cmd.wait()