summaryrefslogtreecommitdiff
path: root/tools/regression/xsl_reports/utils/checked_system.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/regression/xsl_reports/utils/checked_system.py')
-rw-r--r--tools/regression/xsl_reports/utils/checked_system.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/regression/xsl_reports/utils/checked_system.py b/tools/regression/xsl_reports/utils/checked_system.py
new file mode 100644
index 0000000000..bdb8e8f8e6
--- /dev/null
+++ b/tools/regression/xsl_reports/utils/checked_system.py
@@ -0,0 +1,22 @@
+
+import os
+import string
+import sys
+
+def system( commands ):
+ if sys.platform == 'win32':
+ f = open( 'tmp.cmd', 'w' )
+ f.write( string.join( commands, '\n' ) )
+ f.close()
+ rc = os.system( 'tmp.cmd' )
+ return rc
+ else:
+ rc = os.system( '&&'.join( commands ) )
+ return rc
+
+
+def checked_system( commands, valid_return_codes = [ 0 ] ):
+ rc = system( commands )
+ if rc not in [ 0 ] + valid_return_codes:
+ raise Exception( 'Command sequence "%s" failed with return code %d' % ( commands, rc ) )
+ return rc