Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osmosis stdout empty on successful run. info written to stderr #146

Open
reneas opened this issue Feb 22, 2024 · 0 comments
Open

osmosis stdout empty on successful run. info written to stderr #146

reneas opened this issue Feb 22, 2024 · 0 comments

Comments

@reneas
Copy link

reneas commented Feb 22, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant