Revision 0c1833c8

b/snf-tools/synnefo_tools/burnin/__init__.py
161 161
        "--no-colors", action="store_false",
162 162
        default=True, dest="use_colors",
163 163
        help="Disable colorful output")
164
    parser.add_option(
165
        "--quiet", action="store_true",
166
        default=False, dest="quiet",
167
        help="Turn off log output")
168
    parser.add_option(
169
        "--final-report-only", action="store_true",
170
        default=False, dest="final_report",
171
        help="Turn off log output and only print the contents of the log "
172
             "file at the end of the test. Useful when burnin is used in "
173
             "script files and it's output is to be sent using email")
164 174

  
165 175
    (opts, args) = parser.parse_args(args)
166 176

  
......
171 181
        show_version()
172 182
        sys.exit(0)
173 183

  
184
    # `delete_stale' implies `show_stale'
185
    if opts.delete_stale:
186
        opts.show_stale = True
187

  
188
    # `quiet' implies not `final_report'
189
    if opts.quiet:
190
        opts.final_report = False
191
    # `final_report' implies `quiet'
192
    if opts.final_report:
193
        opts.quiet = True
194

  
174 195
    # `token' is mandatory
175 196
    mandatory_argument(opts.token, "--token")
176 197
    # `auth_url' is mandatory
......
213 234

  
214 235
    # Run burnin
215 236
    # The return value denotes the success status
216
    return common.run(testsuites)
237
    return common.run(testsuites, failfast=opts.failfast,
238
                      final_report=opts.final_report)
217 239

  
218 240

  
219 241
if __name__ == "__main__":
b/snf-tools/synnefo_tools/burnin/common.py
173 173
    # Initialize logger
174 174
    global logger  # Using global statement. pylint: disable-msg=C0103,W0603
175 175
    logger = Log(opts.log_folder, verbose=opts.verbose,
176
                 use_colors=opts.use_colors, in_parallel=False)
176
                 use_colors=opts.use_colors, in_parallel=False,
177
                 quiet=opts.quiet)
177 178

  
178 179
    # Initialize clients
179 180
    Clients.auth_url = opts.auth_url
......
194 195

  
195 196
# --------------------------------------------------------------------
196 197
# Run Burnin
197
def run(testsuites):
198
def run(testsuites, failfast=False, final_report=False):
198 199
    """Run burnin testsuites"""
199 200
    global logger  # Using global. pylint: disable-msg=C0103,W0603,W0602
200 201

  
......
204 205
        results = tsuite.run(BurninTestResult())
205 206
        success = success and \
206 207
            was_successful(tcase.__name__, results.wasSuccessful())
208
        if failfast and not success:
209
            break
207 210

  
211
    # Are we going to print final report?
212
    if final_report:
213
        logger.print_logfile_to_stdout()
208 214
    # Clean up our logger
209 215
    del(logger)
210 216

  
b/snf-tools/synnefo_tools/burnin/logger.py
207 207

  
208 208
    """
209 209
    # ----------------------------------
210
    # Too many arguments. pylint: disable-msg=R0913
210 211
    def __init__(self, output_dir, verbose=1, use_colors=True,
211
                 in_parallel=False):
212
                 in_parallel=False, quiet=False):
212 213
        """Initialize our loggers
213 214

  
214 215
        The file to be used by our file logger will be created inside
......
225 226
        @param use_colors: use colors for out stdout/stderr logger
226 227
        @type in_parallel: boolean
227 228
        @param in_parallel: this signifies that burnin is running in parallel
229
        @type quiet: boolean
230
        @type quiet: do not print logs to stdout/stderr
228 231

  
229 232
        """
230 233
        self.verbose = verbose
231 234
        self.use_colors = use_colors
232 235
        self.in_parallel = in_parallel
236
        self.quiet = quiet
233 237

  
234 238
        assert output_dir
235 239

  
......
252 256

  
253 257
        timestamp = datetime.datetime.strftime(
254 258
            datetime.datetime.now(), "%a %b %d %Y %H:%M")
255
        sys.stdout.write("Starting burnin (%s)\n" % timestamp)
259
        self._write_to_stdout(None, "Starting burnin (%s)\n" % timestamp)
256 260

  
257 261
        # Create the logging file
258 262
        self._create_logging_file(timestamp)
......
278 282
            except OSError:
279 283
                self.debug(None, "Couldn't delete lock file")
280 284

  
285
    def print_logfile_to_stdout(self):
286
        """Print the contents of our log file to stdout"""
287
        with open(self.file_location, 'r') as fin:
288
            sys.stdout.write(fin.read())
289

  
281 290
    # ----------------------------------
282 291
    # Logging methods
283 292
    def debug(self, section, msg, *args):
......
346 355

  
347 356
    def _write_to_stdout(self, section, msg):
348 357
        """Write to stdout"""
349
        if section is not None and self.in_parallel:
350
            sys.stdout.write(section + ": " + msg)
351
        else:
352
            sys.stdout.write(msg)
358
        if not self.quiet:
359
            if section is not None and self.in_parallel:
360
                sys.stdout.write(section + ": " + msg)
361
            else:
362
                sys.stdout.write(msg)
353 363

  
354 364
    def _write_to_stderr(self, section, msg):
355 365
        """Write to stderr"""
356
        if section is not None and self.in_parallel:
357
            sys.stderr.write(section + ": " + msg)
358
        else:
359
            sys.stderr.write(msg)
366
        if not self.quiet:
367
            if section is not None and self.in_parallel:
368
                sys.stderr.write(section + ": " + msg)
369
            else:
370
                sys.stderr.write(msg)
360 371

  
361 372
    def _write_to_file(self, section, msg):
362 373
        """Write to file"""

Also available in: Unified diff