Saturday, 5 December 2015

pyqgis - Check whether QGIS3 was started by qgis.bat or qgis.exe


Is it possible to check whether QGIS3 was started by executing qgis.bat or qgis.exe directly?


I want to do some checks in the qgis.bat before qgis starts and make sure that qgis is always started by calling the qgis.bat.


Edit1:


One idea is to set an environment variable in the qgis bat and check in the startup.py if this environmental variable is found:


bat-file:


set batchfilestart="YES"

python part



import os
try:
env_value = os.environ.get("batchfilestart")
if env_value !="YES":
print ("QGIS not started by calling the bat file")
print (env_value)
else:
print("QGIS started by calling the bat file")
print (env_value)
except KeyError:

print("Not exist environment value for %s" % "key_maybe_not_exist")

Is there a better way to make sure I can always run some checks before QGIS starts?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...