Salome HOME
improve some commentaries
[tools/sat.git] / commands / testcommand.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 import subprocess
5
6 import src
7
8 # Define all possible option for config command :  sat config <options>
9 parser = src.options.Options()
10 parser.add_option('u', 'unique', 'boolean', 'unique', "TEST d'option.")
11 parser.add_option('v', 'value', 'string', 'value', "Appelle la commande config avec l'option value.")
12 parser.add_option('m', 'make', 'boolean', 'test_make', "Test d'une commande exterieure : make.")
13
14 def description():
15     return _("Test d'une commande supplĂ©mentaire.")
16     
17
18 def run(args, runner, logger):
19     (options, args) = parser.parse_args(args)
20     if options.unique:
21         logger.write('unique\n')
22     elif options.value:
23         runner.cfg.VARS.user = 'TEST'
24         runner.config('-v ' + options.value, logger)
25     elif options.test_make:
26         command = "make"
27         logger.write("Execution of make\n", 3)
28         res = subprocess.call(command, cwd=str('/tmp'), shell=True,
29                       stdout=logger.logTxtFile, stderr=logger.logTxtFile)
30         
31         print(res)