Mise en forme.
darcs-hash:20060406030222-68412-0dbc2a0cc3d34c3e5de5ee2607f35ad0a5cf3fd7.gz
This commit is contained in:
parent
8d76992b10
commit
cd8bafd791
1 changed files with 26 additions and 20 deletions
|
@ -10,42 +10,48 @@ from affich_tools import cprint, anim, OK, WARNING, ERREUR
|
|||
import config
|
||||
from time import strftime
|
||||
|
||||
class del_user :
|
||||
class del_user:
|
||||
""" Suppression des fichiers d'un compte utilisateur """
|
||||
|
||||
debug = True
|
||||
def __init__(self,args) :
|
||||
self.args=args
|
||||
def reconfigure(self) :
|
||||
|
||||
def __init__(self,args):
|
||||
self.args = args
|
||||
|
||||
def reconfigure(self):
|
||||
cprint(u'Archivage fichiers utilisateur', 'gras')
|
||||
for args in self.args :
|
||||
for args in self.args:
|
||||
anim('\t' + args)
|
||||
try:
|
||||
login, home = args.split(',')
|
||||
if not login or not home :
|
||||
if not login or not home:
|
||||
raise ValueError('Argument invalide')
|
||||
warn = ''
|
||||
f = config.cimetiere + '/files/' + strftime('%Y-%m-%d-%Hh%Mm_') + login + '.tar.bz2'
|
||||
status, output = commands.getstatusoutput("tar cjf '%s' '%s' /var/spool/mail/%s" % ( f,home,login) )
|
||||
if ( status != 512 and status!=0 ) or not os.path.isfile(f) :
|
||||
f = '%s/files/%s_%s.tar.bz2' % (config.cimetiere,
|
||||
strftime('%Y-%m-%d-%Hh%Mm'),
|
||||
login)
|
||||
status, output = commands.getstatusoutput("tar cjf '%s' '%s' /var/spool/mail/%s" % (f, home, login))
|
||||
if (status != 512 and status != 0) or not os.path.isfile(f):
|
||||
# La 512 est si un des paths n'exite pas.
|
||||
raise OSError(output)
|
||||
if os.path.isdir(home) and os.stat(home)[4] >= 500 :
|
||||
if os.path.isdir(home) and os.stat(home)[4] >= 500:
|
||||
shutil.rmtree(home)
|
||||
else :
|
||||
else:
|
||||
warn += '%s incorrect\n' % home
|
||||
if os.path.isdir('/var/spool/mail/' + login ) :
|
||||
if os.path.isdir('/var/spool/mail/' + login):
|
||||
shutil.rmtree('/var/spool/mail/' + login)
|
||||
else :
|
||||
else:
|
||||
warn += '/var/spool/mail/%s incorrect\n' % login
|
||||
|
||||
if warn :
|
||||
if warn:
|
||||
print WARNING
|
||||
if self.debug :
|
||||
if self.debug:
|
||||
sys.stderr.write(warn)
|
||||
else :
|
||||
else:
|
||||
print OK
|
||||
except :
|
||||
except:
|
||||
print ERREUR
|
||||
if self.debug :
|
||||
if self.debug:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
|
@ -65,11 +71,11 @@ class home:
|
|||
os.mkdir(home, 0755)
|
||||
os.chown(home, int(uid) ,config.gid)
|
||||
elif os.path.isdir(home) :
|
||||
# Il y un r-bépertoire existant-A
|
||||
# Il y un répertoire existant
|
||||
# Bon UID ?
|
||||
stat = os.stat(home)
|
||||
if stat[4] != int(uid) or stat[5] != config.gid :
|
||||
# Le home n'est pas -bà la bonne personne-A
|
||||
# Le home n'est pas à la bonne personne
|
||||
raise OSError('home existant')
|
||||
|
||||
### Quota
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue