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

Using os-translator-ii-cli.py in automation #57

Open
Arawn-Davies opened this issue Nov 4, 2022 · 1 comment
Open

Using os-translator-ii-cli.py in automation #57

Arawn-Davies opened this issue Nov 4, 2022 · 1 comment

Comments

@Arawn-Davies
Copy link

Hello, I'm trying to automate the import of OS MasterMap Typography layers in PostGIS without using the QGIS UI directly.
I have OSGeo4W, Python, QGIS and all required tools installed, but when running
python os-translator-ii-cli.py --osmm-data-type "OS Mastermap Topography (v9)" --input-path <gz files> --host <hostname> --database <db> --user <user> --schema <schema>

it gives the error

H:\ostranslator-ii\OSTranslatorII>python os-translator-ii-cli.py
Traceback (most recent call last):
  File "H:\ostranslator-ii\OSTranslatorII\os-translator-ii-cli.py", line 25, in <module>
    from .import_manager import ImportManager
ImportError: attempted relative import with no known parent package

H:\ostranslator-ii\OSTranslatorII>

Now, as a workaround I've removed the prefixing dot from each import, as there is no parent package. That works, but I'm wondering if there is a less-hacky method to running the CLI script directly from a command line window.

My python env variables are:

PYTHONHOME=C:\PROGRA~1\QGIS31~1.5\apps\Python39
PYTHONPATH=C:\Program Files\QGIS 3.16.5\apps\qgis-ltr\python;C:\Users\ardavies\Desktop\ostranslator-ii\

as QGIS's python modules needed to be in PYTHONPATH to import the qgis QT and other python modules.

@rjwats
Copy link

rjwats commented Jan 9, 2023

It looks like running this from the module might be what you need. Assuming the module is somewhere on the python path:

python -m OSTranslatorII.os-translator-ii-cli

image

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

2 participants