Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HPCasCode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hpc-team
HPCasCode
Commits
62749f0e
Commit
62749f0e
authored
8 years ago
by
Philip Chan
Browse files
Options
Downloads
Patches
Plain Diff
subprocess.call instead of os.system
Former-commit-id:
661d57cc
parent
6a10c912
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
roles/provision_homedir/templates/provision_homedir.py.j2
+10
-7
10 additions, 7 deletions
roles/provision_homedir/templates/provision_homedir.py.j2
with
10 additions
and
7 deletions
roles/provision_homedir/templates/provision_homedir.py.j2
+
10
−
7
View file @
62749f0e
...
@@ -3,7 +3,8 @@ import ldap
...
@@ -3,7 +3,8 @@ import ldap
import
traceback
import
traceback
import
os
import
os
import
stat
import
stat
import
shutil
#import shutil
import
subprocess
class
ldapSearchConfig
:
class
ldapSearchConfig
:
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -62,10 +63,10 @@ def recursive_chown(path,uidNumber,gidNumber):
...
@@ -62,10 +63,10 @@ def recursive_chown(path,uidNumber,gidNumber):
if
si
.
st_uid
!=
uidNumber
or
si
.
st_gid
!=
gidNumber
:
if
si
.
st_uid
!=
uidNumber
or
si
.
st_gid
!=
gidNumber
:
raise
Exception
(
"
user home %s uid %d != %d, gid %d != %d mismatch
"
%
(
path
,
si
.
st_uid
,
uidNumber
,
si
.
st_gid
,
gidNumber
))
raise
Exception
(
"
user home %s uid %d != %d, gid %d != %d mismatch
"
%
(
path
,
si
.
st_uid
,
uidNumber
,
si
.
st_gid
,
gidNumber
))
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
for
momo
in
dirs
:
for
dname
in
dirs
:
os
.
chown
(
os
.
path
.
join
(
root
,
momo
),
uidNumber
,
gidNumber
)
os
.
chown
(
os
.
path
.
join
(
root
,
dname
),
uidNumber
,
gidNumber
)
for
momo
in
files
:
for
fname
in
files
:
os
.
chown
(
os
.
path
.
join
(
root
,
momo
),
uidNumber
,
gidNumber
)
os
.
chown
(
os
.
path
.
join
(
root
,
fname
),
uidNumber
,
gidNumber
)
def
cp_skel
(
skelroot
,
path
,
uidNumber
,
gidNumber
):
def
cp_skel
(
skelroot
,
path
,
uidNumber
,
gidNumber
):
if
skelroot
is
None
:
if
skelroot
is
None
:
...
@@ -75,8 +76,10 @@ def cp_skel(skelroot, path, uidNumber, gidNumber):
...
@@ -75,8 +76,10 @@ def cp_skel(skelroot, path, uidNumber, gidNumber):
skelpath
=
os
.
path
.
join
(
skelroot
,
'
common
'
,
'
skel
'
)
skelpath
=
os
.
path
.
join
(
skelroot
,
'
common
'
,
'
skel
'
)
if
os
.
path
.
isdir
(
skelpath
):
if
os
.
path
.
isdir
(
skelpath
):
# copy the skel into the user $HOME
# copy the skel into the user $HOME
os
.
system
(
"
/bin/cp -r %s/* %s
"
%
(
skelpath
,
path
))
# os.system("/bin/cp -r %s/* %s" % (skelpath, path))
os
.
system
(
"
/bin/cp %s/\.* %s
"
%
(
skelpath
,
path
))
subprocess
.
call
([
'
/bin/cp
'
,
'
-r
'
,
"
%s/*
"
%
skelpath
,
path
])
# os.system("/bin/cp %s/\.* %s" % (skelpath, path))
subprocess
.
call
([
'
/bin/cp
'
,
"
%s/.*
"
%
skelpath
,
path
])
# ideally use this, but it assumes 'path' does not exist
# ideally use this, but it assumes 'path' does not exist
# shutil.copytree(skelpath, path)
# shutil.copytree(skelpath, path)
# chown to user ownership
# chown to user ownership
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment