Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/release/utils.py @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.4 KB
Line 
1import string
2
3import os
4
5class failure_exception:
6    def __init__( self, rc ):
7        self.rc_ = rc
8
9    def __str__( self ):
10        return "rc: %d" % self.rc_
11
12def system( commands ):
13    if os.path.exists( "tmp.cmd" ):
14        os.chmod( "tmp.cmd", 0777 )
15        os.unlink( "tmp.cmd" )
16
17    f = open( "tmp.cmd", "w" )
18    f.write( string.join( commands, "\n" ) )
19    f.close()
20    rc = os.system( "tmp.cmd" )
21    os.chmod( "tmp.cmd", 0777 )
22    os.unlink( "tmp.cmd" )
23    return rc
24
25def checked_system( commands, valid_return_codes = [ 0 ] ):
26    rc = system( commands ) 
27    if rc not in [ 0 ] + valid_return_codes: raise failure_exception( rc )
28    return rc
29
30class step_controller:
31    def __init__( self, start_step ):
32        self.current_step_ = None;
33        self.skip_to_step_ = start_step
34
35    def start_step( self, step_name, start_message ):
36        self.current_step_ = step_name
37        if self.is_skipping( step_name ):
38            print "[%s] Skipping." % step_name
39            return 0
40        else:
41            self.skip_to_step_ = ""
42            print "[%s] %s" % ( step_name, start_message )
43            return 1
44
45    def finish_step( self, step_name ):
46        print "[%s] Finished" % step_name
47
48    def is_skipping( self, step_name = None ):
49        if step_name is None: step_name = self.current_step_
50        return self.skip_to_step_ != "" and self.skip_to_step_ != step_name
51
52   
Note: See TracBrowser for help on using the repository browser.