osmosis
osmosis copied to clipboard
osmosis `stdout` empty on successful run. info written to `stderr`
I'm trying to use osmosis
in a python-script and I want to log the command output in my console.
This is the function I'm using to run osmosis
:
def run_subprocess(command):
command_name = command.split()[0] # Get the name of the command
print(f"Running \033[1m{command_name}\033[0m with command:\n{command}\n")
process = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
)
output, error = process.communicate()
if output:
print(f"\033[1m{command_name}\033[0m output:\n", output.decode())
if error:
print(f"\033[1m{command_name}\033[0m Error:\n", error.decode())
The command I'm inputting is:
osmosis --read-pbf /home/reneas/Dokumente/OSM/Alpentour/map_alpentour.pbf
--node-key-value keyValueList=tourism.camp_pitch,tourism.camp_site,tourism.caravan_site
--write-xml /home/reneas/Dokumente/OSM/Alpentour/osm_raw/Camping.osm
normally communicate() returns a tuple (stdout, stderr)
as is written in the description of the function but in my case even when I run the command successfully my stdout
is empty and the stderr
isn't.
If I do print(process.communicate())
I get:
(b'', b'Feb. 22, 2024 1:00:08 NACHM. org.openstreetmap.osmosis.core.Osmosis run\n
INFORMATION: Osmosis Version 0.48.3\n
Feb. 22, 2024 1:00:08 NACHM. org.openstreetmap.osmosis.core.Osmosis run\n
INFORMATION: Preparing pipeline.\n
Feb. 22, 2024 1:00:08 NACHM. org.openstreetmap.osmosis.core.Osmosis run\n
INFORMATION: Launching pipeline execution.\n
Feb. 22, 2024 1:00:08 NACHM. org.openstreetmap.osmosis.core.Osmosis run\n
INFORMATION: Pipeline executing, waiting for completion.\n
Feb. 22, 2024 1:00:12 NACHM. org.openstreetmap.osmosis.core.Osmosis run\n
INFORMATION: Pipeline complete.\n
Feb. 22, 2024 1:00:12 NACHM. org.openstreetmap.osmosis.core.Osmosis run\n
INFORMATION: Total execution time: 4097 milliseconds.\n')
Therefore my commandline output reads:
osmosis Error:
<rest of information herer>
is this a osmosis
related issue?