Salome HOME
style: black format
[tools/sat.git] / data / templates / Application / config / compile.py
1 #!/usr/bin/env python
2 # -*- coding:utf-8 -*-
3
4 # This script is used to build the application module.
5 # First, it copies the content of the sources directory to the install directory.
6 # Then it runs 'lrelease' to build the resources.
7
8 import subprocess
9
10 import src
11
12
13 def compil(config, builder, logger):
14     builder.prepare()
15     if not builder.source_dir.smartcopy(builder.install_dir):
16         raise src.SatException(
17             _("Error when copying %s sources to install dir")
18             % builder.product_info.name
19         )
20
21     # test lrelease #.pyconf needs in ..._APPLI pre_depend : ['qt']
22     command = "which lrelease"
23     res = subprocess.Popen(
24         command,
25         shell=True,
26         stdout=subprocess.PIPE,
27         stderr=subprocess.PIPE,
28         env=builder.build_environ.environ.environ,
29     ).communicate()
30     if res[1] != "":  # an error occured
31         logger.write("ERROR: %s" % res[1])
32         builder.log(res[1] + "\n")
33         return 1
34
35     # run lrelease
36     command = "lrelease *.ts"
37     res = subprocess.call(
38         command,
39         shell=True,
40         cwd=str(builder.install_dir + "resources"),
41         env=builder.build_environ.environ.environ,
42         stdout=logger.logTxtFile,
43         stderr=subprocess.STDOUT,
44     )
45     if res != 0:
46         res = 1
47
48     return res