blob: bdb8e8f8e6b5448c97ceba1397c6d47d8daf0e02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|