10 # Define all possible option for log command : sat log <options>
11 parser = src.options.Options()
12 parser.add_option('t', 'terminal', 'boolean', 'terminal', "Terminal log.")
16 rep = raw_input(_("Which one (enter or 0 to quit)? "))
28 def show_log_command_in_terminal(filePath, logger):
29 xmlRead = src.xmlManager.readXmlFile(filePath)
30 lAttrText = xmlRead.get_attrib_text('name')
32 src.print_info(logger, lAttrText)
33 command_traces = xmlRead.get_node_text('traces')
35 logger.write(_("Here are the command traces :\n"), 1)
36 logger.write(command_traces, 1)
40 return _("Gives access to logs of salomeTools.")
42 def run(args, runner):
43 (options, args) = parser.parse_args(args)
45 # get the log directory. If there is an application, it is in cfg.APPLICATION.out_dir, else in user directory
46 logDir = runner.cfg.VARS.logDir
50 for fileName in os.listdir(logDir):
51 sExpr = "^[0-9]{8}_+[0-9]{6}_+.*.xml$"
52 oExpr = re.compile(sExpr)
53 if oExpr.search(fileName):
54 lLogs.append(fileName)
59 date_hour_cmd = t.split('_')
60 date_not_formated = date_hour_cmd[0]
61 date = "%s/%s/%s" % (date_not_formated[6:8], date_not_formated[4:6], date_not_formated[0:4] )
62 hour_not_formated = date_hour_cmd[1]
63 hour = "%s:%s:%s" % (hour_not_formated[0:2], hour_not_formated[2:4], hour_not_formated[4:6])
64 cmd = date_hour_cmd[2][:-len('.xml')]
66 num = src.printcolors.printcLabel("%2d" % (nb_logs - index))
67 runner.logger.write("%s: %13s %s %s\n" % (num, cmd, date, hour), 1, False)
73 x = ask_value(nb_logs)
76 index = len(lLogs) - int(x)
77 show_log_command_in_terminal(os.path.join(logDir, lLogs[index]), runner.logger)
83 # Find the stylesheets Directory and files
84 xslDir = os.path.join(runner.cfg.VARS.srcDir, 'xsl')
85 xslCommand = os.path.join(xslDir, "command.xsl")
86 xslHat = os.path.join(xslDir, "hat.xsl")
87 imgLogo = os.path.join(xslDir, "LOGO-SAT.png")
89 # copy the stylesheets in the log directory
90 shutil.copy2(xslCommand, logDir)
91 shutil.copy2(xslHat, logDir)
92 shutil.copy2(imgLogo, logDir)
94 xmlHatFilePath = os.path.join(logDir, 'hat.xml')
95 if 'APPLICATION' in runner.cfg:
96 src.xmlManager.update_hat_xml(runner.cfg.VARS.logDir, runner.cfg.VARS.application)
98 src.xmlManager.update_hat_xml(runner.cfg.VARS.logDir)
100 src.system.show_in_editor(runner.cfg.USER.browser, xmlHatFilePath)