roam-qgis / Roam

Simple data collection built using QGIS.
http://roam-docs.readthedocs.org/en/latest/
GNU General Public License v2.0
166 stars 60 forks source link

[ConfigManager] Make OSGeo4W QGIS installation aware #473

Open jonnyforestGIS opened 3 years ago

jonnyforestGIS commented 3 years ago

Hi @NathanW2 , ROAM is not OSGeo4W QGIS installation aware. So I search in the code and I found in here this section inside of utils.py of configmanager.

https://github.com/roam-qgis/Roam/blob/d5f7e62a221046d3b0cb2b2b81fb8c84debf41d4/src/configmanager/utils.py#L22

https://github.com/roam-qgis/Roam/blob/d5f7e62a221046d3b0cb2b2b81fb8c84debf41d4/src/configmanager/utils.py#L28

I start to do a PR about this and perhaps with a separate def osgeo path, something like this:


def qgis_path(base_path, name):
    return os.path.join(base_path, "QGIS 3.10", "bin", name)

def osgeo_path(base_path, name):
    return os.path.join(base_path, "bin", name)

def find_qgis():
    triedpaths = []
    for installpath in [qgis_path(os.environ['ProgramFiles'],"qgis-bin.exe"),
                        qgis_path(os.environ['ProgramFiles(x86)'], "qgis-bin.exe"),
                        qgis_path(os.environ['ProgramFiles'], "qgis-ltr-bin.exe"),
                        qgis_path(os.environ['ProgramFiles(x86)'], "qgis-ltr-bin.exe"),
                        osgeo_path(os.environ['OSGeo4W64'],"qgis-ltr-bin.exe"),
                        osgeo_path(os.environ['OSGeo4W'],"qgis-ltr-bin.exe"),
                        ]:

Let me know if is more complex than this if not I can submit a PR with these changes.