Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
51763792 by Udo Spallek at 2023-04-28T23:45:43+02:00
Try __main__.__file__ as application name and fallback to 'trytond' on 
fail

sys.argv is not reliable to get the process name.

Closes #12242
- - - - -


1 changed file:

- trytond/trytond/__init__.py


Changes:

=====================================
trytond/trytond/__init__.py
=====================================
@@ -1,8 +1,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 import os
-import sys
 import time
 import warnings
 from email import charset
 
@@ -5,8 +4,9 @@
 import time
 import warnings
 from email import charset
 
+import __main__
 from lxml import etree, objectify
 
 __version__ = "6.7.0"
 
@@ -9,8 +9,10 @@
 from lxml import etree, objectify
 
 __version__ = "6.7.0"
 
-os.environ.setdefault('TRYTOND_APPNAME', os.path.basename(sys.argv[0]))
+os.environ.setdefault(
+    'TRYTOND_APPNAME',
+    os.path.basename(getattr(__main__, '__file__', 'trytond')))
 os.environ.setdefault('TRYTOND_TZ', os.environ.get('TZ', 'UTC'))
 os.environ['TZ'] = 'UTC'
 if hasattr(time, 'tzset'):



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/51763792837e3ec5ecefeeb127b559deb60334b3

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/51763792837e3ec5ecefeeb127b559deb60334b3
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to