Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-13 Thread Etienne Trimaille
You might find something useful in this new repository :
https://github.com/haubourg/custom-osgeo4w-qgis/ ?

Le lun. 12 juil. 2021 à 10:54, Alexandre Neto  a
écrit :

> Hi Bo,
>
> This is some old stuff we wrote at Boundless, I believe it still applies
> for QGIS today.
>
>
> https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators
>
> Both initialisation scripts and global setting file can help you with what
> you want to achieve.
>
> (I should make sure this information is available on docs.qgis.org, but I
> never find the time to do it...)
>
> Best regards,
>
> Alexandre Neto
> User Support
> www.qcooperative.net
>
> A segunda, 12/07/2021, 08:34, Bo Victor Thomsen <
> bo.victor.thom...@gmail.com> escreveu:
>
>> Hi Thomas -
>>
>> Your suggestion is actually pretty close to the solution I made -
>>
>>- Standard installation of QGIS with *standard* .msi package.
>>- After the QGIS installation and before QGIS is started the user do
>>a one-time run a Python script from et central network drive -  using the
>>Python interpreter installed together with QGIS  which:
>>- Unzip a complete profile  with specific plugins and customized
>>   parameters from a central network based repository. This profile 
>> replaces
>>   the standard "default" profile.
>>   - Search/replace a couple of "tokenized" values in QGIS.ini with
>>   actual values based on username
>>
>> The profile and tokenized QGIS.ini is prepared by the GIS administrator
>>
>> The Python script is packaged in a .cmd file which is started by the user.
>>
>> Not a perfect solution, but doable:
>>
>>- The It department is happy: No work doing specialized installations
>>- The GIS administrator is happy. It's a one-time piece of work for
>>each QGIS version to  prepare the profile and tokenize the QGIS.ini
>>- The user is - somewhat - happy. To finish the installation is
>>simply to double-click once on a file placed in a "highly visible" 
>> location.
>>- Any subsequent mistakes made by the user (Installation of dodgy
>>plugins, strange changes in setups ) is easily repaired by running the
>>Python script again.
>>
>>
>> Med venlig hilsen / Kind regards
>>
>> Bo Victor Thomsen
>>
>> Den 12-07-2021 kl. 03:14 skrev Thomas Gratier:
>>
>> Hi,
>>
>> I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is not
>> portable as would only work on Windows
>>
>> You can always try generate the QGIS.ini file using a templating system
>>
>> File QGIS.ini.j2 with following content
>>
>>
>> Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>
>> Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>
>>
>> File generate_ini.py with following content
>>
>> import os
>> import jinja2
>>
>> templateLoader = jinja2.FileSystemLoader(searchpath="./")
>> templateEnv = jinja2.Environment(loader=templateLoader)
>> TEMPLATE_FILE = "QGIS.ini.j2"
>> template = templateEnv.get_template(TEMPLATE_FILE)
>> mydict = {
>> "APPDATA": os.environ.get("APPDATA")
>> }
>> outputText = template.render(**mydict)
>> with open('QGIS.ini', 'w') as outputfile:
>> outputfile.write(outputText)
>>
>> Then, to write your QGIS.ini file, do
>>
>>
>> python3 generate_ini.py
>>
>>
>> The possible deal breakers with this approach are:
>> - you depend from jinja2, a third party Python library,
>> - you can't later reuse the mechanism if for instance QGIS changes the
>> QGIS.ini file later on
>>
>>
>> Regards
>>
>> Thomas
>>
>>
>> Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen <
>> bo.victor.thom...@gmail.com> a écrit :
>>
>>> To the list -
>>>
>>> Is there a method to use OS (Linux, Windows...) environment variables in
>>> the QGIS.ini setup file ?
>>>
>>> I had a number of customers asking for a method to "generalize"
>>> QGIS.ini, so it doesn't contain any "user" specific file and directory
>>> references, i.e
>>>
>>> (From qgis.ini)
>>>
>>> Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor
>>> Thomsen\\AppData\\Roaming*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>> Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor
>>> Thomsen\\AppData\\Roaming*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>>
>>> could be:
>>>
>>> Configuration\MODELS_FOLDER=*%APPDATA%*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>> Configuration\SCRIPTS_FOLDERS=*%APPDATA%*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>>
>>> or likewise.
>>>
>>> The ultimate reason is to have a method to distribute a "standard" setup
>>> for QGIS, complete with plugins and specialized setup parameters. This can
>>> be done by making a standard QGIS installation (which the IT departments
>>> love, especially with the new .msi package) and afterwards replace the
>>> "default" profile directory with at  directory specific for the
>>> organisation. However, the process of making the 

Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-13 Thread Alexandre Neto
Hi Thomas,

I will check with others and let you know.

Best regards,

Alexandre Neto

A terça, 13/07/2021, 07:08, Thomas B  escreveu:

> Hi Alexandre,
>
> >>This is some old stuff we wrote at Boundless, I believe it still
> applies for QGIS today.
> >>
> https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators
> >>Both initialisation scripts and global setting file can help you
> with what you want to achieve.
>
> The initialisation scripts could be useful. But they don't seem to be
> merged into the QGIS repository yet.
>
> regards,
> Thomas
>
>
> Am Mo., 12. Juli 2021 um 10:54 Uhr schrieb Alexandre Neto <
> senhor.n...@gmail.com>:
>
>> Hi Bo,
>>
>> This is some old stuff we wrote at Boundless, I believe it still applies
>> for QGIS today.
>>
>>
>> https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators
>>
>> Both initialisation scripts and global setting file can help you with
>> what you want to achieve.
>>
>> (I should make sure this information is available on docs.qgis.org, but
>> I never find the time to do it...)
>>
>> Best regards,
>>
>> Alexandre Neto
>> User Support
>> www.qcooperative.net
>>
>> A segunda, 12/07/2021, 08:34, Bo Victor Thomsen <
>> bo.victor.thom...@gmail.com> escreveu:
>>
>>> Hi Thomas -
>>>
>>> Your suggestion is actually pretty close to the solution I made -
>>>
>>>- Standard installation of QGIS with *standard* .msi package.
>>>- After the QGIS installation and before QGIS is started the user do
>>>a one-time run a Python script from et central network drive -  using the
>>>Python interpreter installed together with QGIS  which:
>>>- Unzip a complete profile  with specific plugins and customized
>>>   parameters from a central network based repository. This profile 
>>> replaces
>>>   the standard "default" profile.
>>>   - Search/replace a couple of "tokenized" values in QGIS.ini with
>>>   actual values based on username
>>>
>>> The profile and tokenized QGIS.ini is prepared by the GIS administrator
>>>
>>> The Python script is packaged in a .cmd file which is started by the
>>> user.
>>>
>>> Not a perfect solution, but doable:
>>>
>>>- The It department is happy: No work doing specialized installations
>>>- The GIS administrator is happy. It's a one-time piece of work for
>>>each QGIS version to  prepare the profile and tokenize the QGIS.ini
>>>- The user is - somewhat - happy. To finish the installation is
>>>simply to double-click once on a file placed in a "highly visible" 
>>> location.
>>>- Any subsequent mistakes made by the user (Installation of dodgy
>>>plugins, strange changes in setups ) is easily repaired by running 
>>> the
>>>Python script again.
>>>
>>>
>>> Med venlig hilsen / Kind regards
>>>
>>> Bo Victor Thomsen
>>>
>>> Den 12-07-2021 kl. 03:14 skrev Thomas Gratier:
>>>
>>> Hi,
>>>
>>> I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is not
>>> portable as would only work on Windows
>>>
>>> You can always try generate the QGIS.ini file using a templating system
>>>
>>> File QGIS.ini.j2 with following content
>>>
>>>
>>> Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>>
>>> Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>>
>>>
>>> File generate_ini.py with following content
>>>
>>> import os
>>> import jinja2
>>>
>>> templateLoader = jinja2.FileSystemLoader(searchpath="./")
>>> templateEnv = jinja2.Environment(loader=templateLoader)
>>> TEMPLATE_FILE = "QGIS.ini.j2"
>>> template = templateEnv.get_template(TEMPLATE_FILE)
>>> mydict = {
>>> "APPDATA": os.environ.get("APPDATA")
>>> }
>>> outputText = template.render(**mydict)
>>> with open('QGIS.ini', 'w') as outputfile:
>>> outputfile.write(outputText)
>>>
>>> Then, to write your QGIS.ini file, do
>>>
>>>
>>> python3 generate_ini.py
>>>
>>>
>>> The possible deal breakers with this approach are:
>>> - you depend from jinja2, a third party Python library,
>>> - you can't later reuse the mechanism if for instance QGIS changes the
>>> QGIS.ini file later on
>>>
>>>
>>> Regards
>>>
>>> Thomas
>>>
>>>
>>> Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen <
>>> bo.victor.thom...@gmail.com> a écrit :
>>>
 To the list -

 Is there a method to use OS (Linux, Windows...) environment variables
 in the QGIS.ini setup file ?

 I had a number of customers asking for a method to "generalize"
 QGIS.ini, so it doesn't contain any "user" specific file and directory
 references, i.e

 (From qgis.ini)

 Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor
 Thomsen\\AppData\\Roaming*
 \\QGIS\\QGIS3\\profiles\\default\\processing\\models
 Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor
 Thomsen\\AppData\\Roaming*
 \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts


Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-13 Thread Thomas B
 Hi Alexandre,

>>This is some old stuff we wrote at Boundless, I believe it still
applies for QGIS today.
>>
https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators
>>Both initialisation scripts and global setting file can help you with
what you want to achieve.

The initialisation scripts could be useful. But they don't seem to be
merged into the QGIS repository yet.

regards,
Thomas


Am Mo., 12. Juli 2021 um 10:54 Uhr schrieb Alexandre Neto <
senhor.n...@gmail.com>:

> Hi Bo,
>
> This is some old stuff we wrote at Boundless, I believe it still applies
> for QGIS today.
>
>
> https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators
>
> Both initialisation scripts and global setting file can help you with what
> you want to achieve.
>
> (I should make sure this information is available on docs.qgis.org, but I
> never find the time to do it...)
>
> Best regards,
>
> Alexandre Neto
> User Support
> www.qcooperative.net
>
> A segunda, 12/07/2021, 08:34, Bo Victor Thomsen <
> bo.victor.thom...@gmail.com> escreveu:
>
>> Hi Thomas -
>>
>> Your suggestion is actually pretty close to the solution I made -
>>
>>- Standard installation of QGIS with *standard* .msi package.
>>- After the QGIS installation and before QGIS is started the user do
>>a one-time run a Python script from et central network drive -  using the
>>Python interpreter installed together with QGIS  which:
>>- Unzip a complete profile  with specific plugins and customized
>>   parameters from a central network based repository. This profile 
>> replaces
>>   the standard "default" profile.
>>   - Search/replace a couple of "tokenized" values in QGIS.ini with
>>   actual values based on username
>>
>> The profile and tokenized QGIS.ini is prepared by the GIS administrator
>>
>> The Python script is packaged in a .cmd file which is started by the user.
>>
>> Not a perfect solution, but doable:
>>
>>- The It department is happy: No work doing specialized installations
>>- The GIS administrator is happy. It's a one-time piece of work for
>>each QGIS version to  prepare the profile and tokenize the QGIS.ini
>>- The user is - somewhat - happy. To finish the installation is
>>simply to double-click once on a file placed in a "highly visible" 
>> location.
>>- Any subsequent mistakes made by the user (Installation of dodgy
>>plugins, strange changes in setups ) is easily repaired by running the
>>Python script again.
>>
>>
>> Med venlig hilsen / Kind regards
>>
>> Bo Victor Thomsen
>>
>> Den 12-07-2021 kl. 03:14 skrev Thomas Gratier:
>>
>> Hi,
>>
>> I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is not
>> portable as would only work on Windows
>>
>> You can always try generate the QGIS.ini file using a templating system
>>
>> File QGIS.ini.j2 with following content
>>
>>
>> Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>
>> Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>
>>
>> File generate_ini.py with following content
>>
>> import os
>> import jinja2
>>
>> templateLoader = jinja2.FileSystemLoader(searchpath="./")
>> templateEnv = jinja2.Environment(loader=templateLoader)
>> TEMPLATE_FILE = "QGIS.ini.j2"
>> template = templateEnv.get_template(TEMPLATE_FILE)
>> mydict = {
>> "APPDATA": os.environ.get("APPDATA")
>> }
>> outputText = template.render(**mydict)
>> with open('QGIS.ini', 'w') as outputfile:
>> outputfile.write(outputText)
>>
>> Then, to write your QGIS.ini file, do
>>
>>
>> python3 generate_ini.py
>>
>>
>> The possible deal breakers with this approach are:
>> - you depend from jinja2, a third party Python library,
>> - you can't later reuse the mechanism if for instance QGIS changes the
>> QGIS.ini file later on
>>
>>
>> Regards
>>
>> Thomas
>>
>>
>> Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen <
>> bo.victor.thom...@gmail.com> a écrit :
>>
>>> To the list -
>>>
>>> Is there a method to use OS (Linux, Windows...) environment variables in
>>> the QGIS.ini setup file ?
>>>
>>> I had a number of customers asking for a method to "generalize"
>>> QGIS.ini, so it doesn't contain any "user" specific file and directory
>>> references, i.e
>>>
>>> (From qgis.ini)
>>>
>>> Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor
>>> Thomsen\\AppData\\Roaming*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>> Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor
>>> Thomsen\\AppData\\Roaming*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>>
>>> could be:
>>>
>>> Configuration\MODELS_FOLDER=*%APPDATA%*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
>>> Configuration\SCRIPTS_FOLDERS=*%APPDATA%*
>>> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>>
>>> or likewise.
>>>
>>> The ultimate reason is to have a method to distribute a 

Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-12 Thread Bo Victor Thomsen

Hi Alexandre -

Thanks for the heads-up regarding initialisation scripts and global 
settings file.


Med venlig hilsen / Kind regards

Bo Victor Thomsen

Den 12-07-2021 kl. 10:54 skrev Alexandre Neto:

Hi Bo,

This is some old stuff we wrote at Boundless, I believe it still 
applies for QGIS today.


https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators 



Both initialisation scripts and global setting file can help you with 
what you want to achieve.


(I should make sure this information is available on docs.qgis.org 
, but I never find the time to do it...)


Best regards,

Alexandre Neto
User Support
www.qcooperative.net 

A segunda, 12/07/2021, 08:34, Bo Victor Thomsen 
mailto:bo.victor.thom...@gmail.com>> 
escreveu:


Hi Thomas -

Your suggestion is actually pretty close to the solution I made -

  * Standard installation of QGIS with /standard/ .msi package.
  * After the QGIS installation and before QGIS is started the
user do a one-time run a Python script from et central network
drive -  using the Python interpreter installed together with
QGIS  which:
  o Unzip a complete profile  with specific plugins and
customized parameters from a central network based
repository. This profile replaces the standard "default"
profile.
  o Search/replace a couple of "tokenized" values in QGIS.ini
with actual values based on username

The profile and tokenized QGIS.ini is prepared by the GIS
administrator

The Python script is packaged in a .cmd file which is started by
the user.

Not a perfect solution, but doable:

  * The It department is happy: No work doing specialized
installations
  * The GIS administrator is happy. It's a one-time piece of work
for each QGIS version to  prepare the profile and tokenize the
QGIS.ini
  * The user is - somewhat - happy. To finish the installation is
simply to double-click once on a file placed in a "highly
visible" location.
  * Any subsequent mistakes made by the user (Installation of
dodgy plugins, strange changes in setups ) is easily
repaired by running the Python script again.


Med venlig hilsen / Kind regards

Bo Victor Thomsen

Den 12-07-2021 kl. 03:14 skrev Thomas Gratier:

Hi,

I'm not aware QSettings provided by Qt can do it. Your %APPDATA%
is not portable as would only work on Windows

You can always try generate the QGIS.ini file using a templating
system

File QGIS.ini.j2 with following content


Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models

Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts


File generate_ini.py with following content

import os
import jinja2

templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "QGIS.ini.j2"
template = templateEnv.get_template(TEMPLATE_FILE)
mydict = {
    "APPDATA": os.environ.get("APPDATA")
}
outputText = template.render(**mydict)
with open('QGIS.ini', 'w') as outputfile:
    outputfile.write(outputText)

Then, to write your QGIS.ini file, do


python3 generate_ini.py


The possible deal breakers with this approach are:
- you depend from jinja2, a third party Python library,
- you can't later reuse the mechanism if for instance QGIS
changes the QGIS.ini file later on


Regards

Thomas


Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen
mailto:bo.victor.thom...@gmail.com>> a écrit :

To the list -

Is there a method to use OS (Linux, Windows...) environment
variables in the QGIS.ini setup file ?

I had a number of customers asking for a method to
"generalize" QGIS.ini, so it doesn't contain any "user"
specific file and directory references, i.e

(From qgis.ini)

Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor

Thomsen\\AppData\\Roaming*\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor

Thomsen\\AppData\\Roaming*\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts

could be:


Configuration\MODELS_FOLDER=*%APPDATA%*\\QGIS\\QGIS3\\profiles\\default\\processing\\models

Configuration\SCRIPTS_FOLDERS=*%APPDATA%*\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts

or likewise.

The ultimate reason is to have a method to distribute a
"standard" setup for QGIS, complete with plugins and
specialized setup parameters. This can be done 

Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-12 Thread Alexandre Neto
Hi Bo,

This is some old stuff we wrote at Boundless, I believe it still applies
for QGIS today.

https://boundless-desktop.readthedocs.io/en/latest/system_admins/index.html#for-system-administrators

Both initialisation scripts and global setting file can help you with what
you want to achieve.

(I should make sure this information is available on docs.qgis.org, but I
never find the time to do it...)

Best regards,

Alexandre Neto
User Support
www.qcooperative.net

A segunda, 12/07/2021, 08:34, Bo Victor Thomsen 
escreveu:

> Hi Thomas -
>
> Your suggestion is actually pretty close to the solution I made -
>
>- Standard installation of QGIS with *standard* .msi package.
>- After the QGIS installation and before QGIS is started the user do a
>one-time run a Python script from et central network drive -  using the
>Python interpreter installed together with QGIS  which:
>- Unzip a complete profile  with specific plugins and customized
>   parameters from a central network based repository. This profile 
> replaces
>   the standard "default" profile.
>   - Search/replace a couple of "tokenized" values in QGIS.ini with
>   actual values based on username
>
> The profile and tokenized QGIS.ini is prepared by the GIS administrator
>
> The Python script is packaged in a .cmd file which is started by the user.
>
> Not a perfect solution, but doable:
>
>- The It department is happy: No work doing specialized installations
>- The GIS administrator is happy. It's a one-time piece of work for
>each QGIS version to  prepare the profile and tokenize the QGIS.ini
>- The user is - somewhat - happy. To finish the installation is simply
>to double-click once on a file placed in a "highly visible" location.
>- Any subsequent mistakes made by the user (Installation of dodgy
>plugins, strange changes in setups ) is easily repaired by running the
>Python script again.
>
>
> Med venlig hilsen / Kind regards
>
> Bo Victor Thomsen
>
> Den 12-07-2021 kl. 03:14 skrev Thomas Gratier:
>
> Hi,
>
> I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is not
> portable as would only work on Windows
>
> You can always try generate the QGIS.ini file using a templating system
>
> File QGIS.ini.j2 with following content
>
>
> Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
>
> Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>
>
> File generate_ini.py with following content
>
> import os
> import jinja2
>
> templateLoader = jinja2.FileSystemLoader(searchpath="./")
> templateEnv = jinja2.Environment(loader=templateLoader)
> TEMPLATE_FILE = "QGIS.ini.j2"
> template = templateEnv.get_template(TEMPLATE_FILE)
> mydict = {
> "APPDATA": os.environ.get("APPDATA")
> }
> outputText = template.render(**mydict)
> with open('QGIS.ini', 'w') as outputfile:
> outputfile.write(outputText)
>
> Then, to write your QGIS.ini file, do
>
>
> python3 generate_ini.py
>
>
> The possible deal breakers with this approach are:
> - you depend from jinja2, a third party Python library,
> - you can't later reuse the mechanism if for instance QGIS changes the
> QGIS.ini file later on
>
>
> Regards
>
> Thomas
>
>
> Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen <
> bo.victor.thom...@gmail.com> a écrit :
>
>> To the list -
>>
>> Is there a method to use OS (Linux, Windows...) environment variables in
>> the QGIS.ini setup file ?
>>
>> I had a number of customers asking for a method to "generalize" QGIS.ini,
>> so it doesn't contain any "user" specific file and directory references, i.e
>>
>> (From qgis.ini)
>>
>> Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor
>> Thomsen\\AppData\\Roaming*
>> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
>> Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor
>> Thomsen\\AppData\\Roaming*
>> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>
>> could be:
>>
>> Configuration\MODELS_FOLDER=*%APPDATA%*
>> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
>> Configuration\SCRIPTS_FOLDERS=*%APPDATA%*
>> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>>
>> or likewise.
>>
>> The ultimate reason is to have a method to distribute a "standard" setup
>> for QGIS, complete with plugins and specialized setup parameters. This can
>> be done by making a standard QGIS installation (which the IT departments
>> love, especially with the new .msi package) and afterwards replace the
>> "default" profile directory with at  directory specific for the
>> organisation. However, the process of making the new profile will place a
>> lot of file/directory references in QGIS.ini that is specific for the
>> super-user developing the new profile.
>>
>> --
>> Med venlig hilsen / Kind regards
>>
>> Bo Victor Thomsen
>>
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: 

Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-12 Thread Bo Victor Thomsen

Hi Thomas -

Your suggestion is actually pretty close to the solution I made -

 * Standard installation of QGIS with /standard/ .msi package.
 * After the QGIS installation and before QGIS is started the user do a
   one-time run a Python script from et central network drive -  using
   the Python interpreter installed together with QGIS  which:
 o Unzip a complete profile  with specific plugins and customized
   parameters from a central network based repository. This profile
   replaces the standard "default" profile.
 o Search/replace a couple of "tokenized" values in QGIS.ini with
   actual values based on username

The profile and tokenized QGIS.ini is prepared by the GIS administrator

The Python script is packaged in a .cmd file which is started by the user.

Not a perfect solution, but doable:

 * The It department is happy: No work doing specialized installations
 * The GIS administrator is happy. It's a one-time piece of work for
   each QGIS version to  prepare the profile and tokenize the QGIS.ini
 * The user is - somewhat - happy. To finish the installation is simply
   to double-click once on a file placed in a "highly visible" location.
 * Any subsequent mistakes made by the user (Installation of dodgy
   plugins, strange changes in setups ) is easily repaired by
   running the Python script again.


Med venlig hilsen / Kind regards

Bo Victor Thomsen

Den 12-07-2021 kl. 03:14 skrev Thomas Gratier:

Hi,

I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is 
not portable as would only work on Windows


You can always try generate the QGIS.ini file using a templating system

File QGIS.ini.j2 with following content

Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts


File generate_ini.py with following content

import os
import jinja2

templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "QGIS.ini.j2"
template = templateEnv.get_template(TEMPLATE_FILE)
mydict = {
    "APPDATA": os.environ.get("APPDATA")
}
outputText = template.render(**mydict)
with open('QGIS.ini', 'w') as outputfile:
    outputfile.write(outputText)

Then, to write your QGIS.ini file, do


python3 generate_ini.py


The possible deal breakers with this approach are:
- you depend from jinja2, a third party Python library,
- you can't later reuse the mechanism if for instance QGIS changes the 
QGIS.ini file later on



Regards

Thomas


Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen 
mailto:bo.victor.thom...@gmail.com>> a 
écrit :


To the list -

Is there a method to use OS (Linux, Windows...) environment
variables in the QGIS.ini setup file ?

I had a number of customers asking for a method to "generalize"
QGIS.ini, so it doesn't contain any "user" specific file and
directory references, i.e

(From qgis.ini)

Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor

Thomsen\\AppData\\Roaming*\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor

Thomsen\\AppData\\Roaming*\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts

could be:


Configuration\MODELS_FOLDER=*%APPDATA%*\\QGIS\\QGIS3\\profiles\\default\\processing\\models

Configuration\SCRIPTS_FOLDERS=*%APPDATA%*\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts

or likewise.

The ultimate reason is to have a method to distribute a "standard"
setup for QGIS, complete with plugins and specialized setup
parameters. This can be done by making a standard QGIS
installation (which the IT departments love, especially with the
new .msi package) and afterwards replace the "default" profile
directory with at  directory specific for the organisation.
However, the process of making the new profile will place a lot of
file/directory references in QGIS.ini that is specific for the
super-user developing the new profile.

-- 
Med venlig hilsen / Kind regards


Bo Victor Thomsen

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org 
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Unsubscribe:
https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Using environment variables in QGIS.ini

2021-07-11 Thread Thomas Gratier
Hi,

I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is not
portable as would only work on Windows

You can always try generate the QGIS.ini file using a templating system

File QGIS.ini.j2 with following content

Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts


File generate_ini.py with following content

import os
import jinja2

templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "QGIS.ini.j2"
template = templateEnv.get_template(TEMPLATE_FILE)
mydict = {
"APPDATA": os.environ.get("APPDATA")
}
outputText = template.render(**mydict)
with open('QGIS.ini', 'w') as outputfile:
outputfile.write(outputText)

Then, to write your QGIS.ini file, do


python3 generate_ini.py


The possible deal breakers with this approach are:
- you depend from jinja2, a third party Python library,
- you can't later reuse the mechanism if for instance QGIS changes the
QGIS.ini file later on


Regards

Thomas


Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen 
a écrit :

> To the list -
>
> Is there a method to use OS (Linux, Windows...) environment variables in
> the QGIS.ini setup file ?
>
> I had a number of customers asking for a method to "generalize" QGIS.ini,
> so it doesn't contain any "user" specific file and directory references, i.e
>
> (From qgis.ini)
>
> Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor
> Thomsen\\AppData\\Roaming*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
> Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor
> Thomsen\\AppData\\Roaming*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>
> could be:
>
> Configuration\MODELS_FOLDER=*%APPDATA%*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
> Configuration\SCRIPTS_FOLDERS=*%APPDATA%*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>
> or likewise.
>
> The ultimate reason is to have a method to distribute a "standard" setup
> for QGIS, complete with plugins and specialized setup parameters. This can
> be done by making a standard QGIS installation (which the IT departments
> love, especially with the new .msi package) and afterwards replace the
> "default" profile directory with at  directory specific for the
> organisation. However, the process of making the new profile will place a
> lot of file/directory references in QGIS.ini that is specific for the
> super-user developing the new profile.
>
> --
> Med venlig hilsen / Kind regards
>
> Bo Victor Thomsen
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] Using environment variables in QGIS.ini

2021-07-06 Thread Bo Victor Thomsen

To the list -

Is there a method to use OS (Linux, Windows...) environment variables in 
the QGIS.ini setup file ?


I had a number of customers asking for a method to "generalize" 
QGIS.ini, so it doesn't contain any "user" specific file and directory 
references, i.e


(From qgis.ini)

Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor 
Thomsen\\AppData\\Roaming*\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor 
Thomsen\\AppData\\Roaming*\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts


could be:

Configuration\MODELS_FOLDER=*%APPDATA%*\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS=*%APPDATA%*\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts

or likewise.

The ultimate reason is to have a method to distribute a "standard" setup 
for QGIS, complete with plugins and specialized setup parameters. This 
can be done by making a standard QGIS installation (which the IT 
departments love, especially with the new .msi package) and afterwards 
replace the "default" profile directory with at  directory specific for 
the organisation. However, the process of making the new profile will 
place a lot of file/directory references in QGIS.ini that is specific 
for the super-user developing the new profile.


--
Med venlig hilsen / Kind regards

Bo Victor Thomsen

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer