Skip to content

Instantly share code, notes, and snippets.

View mkorpela's full-sized avatar

Mikko Korpela mkorpela

View GitHub Profile
@mkorpela
mkorpela / Printter.py
Created March 5, 2014 13:55
Print execution status during robot run (pybot --listener Printter.py ..)
class Printter(object):
ROBOT_LISTENER_API_VERSION = 2
def __init__(self):
self._main_suite = True
self.passed_all = 0
self.failed_all = 0
self.passed_critical = 0
self.failed_critical = 0
import os
import re
SPLITTER = re.compile(r'\n(?=[^\s])', re.MULTILINE)
def files(path):
for root, dirs, files in os.walk(path):
for f in files:
if f.endswith('.txt') or f.endswith('.robot') or f.endswith('.tsv'):
yield os.path.join(root, f)
@mkorpela
mkorpela / test_execution_order.py
Created May 20, 2014 10:05
Pabot test execution order visualisation
from robot.api import ExecutionResult, ResultVisitor
from robot.utils import timestamp_to_secs as ts, secs_to_timestamp as st
res = ExecutionResult('output.xml')
class SuiteAndTestTimes(ResultVisitor):
def __init__(self):
self.result_by_start_time = []
self.result_by_end_time = []
@mkorpela
mkorpela / result_merger.py
Created August 23, 2014 08:05
result_merger.py
# Copyright 2014 Mikko Korpela
# Partly based on work of Pekka
# under Copyright 2008-2014 Nokia Solutions and Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
class TrucksAvailable(object):
def __init__(self):
self._trucks_available = []
def add_truck(self, times):
for start, end in times:
self._add_truck_to_time_slice(start, end)
def _add_truck_to_time_slice(self, start, end):
@mkorpela
mkorpela / chromejam.py
Created February 9, 2012 12:42
This seems to jam while Chrome is running
import sys
import wx
print wx.__version__
print sys.version_info
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
@mkorpela
mkorpela / pybotprofiler.py
Created October 17, 2012 18:53
Script to help in Robot Framework test optimization
import cProfile
import pstats
from robot.run import run_cli
import os, sys
import tempfile
profile_results = tempfile.mktemp(suffix='.out', prefix='pybot-profile', dir='.')
cProfile.run('run_cli(sys.argv[1:])', profile_results)
stats = pstats.Stats(profile_results)
stats.sort_stats('cumulative').print_stats(50)
@mkorpela
mkorpela / feiluret.py
Created November 9, 2012 11:55
Log failure information to command line
# Copyright 2008-2012 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
import cProfile
import pstats
from pabot.pabot import main
import os, sys
import tempfile
profile_results = tempfile.mktemp(suffix='.out', prefix='pybot-profile', dir='.')
cProfile.run('main(sys.argv[1:])', profile_results)
stats = pstats.Stats(profile_results)
stats.sort_stats('cumulative').print_stats(50)
@mkorpela
mkorpela / stacktrace_signalhandler.py
Created January 7, 2014 13:27
Print stack trace during test execution. Works on POSIX not WINDOWS.
mport signal
import sys
import traceback
def debug(sig, frame):
""" This is a modified version of the one posted to http://stackoverflow.com/a/133384/308189
This one only writes the traceback to real stdout as robot framework redirects the stdout
"""
message = "\nSignal recieved : \nTraceback:\n"