File: __init__.py

package info (click to toggle)
tryton-server 7.0.43-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,760 kB
  • sloc: python: 53,744; xml: 5,194; sh: 803; sql: 217; makefile: 28
file content (43 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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 time
import warnings
from email import charset

import __main__
from lxml import etree, objectify

try:
    from requests import utils as requests_utils
except ImportError:
    requests_utils = None

__version__ = "7.0.43"

if not os.environ.get('TRYTOND_APPNAME'):
    os.environ['TRYTOND_APPNAME'] = os.path.basename(
        getattr(__main__, '__file__', 'trytond'))
if not os.environ.get('TRYTOND_TZ'):
    os.environ['TRYTOND_TZ'] = os.environ.get('TZ') or 'UTC'
os.environ['TZ'] = 'UTC'
if hasattr(time, 'tzset'):
    time.tzset()

if time.tzname[0] != 'UTC':
    warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])

# set email encoding for utf-8 to 'quoted-printable'
charset.add_charset('utf-8', charset.QP, charset.QP)

# prevent XML vulnerabilities by default
etree.set_default_parser(etree.XMLParser(resolve_entities=False))
objectify.set_default_parser(objectify.makeparser(resolve_entities=False))


def default_user_agent(name="Tryton"):
    return f"{name}/{__version__}"


if requests_utils:
    requests_utils.default_user_agent = default_user_agent