[gen_code.py] strip-trailing-ws
Ignore-this: 20199bd05d92bf9d4f2b2c396bce9ca2 darcs-hash:20090514155532-bd074-aa4f11eeaab255dff821dcf37878c35b9e277bd5.gz
This commit is contained in:
parent
35cc9fa3d3
commit
03955ca315
1 changed files with 7 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# -*- coding: iso8859-15 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# import des modules
|
# import des modules
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -13,7 +13,7 @@ rand.seed()
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from user_tests import getuser
|
from user_tests import getuser
|
||||||
|
|
||||||
# définition des exemptions
|
# définition des exemptions
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
class NoCodeError(Exception):
|
class NoCodeError(Exception):
|
||||||
|
@ -23,7 +23,7 @@ class NoCodeError(Exception):
|
||||||
|
|
||||||
def new_code(msg=''):
|
def new_code(msg=''):
|
||||||
"""
|
"""
|
||||||
Génération d'un nouveau code
|
Génération d'un nouveau code
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for i in range(1000):
|
for i in range(1000):
|
||||||
|
@ -35,7 +35,7 @@ def new_code(msg=''):
|
||||||
# Pas de code disponible
|
# Pas de code disponible
|
||||||
raise NoCodeError, 'Il n\'y a plus de code disponible'
|
raise NoCodeError, 'Il n\'y a plus de code disponible'
|
||||||
|
|
||||||
# On enregistre le fichier avec le code pour numéro
|
# On enregistre le fichier avec le code pour numéro
|
||||||
codefichier = open("/var/impression/codes/%d" % code, 'w')
|
codefichier = open("/var/impression/codes/%d" % code, 'w')
|
||||||
codefichier.write(msg+'\n')
|
codefichier.write(msg+'\n')
|
||||||
codefichier.close()
|
codefichier.close()
|
||||||
|
@ -44,5 +44,5 @@ def new_code(msg=''):
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# génère un nouveau code et l'affiche
|
# génère un nouveau code et l'affiche
|
||||||
print new_code('%s via %s'%(getuser(),os.path.abspath(__file__)))
|
print new_code('%s via %s'%(getuser(),os.path.abspath(__file__)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue