Salome HOME
96fc057e1f5ab3a3d0198958f8cf8fd0bc44de81
[tools/sat.git] / commands / log.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 import os
5 import shutil
6
7 import src
8
9 # Define all possible option for log command :  sat log <options>
10 parser = src.options.Options()
11 parser.add_option('t', 'terminal', 'boolean', 'terminal', "Terminal log.")
12
13
14
15 def description():
16     return _("Gives access to logs of salomeTools.")    
17
18 def run(args, runner):
19     (options, args) = parser.parse_args(args)
20     if options.terminal:
21         print('terminal')
22     
23     # Find stylesheet Directory and files
24     xslDir = os.path.join(runner.cfg.VARS.srcDir, 'xsl')
25     xslCommand = os.path.join(xslDir, "command.xsl")
26     xslHat = os.path.join(xslDir, "hat.xsl")
27     imgLogo = os.path.join(xslDir, "LOGO-SAT.png")
28
29     # get the log direcory. If there is an application, it is in cfg.APPLICATION.out_dir, else in user directory
30     logDir = runner.cfg.VARS.logDir
31     
32     # copy the stylesheet in the log directory
33     shutil.copy2(xslCommand, logDir)
34     shutil.copy2(xslHat, logDir)
35     shutil.copy2(imgLogo, logDir)
36     
37     xmlHatFilePath = os.path.join(logDir, 'hat.xml')
38     if 'APPLICATION' in runner.cfg:
39         src.xmlManager.update_hat_xml(runner.cfg.VARS.logDir, runner.cfg.VARS.application)
40     else:
41         src.xmlManager.update_hat_xml(runner.cfg.VARS.logDir)
42     
43     src.system.show_in_editor(runner.cfg.USER.browser, xmlHatFilePath)