@@ -22,7 +22,7 @@ def pid_exists(pid):
22
22
return False
23
23
try :
24
24
os .kill (pid , 0 )
25
- except OSError , e :
25
+ except OSError as e :
26
26
return e .errno == errno .EPERM
27
27
else :
28
28
return True
@@ -39,11 +39,11 @@ def unthrottle_posix(pid):
39
39
f .write ('performance' )
40
40
41
41
def signal_handler (signum , frame ):
42
- print 'Signal hanadler called with signal' , signum
42
+ print ( 'Signal handler called with signal' , signum )
43
43
for cpu , governor in zip (cpus , scaling_governor ):
44
44
with open (cpu , 'w' ) as f :
45
45
f .write (governor )
46
- print 'Reverted throttling to the previous behaviour.'
46
+ print ( 'Reverted throttling to the previous behaviour.' )
47
47
sys .exit (0 )
48
48
49
49
signal .signal (signal .SIGPIPE , signal_handler )
@@ -63,7 +63,8 @@ def unthrottle(pid):
63
63
if os .name == 'posix' :
64
64
unthrottle_posix (pid )
65
65
else :
66
- print 'I don\' t know how to unthrottle your system (' + platform .system ()+ ')'
66
+ print ('I don\' t know how to unthrottle your system (' +
67
+ platform .system () + ')' )
67
68
sys .exit (3 )
68
69
69
70
@@ -81,29 +82,30 @@ def is_throttled():
81
82
if os .name == 'posix' :
82
83
return is_throttled_posix ()
83
84
else :
84
- print 'I don\' t know how to unthrottle your system (' + platform .system ()+ ')'
85
+ print ('I don\' t know how to unthrottle your system (' +
86
+ platform .system () + ')' )
85
87
sys .exit (3 )
86
88
87
89
88
90
def check_root ():
89
91
if os .name == 'posix' :
90
92
if os .getuid () == 0 :
91
93
return
92
- print '\n Error: You need to be root to (un)throttle the CPU.\n '
94
+ print ( '\n Error: You need to be root to (un)throttle the CPU.\n ' )
93
95
sys .exit (1 )
94
96
else :
95
- print 'I don\' t know how to probe administrator rights on your system (' + platform .system ()+ ')'
97
+ print ( 'I don\' t know how to probe administrator rights on your system (' + platform .system ()+ ')' )
96
98
sys .exit (3 )
97
99
98
100
99
101
def check_nonroot ():
100
102
if os .name == 'posix' :
101
103
if os .getuid () > 0 :
102
104
return
103
- print '\n Error: You are crazy to run this as root, exiting.\n '
105
+ print ( '\n Error: You are crazy to run this as root, exiting.\n ' )
104
106
sys .exit (2 )
105
107
else :
106
- print 'I don\' t know how to probe administrator rights on your system (' + platform .system ()+ ')'
108
+ print ( 'I don\' t know how to probe administrator rights on your system (' + platform .system ()+ ')' )
107
109
sys .exit (3 )
108
110
109
111
@@ -123,14 +125,14 @@ atexit.register(wait_for_command)
123
125
def unthrottle_self ():
124
126
if os .name == 'posix' :
125
127
global command
126
- print 'Running sudo atlas-config --unthrottle to turn CPU throttling off.'
128
+ print ( 'Running sudo atlas-config --unthrottle to turn CPU throttling off.' )
127
129
command = subprocess .Popen (['sudo' , os .path .abspath ( __file__ ),
128
130
'--unthrottle' , str (os .getpid ())])
129
131
else :
130
- print 'I don\' t know how to unthrottle your system (' + platform .system ()+ ')'
132
+ print ( 'I don\' t know how to unthrottle your system (' + platform .system ()+ ')' )
131
133
sys .exit (2 )
132
134
133
- print 'Waiting for CPU throttling to be turned off...'
135
+ print ( 'Waiting for CPU throttling to be turned off...' )
134
136
while is_throttled ():
135
137
time .sleep (1 )
136
138
@@ -147,35 +149,28 @@ if __name__ == '__main__':
147
149
unthrottle_self ()
148
150
print
149
151
if os .environ .get ('SAGE_FAT_BINARY' , 'no' ) == 'yes' :
150
- print 'Building ATLAS with SAGE_FAT_BINARY (generic archdefs).'
151
- elif os . environ . has_key ( 'SAGE_ATLAS_ARCH' ) :
152
- print 'Building ATLAS with SAGE_ATLAS_ARCH =' , os .environ ['SAGE_ATLAS_ARCH' ]
152
+ print ( 'Building ATLAS with SAGE_FAT_BINARY (generic archdefs).' )
153
+ elif 'SAGE_ATLAS_ARCH' in os . environ :
154
+ print ( 'Building ATLAS with SAGE_ATLAS_ARCH =' , os .environ ['SAGE_ATLAS_ARCH' ])
153
155
else :
154
- print 'Building ATLAS without specifying architecture.'
155
- print 'This may take many hours during which you should leave the computer otherwise'
156
- print 'idle to obtain accurate timings.'
156
+ print ( 'Building ATLAS without specifying architecture.' )
157
+ print ( 'This may take many hours during which you should leave the computer otherwise' )
158
+ print ( 'idle to obtain accurate timings.' )
157
159
if args .archdef :
158
160
os .environ ['SAGE_ATLAS_SAVE_ARCHDEF' ] = os .getcwd ()
159
- print 'The resulting <archdef>.tar.bz2 will be saved in ' + os .getcwd ()
160
- print
161
- print 'You have 5 seconds to interrupt...'
161
+ print ( 'The resulting <archdef>.tar.bz2 will be saved in ' + os .getcwd () )
162
+ print ()
163
+ print ( 'You have 5 seconds to interrupt...' )
162
164
time .sleep (1 )
163
- print 'You have 4 seconds to interrupt...'
165
+ print ( 'You have 4 seconds to interrupt...' )
164
166
time .sleep (1 )
165
- print 'You have 3 seconds to interrupt...'
167
+ print ( 'You have 3 seconds to interrupt...' )
166
168
time .sleep (1 )
167
- print 'You have 2 seconds to interrupt...'
169
+ print ( 'You have 2 seconds to interrupt...' )
168
170
time .sleep (1 )
169
- print 'You have 1 second to interrupt...'
171
+ print ( 'You have 1 second to interrupt...' )
170
172
time .sleep (1 )
171
173
172
174
sys .stdout .flush ()
173
175
sys .stderr .flush ()
174
176
os .system ('sage -f atlas' )
175
-
176
-
177
-
178
-
179
-
180
-
181
-
0 commit comments