[lib] ajout des fichiers non suivis
darcs-hash:20090609134320-bd074-f4df3e57ff2a6e60f07e25cda773524c8e20de3c.gz
This commit is contained in:
parent
dce8ccb6da
commit
c2535c1f04
17 changed files with 2346 additions and 0 deletions
0
lib/scripts/__init__.py
Normal file
0
lib/scripts/__init__.py
Normal file
47
lib/scripts/autologout.py
Executable file
47
lib/scripts/autologout.py
Executable file
|
@ -0,0 +1,47 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import re, commands
|
||||
import crans.utils.logs
|
||||
import logging
|
||||
LOGGER = logging.getLogger("crans.autologout")
|
||||
LOGGER.addHandler(crans.utils.logs.CransFileHandler("autologout"))
|
||||
LOGGER.setLevel(logging.WARNING)
|
||||
|
||||
def run_autologout():
|
||||
LOGGER.debug("Starting autologout")
|
||||
# pour chaque ligne du w
|
||||
for w in commands.getoutput("w -h").split('\n') :
|
||||
if not w : continue
|
||||
# on splite
|
||||
w = w.split()
|
||||
|
||||
if w[0] in ['cohen','segaud']:
|
||||
continue
|
||||
|
||||
# on verifie que c'est une connection du bde
|
||||
hosts = ['bde.crans.org','cableur.crans.org','cableuse.crans.org','venus.crans.org']
|
||||
if w[2] not in [ h[0:16] for h in hosts ] :
|
||||
continue
|
||||
|
||||
# on verifie qu'on a depase le timeout
|
||||
if re.match('^\d*\.\d*s$', w[4]) or re.match('^[0-4]:\d*m$', w[4]) :
|
||||
continue
|
||||
|
||||
# on reccuperre les processus s le tty
|
||||
ps = commands.getoutput('ps auwwx | grep "%s" | head -n 1' % w[1] ).split()
|
||||
|
||||
# on verrifie que c'est le bon user
|
||||
if ps[0] != w[0] :
|
||||
continue
|
||||
|
||||
# on verifie qu'on a pas de tty
|
||||
if ps[6] != '?' :
|
||||
continue
|
||||
|
||||
# on tue le process
|
||||
commands.getoutput('kill %s' % ps[1] )
|
||||
LOGGER.info("%s a ete deconnecte" % ps[0])
|
||||
#print ps
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_autologout()
|
11
lib/scripts/helloworld.py
Normal file
11
lib/scripts/helloworld.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
import logging
|
||||
|
||||
from crans.utils.logs import getFileLogger
|
||||
#LOGGER = logging.getLogger("crans.scripts.test")
|
||||
LOGGER = getFileLogger("helloworld")
|
||||
LOGGER.setLevel(logging.INFO)
|
||||
LOGGER.addHandler(logging.StreamHandler())
|
||||
|
||||
if __name__ == "__main__":
|
||||
LOGGER.info(u"Hello World")
|
Loading…
Add table
Add a link
Reference in a new issue