fix, error messages for missing -e
authorDaniel Camara <daniel.camara@telecom-paristech.fr>
Wed, 20 Nov 2013 14:54:23 +0100
changeset 290 57132825eb20
parent 289 82cc073a6a9a
child 291 c94da6cc90f7
fix, error messages for missing -e
bake/Bake.py
bake/ModuleLogger.py
--- a/bake/Bake.py	Tue Nov 05 21:56:05 2013 -0800
+++ b/bake/Bake.py	Wed Nov 20 14:54:23 2013 +0100
@@ -404,8 +404,8 @@
         parser.add_option("--append", action="append", type="string", 
                           dest="append", default=[],
                           help="Format: module:name=value. A variable to"
-                          " append to in the Bake "
-                          "configuration for the matching module.")
+                          " append to in the Bake build "
+                          "configuration for the especified module.")
         parser.add_option("--objdir", action="store", type="string",
                           dest="objdir", default="objdir",
                           help="The per-module directory where the object"
@@ -421,6 +421,18 @@
                           dest="predefined", default=None,
                           help="A predefined configuration to apply")
 
+        parser.add_option('--logfile', help='File in which we want to store log output '
+                          'of requested operation', action="store", type="string", dest="logfile",
+                          default='')
+        parser.add_option('--logdir', help='Directory in which we want to store log output '
+                          'of requested operation. One file per module.', action="store",
+                          type="string", dest="logdir",
+                          default='')
+        parser.add_option('-v', '--verbose', action='count', dest='verbose', 
+                          default=0, help='Increase the log verbosity level')
+        parser.add_option('-q', '--quiet', action='count', dest='quiet', 
+                          default=0, help='Increase the log quietness level')
+
         # sets the configuration values got from the line command
         (options, args_left) = parser.parse_args(args)
 
@@ -497,6 +509,13 @@
                 module.get_build().attribute(name).value = current_value + ' ' + value
         configuration.write()
         
+        if not configuration._enabled and not options.append :
+            env =  self._get_dummy_env(options)
+            env._logger.commands.write(' > No module enabled: Bake configuration requires at least one module to be enabled'
+                                       ' (enable, predefined), or appended.\n'
+                                       '   Argument(s) %s is not enough for an unambiguous action.\n' % (args_left))
+            self._error('No module enabled, please use -e <name of the module>, -p <predefined modules> or -a, to activate all modules.')
+
         self._save_resource_configuration(configuration)
         
         
@@ -1008,6 +1027,7 @@
         verbose = options.verbose - options.quiet
         verbose = verbose if verbose >= 0 else 0
         logger.set_verbose(verbose)
+        logger._update_file(logger._file)
 
         return ModuleEnvironment(logger, "","","", Bake.main_options.debug)
 
--- a/bake/ModuleLogger.py	Tue Nov 05 21:56:05 2013 -0800
+++ b/bake/ModuleLogger.py	Wed Nov 20 14:54:23 2013 +0100
@@ -39,7 +39,7 @@
         """ Initializes the used variables."""
 
         self._verbose = None
-        self._command_file = None
+        self._command_file = open(os.devnull, 'w')
         self._std_file = None
         self._dump_file = None
 
@@ -92,7 +92,8 @@
         """ Initializes the used variables."""
 
         ModuleLogger.__init__(self)
-        self._update_file(sys.__stdout__)
+        self._file=sys.__stdout__
+        self._update_file(self._file)
         
     def set_current_module(self, name):
         """ Sets stdout as the output as the output for the module."""