Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F11712074
One implementation for T182451: qacct wrapper
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
zhuyifei1999
Dec 9 2017, 1:49 AM
2017-12-09 01:49:32 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
One implementation for T182451: qacct wrapper
View Options
#! /usr/bin/python3 -Es
import
io
import
os
import
subprocess
import
sys
import
tempfile
sge_root
=
os
.
environ
.
get
(
'SGE_ROOT'
,
'/var/lib/gridengine'
)
sge_cell
=
os
.
environ
.
get
(
'SGE_CELL'
,
'default'
)
account_file
=
'common/accounting'
logpath
=
os
.
path
.
join
(
sge_root
,
sge_cell
,
account_file
)
with
open
(
logpath
,
'rb'
)
as
logfile
:
logfile
.
seek
(
-
400
*
45000
*
7
,
os
.
SEEK_END
)
# Ignore first line as it may be onlym part of a line
logfile
.
readline
()
with
tempfile
.
TemporaryDirectory
()
as
new_sge_root
:
new_logpath
=
os
.
path
.
join
(
new_sge_root
,
sge_cell
,
account_file
)
os
.
makedirs
(
os
.
path
.
dirname
(
new_logpath
))
for
fname
in
os
.
listdir
(
os
.
path
.
dirname
(
logpath
)):
os
.
symlink
(
os
.
path
.
join
(
os
.
path
.
dirname
(
logpath
),
fname
),
os
.
path
.
join
(
os
.
path
.
dirname
(
new_logpath
),
fname
))
os
.
remove
(
new_logpath
)
os
.
mkfifo
(
new_logpath
)
real_qacct
=
subprocess
.
Popen
(
[
'/usr/bin/qacct'
]
+
sys
.
argv
[
1
:],
env
=
dict
(
os
.
environ
,
SGE_ROOT
=
new_sge_root
))
with
open
(
new_logpath
,
'wb'
)
as
new_logfile
:
while
real_qacct
.
poll
()
is
None
:
data
=
logfile
.
read
(
io
.
DEFAULT_BUFFER_SIZE
)
if
not
data
:
break
new_logfile
.
write
(
data
)
sys
.
exit
(
real_qacct
.
wait
())
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5285255
Default Alt Text
One implementation for T182451: qacct wrapper (1 KB)
Attached To
Mode
P6446 One implementation for T182451: qacct wrapper
Attached
Detach File
Event Timeline
Log In to Comment