(path, output=subprocess.DEVNULL, error=subprocess.DEVNULL)
| 7 | |
| 8 | |
| 9 | def build_osmtools(path, output=subprocess.DEVNULL, error=subprocess.DEVNULL): |
| 10 | src = { |
| 11 | settings.OSM_TOOL_UPDATE: "osmupdate.c", |
| 12 | settings.OSM_TOOL_FILTER: "osmfilter.c", |
| 13 | settings.OSM_TOOL_CONVERT: "osmconvert.c", |
| 14 | } |
| 15 | ld_flags = ("-lz",) |
| 16 | cc = [] |
| 17 | result = {} |
| 18 | for executable, src in src.items(): |
| 19 | out = os.path.join(settings.OSM_TOOLS_PATH, executable) |
| 20 | op = [ |
| 21 | settings.OSM_TOOLS_CC, |
| 22 | *settings.OSM_TOOLS_CC_FLAGS, |
| 23 | "-o", |
| 24 | out, |
| 25 | os.path.join(path, src), |
| 26 | *ld_flags, |
| 27 | ] |
| 28 | s = subprocess.Popen(op, stdout=output, stderr=error) |
| 29 | cc.append(s) |
| 30 | result[executable] = out |
| 31 | |
| 32 | messages = [] |
| 33 | for c in cc: |
| 34 | if c.wait() != os.EX_OK: |
| 35 | messages.append(f"The launch of {' '.join(c.args)} failed.") |
| 36 | if messages: |
| 37 | raise BadExitStatusError("\n".join(messages)) |
| 38 | |
| 39 | return result |
| 40 | |
| 41 | |
| 42 | def osmconvert( |
no test coverage detected