Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos.core
Commits
225e6d79
Commit
225e6d79
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file handling cleanup
parent
beb698a5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
21 deletions
+9
-21
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+3
-7
slapos/grid/utils.py
slapos/grid/utils.py
+6
-14
No files found.
slapos/grid/slapgrid.py
View file @
225e6d79
...
...
@@ -582,9 +582,8 @@ class Slapgrid(object):
except
NotFoundError
:
pass
software
.
install
()
file_descriptor
=
open
(
completed_tag
,
'w'
)
file_descriptor
.
write
(
time
.
asctime
())
file_descriptor
.
close
()
with
open
(
completed_tag
,
'w'
)
as
fout
:
fout
.
write
(
time
.
asctime
())
elif
state
==
'destroyed'
:
if
os
.
path
.
exists
(
software_path
):
logger
.
info
(
'Destroying %r...'
%
software_release_uri
)
...
...
@@ -665,7 +664,6 @@ class Slapgrid(object):
promise
=
os
.
path
.
basename
(
command
[
0
])
self
.
logger
.
info
(
"Checking promise %r."
,
promise
)
process_handler
=
subprocess
.
Popen
(
command
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
cwd
,
...
...
@@ -1169,9 +1167,7 @@ class Slapgrid(object):
file_path
=
os
.
path
.
join
(
dir_reports
,
filename
)
if
os
.
path
.
exists
(
file_path
):
usage_file
=
open
(
file_path
,
'r'
)
usage
=
usage_file
.
read
()
usage_file
.
close
()
usage
=
open
(
file_path
,
'r'
).
read
()
#We check the validity of xml content of each reports
if
not
self
.
validateXML
(
usage
,
partition_consumption_model
):
...
...
slapos/grid/utils.py
View file @
225e6d79
...
...
@@ -111,9 +111,7 @@ class SlapPopen(subprocess.Popen):
if
line
==
''
and
self
.
poll
()
!=
None
:
break
output_lines
.
append
(
line
)
if
line
[
-
1
:]
==
'
\
n
'
:
line
=
line
[:
-
1
]
logger
.
info
(
line
)
logger
.
info
(
line
.
rstrip
(
'
\
n
'
))
self
.
output
=
''
.
join
(
output_lines
)
...
...
@@ -168,11 +166,9 @@ def setFinished(pid_file):
def
write_pid
(
pid_file
):
logger
=
logging
.
getLogger
(
'Slapgrid'
)
pid
=
os
.
getpid
()
try
:
f
=
open
(
pid_file
,
'w'
)
f
.
write
(
'%s'
%
pid
)
f
.
close
()
with
open
(
pid_file
,
'w'
)
as
fout
:
fout
.
write
(
'%s'
%
os
.
getpid
())
except
(
IOError
,
OSError
):
logger
.
critical
(
'slapgrid could not write pidfile %s'
%
pid_file
)
raise
...
...
@@ -302,9 +298,7 @@ def launchBuildout(path, buildout_binary,
uid
=
stat_info
.
st_uid
gid
=
stat_info
.
st_gid
# Extract python binary to prevent shebang size limit
file
=
open
(
buildout_binary
,
'r'
)
line
=
file
.
readline
()
file
.
close
()
line
=
open
(
buildout_binary
,
'r'
).
readline
()
invocation_list
=
[]
if
line
.
startswith
(
'#!'
):
line
=
line
[
2
:]
...
...
@@ -341,11 +335,9 @@ def updateFile(file_path, content, mode=0o600):
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
\
hashlib
.
md5
(
content
).
digest
()):
with
open
(
file_path
,
'w'
)
as
fout
:
fout
.
write
(
content
)
altered
=
True
file_file
=
open
(
file_path
,
'w'
)
file_file
.
write
(
content
)
file_file
.
flush
()
file_file
.
close
()
os
.
chmod
(
file_path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
if
stat
.
S_IMODE
(
os
.
stat
(
file_path
).
st_mode
)
!=
mode
:
os
.
chmod
(
file_path
,
mode
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment