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
Boxiang Sun
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):
...
@@ -582,9 +582,8 @@ class Slapgrid(object):
except
NotFoundError
:
except
NotFoundError
:
pass
pass
software
.
install
()
software
.
install
()
file_descriptor
=
open
(
completed_tag
,
'w'
)
with
open
(
completed_tag
,
'w'
)
as
fout
:
file_descriptor
.
write
(
time
.
asctime
())
fout
.
write
(
time
.
asctime
())
file_descriptor
.
close
()
elif
state
==
'destroyed'
:
elif
state
==
'destroyed'
:
if
os
.
path
.
exists
(
software_path
):
if
os
.
path
.
exists
(
software_path
):
logger
.
info
(
'Destroying %r...'
%
software_release_uri
)
logger
.
info
(
'Destroying %r...'
%
software_release_uri
)
...
@@ -665,7 +664,6 @@ class Slapgrid(object):
...
@@ -665,7 +664,6 @@ class Slapgrid(object):
promise
=
os
.
path
.
basename
(
command
[
0
])
promise
=
os
.
path
.
basename
(
command
[
0
])
self
.
logger
.
info
(
"Checking promise %r."
,
promise
)
self
.
logger
.
info
(
"Checking promise %r."
,
promise
)
process_handler
=
subprocess
.
Popen
(
command
,
process_handler
=
subprocess
.
Popen
(
command
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
cwd
,
cwd
=
cwd
,
...
@@ -1169,9 +1167,7 @@ class Slapgrid(object):
...
@@ -1169,9 +1167,7 @@ class Slapgrid(object):
file_path
=
os
.
path
.
join
(
dir_reports
,
filename
)
file_path
=
os
.
path
.
join
(
dir_reports
,
filename
)
if
os
.
path
.
exists
(
file_path
):
if
os
.
path
.
exists
(
file_path
):
usage_file
=
open
(
file_path
,
'r'
)
usage
=
open
(
file_path
,
'r'
).
read
()
usage
=
usage_file
.
read
()
usage_file
.
close
()
#We check the validity of xml content of each reports
#We check the validity of xml content of each reports
if
not
self
.
validateXML
(
usage
,
partition_consumption_model
):
if
not
self
.
validateXML
(
usage
,
partition_consumption_model
):
...
...
slapos/grid/utils.py
View file @
225e6d79
...
@@ -111,9 +111,7 @@ class SlapPopen(subprocess.Popen):
...
@@ -111,9 +111,7 @@ class SlapPopen(subprocess.Popen):
if
line
==
''
and
self
.
poll
()
!=
None
:
if
line
==
''
and
self
.
poll
()
!=
None
:
break
break
output_lines
.
append
(
line
)
output_lines
.
append
(
line
)
if
line
[
-
1
:]
==
'
\
n
'
:
logger
.
info
(
line
.
rstrip
(
'
\
n
'
))
line
=
line
[:
-
1
]
logger
.
info
(
line
)
self
.
output
=
''
.
join
(
output_lines
)
self
.
output
=
''
.
join
(
output_lines
)
...
@@ -168,11 +166,9 @@ def setFinished(pid_file):
...
@@ -168,11 +166,9 @@ def setFinished(pid_file):
def
write_pid
(
pid_file
):
def
write_pid
(
pid_file
):
logger
=
logging
.
getLogger
(
'Slapgrid'
)
logger
=
logging
.
getLogger
(
'Slapgrid'
)
pid
=
os
.
getpid
()
try
:
try
:
f
=
open
(
pid_file
,
'w'
)
with
open
(
pid_file
,
'w'
)
as
fout
:
f
.
write
(
'%s'
%
pid
)
fout
.
write
(
'%s'
%
os
.
getpid
())
f
.
close
()
except
(
IOError
,
OSError
):
except
(
IOError
,
OSError
):
logger
.
critical
(
'slapgrid could not write pidfile %s'
%
pid_file
)
logger
.
critical
(
'slapgrid could not write pidfile %s'
%
pid_file
)
raise
raise
...
@@ -302,9 +298,7 @@ def launchBuildout(path, buildout_binary,
...
@@ -302,9 +298,7 @@ def launchBuildout(path, buildout_binary,
uid
=
stat_info
.
st_uid
uid
=
stat_info
.
st_uid
gid
=
stat_info
.
st_gid
gid
=
stat_info
.
st_gid
# Extract python binary to prevent shebang size limit
# Extract python binary to prevent shebang size limit
file
=
open
(
buildout_binary
,
'r'
)
line
=
open
(
buildout_binary
,
'r'
).
readline
()
line
=
file
.
readline
()
file
.
close
()
invocation_list
=
[]
invocation_list
=
[]
if
line
.
startswith
(
'#!'
):
if
line
.
startswith
(
'#!'
):
line
=
line
[
2
:]
line
=
line
[
2
:]
...
@@ -341,11 +335,9 @@ def updateFile(file_path, content, mode=0o600):
...
@@ -341,11 +335,9 @@ def updateFile(file_path, content, mode=0o600):
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
\
hashlib
.
md5
(
content
).
digest
()):
hashlib
.
md5
(
content
).
digest
()):
with
open
(
file_path
,
'w'
)
as
fout
:
fout
.
write
(
content
)
altered
=
True
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
)
os
.
chmod
(
file_path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
if
stat
.
S_IMODE
(
os
.
stat
(
file_path
).
st_mode
)
!=
mode
:
if
stat
.
S_IMODE
(
os
.
stat
(
file_path
).
st_mode
)
!=
mode
:
os
.
chmod
(
file_path
,
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