From cccf3d16e57ed35afa69cd43753bcff3799a4ff3 Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Fri, 13 Feb 2009 12:55:31 +0100 Subject: [PATCH] [gestion/{annaires,gest_crans}.py] stripping trailing whitespaces darcs-hash:20090213115531-bd074-5aa9ec236d4fc46bbadf3b4b9392c0e0dd73f5a1.gz --- gestion/annuaires.py | 112 +++++------ gestion/gest_crans.py | 452 +++++++++++++++++++++--------------------- 2 files changed, 282 insertions(+), 282 deletions(-) diff --git a/gestion/annuaires.py b/gestion/annuaires.py index c8cf1f2e..8331403e 100755 --- a/gestion/annuaires.py +++ b/gestion/annuaires.py @@ -5,7 +5,7 @@ bat_switchs = [ 'a' , 'b' , 'c' , 'h' , 'i' , 'j' , 'm' , 'p'] bat_manuels = [ 'o' , 'r' ] # Y en a plus aucun :) ou presque -aide={ +aide={ 'g' : "appart du RDC=G901" } @@ -48,14 +48,14 @@ chbre_prises={ 'a' : '605g':'205', '605d':'206', '606g':'207', '606d':'208', '607g':'209', '607d':'210', '601g':'211', '601d':'212', '602g':'213', '602d':'214', 'cl5':'215', 'cl4':'216', - 'cl3':'217', 'cl2':'218', '608g':'219', - + 'cl3':'217', 'cl2':'218', '608g':'219', + '603d':'301', '608d':'302', 'cl6':'303'}, # Le local club du 6ème et les chambres A608d, A603d sont sur la -# prise 202 (switch au 6ème dans le local technique à coté de +# prise 202 (switch au 6ème dans le local technique à coté de # l'ascensseur - + 'b' : {'cl0':'047' , 'cl1':'046' , '105':'001' , '106':'002' , '107':'003' , '108':'004' , @@ -71,18 +71,18 @@ chbre_prises={ 'a' : '117':'041' , '118':'042' , '119d':'043' , '119g':'044' , '220g':'101' , '220d':'102' , '221g':'103' , '221d':'104' , - '305':'105' , '306':'106' , '307':'107' , '308':'108' , + '305':'105' , '306':'106' , '307':'107' , '308':'108' , '320g':'109' , '320d':'110' , '321g':'111' , '321d':'112' , -'222g':'113' , '222d':'114' , '223':'115' , '224':'116' , - '309':'117' , '310':'118' , '311':'119' , '312':'120' , +'222g':'113' , '222d':'114' , '223':'115' , '224':'116' , + '309':'117' , '310':'118' , '311':'119' , '312':'120' , '322g':'121' , '322d':'122' , '323':'123' , '324':'124' , '201g':'125' , '201d':'126' , '202g':'127' , '202d':'128' , - '213':'129' , '214':'130' , '215':'131' , '216':'132' , + '213':'129' , '214':'130' , '215':'131' , '216':'132' , '301g':'133' , '301d':'134' , '302g':'135' , '302d':'136' , '203g':'137' , '203d':'138' , '204g':'139' , '204d':'140' , '217':'141' , '218':'142' , '219g':'143' , '219d':'144' , '303g':'145' , '303d':'146' , '304g':'147' , '304d':'148' , - + '405':'201' , '406':'202' , '407':'203' , '408':'204' , '420g':'205' , '420d':'206' , '421g':'207' , '421d':'208' , '505g':'209' , '505d':'210' , '506g':'211' , '506d':'212' , @@ -95,7 +95,7 @@ chbre_prises={ 'a' : '317':'237' , '318':'238' , '319g':'239' , '319d':'240' , '403g':'241' , '403d':'242' , '404g':'243' , '404d':'244' , '417':'245' , '418':'246' , '419g':'247' , '419d':'248' , - + '511g':'301' , '511d':'302' , '512g':'303' , '512d':'304' , '603g':'305' , '603d':'306' , '604g':'307' , '604d':'308' , '609g':'309' , '609d':'310' , '610g':'311' , '610d':'312' , @@ -109,7 +109,7 @@ chbre_prises={ 'a' : '509g':'341' , '509d':'342' , '510g':'343' , '510d':'344' , '601g':'345' , '601d':'346' , '602g':'347' , '602d':'348' } , -'c' : +'c' : {'312d':'001', '313g':'002' , '313d':'003' , '314':'004' , '315':'005' , '401g':'006' , '401d':'007' , '402g':'008' , '402d':'009' , '403g':'010' , '406g':'011' , '406d':'012' , @@ -124,18 +124,18 @@ chbre_prises={ 'a' : '310d':'045' , '310g':'046' , '309d':'047' , '309g':'048' , '103d':'101' , '111d':'102' , '103g':'103' , '111g':'104' , -'102d':'105' , '110d':'106' , '102g':'107' , '110g':'108' , +'102d':'105' , '110d':'106' , '102g':'107' , '110g':'108' , '101d':'109' , '109d':'110' , '101g':'111' , '109g':'112' , -'205d':'113' , '213d':'114' , '307g':'115' , '205g':'116' , -'213g':'117' , '306d':'118' , '204d':'119' , '212d':'120' , +'205d':'113' , '213d':'114' , '307g':'115' , '205g':'116' , +'213g':'117' , '306d':'118' , '204d':'119' , '212d':'120' , '306g':'121' , '204g':'122' , '212g':'123' , '305d':'124' , '203d':'125' , '211d':'126' , '305g':'127' , '203g':'128' , -'211g':'129' , '304d':'130' , '104g':'131' , '112g':'132' , +'211g':'129' , '304d':'130' , '104g':'131' , '112g':'132' , '206g':'133' , '214':'134' , '307d':'135' , '104d':'136' , '112d':'137' , '105g':'138' , '113g':'139' , '105d':'140' , '113d':'141' , '106g':'142' , '114':'143' , '106d':'144' , '115':'145' , '107g':'146' , '201g':'147' , '107d':'148' , - + '304g':'201' , '303d':'202' , '303g':'203' , '210d':'204' , '210g':'205' , '209d':'206' , '302d':'207' , '209g':'208' , '208d':'209' , '302g':'210' , '208g':'211' , '301d':'212' , @@ -176,7 +176,7 @@ chbre_prises={ 'a' : '238':'213' , '296':'214' , '241':'215' , '244':'216-' , '198':'217-', '199':'218-', '192':'219' , '239':'220' , '245':'221' , '303':'222' , '305':'223' , '191':'224' , - '237':'225' , 'XXX':'226' , 'XXX':'227' , '243':'228' , + '237':'225' , 'XXX':'226' , 'XXX':'227' , '243':'228' , 'XXX':'229' , 'XXX':'230' , '056':'231' , '004':'232' , 'XXX':'233' , '188':'234' , '007':'235' , '116':'236' , 'XXX':'237' , 'XXX':'238' , '240':'239' , 'XXX':'240' , @@ -189,7 +189,7 @@ chbre_prises={ 'a' : '203':'413' , '234':'414' , '224':'415' , '019':'416' , '041':'417' , '089':'418-', '037':'419' , '045':'420' , '099':'421' , '078':'422-', '904':'423' , '264':'424' , - '206':'425' , '235':'426-', '268':'427' , '269':'428' , + '206':'425' , '235':'426-', '268':'427' , '269':'428' , '229':'429' , '096':'430' , '272':'431' , '273':'432' , '274':'433' , '275':'434' , '277':'435' , '279':'436' , '281':'437' , '282':'438' , '217':'439' , '286':'440' , @@ -207,7 +207,7 @@ chbre_prises={ 'a' : '094':'533' , '026':'534' , '266':'535' , '081':'536' , '080':'537' , '148':'538' , '102':'539' , '030':'540' , '018':'541' , '110':'542' , '035':'543-', '093':'544' , - '159':'545' , '034':'546', '202':'402' , '230':'548' + '159':'545' , '034':'546', '202':'402' , '230':'548' } , 'h' : @@ -219,7 +219,7 @@ chbre_prises={ 'a' : '311g':'125' , '311d':'127' , '312':'129' , '313':'131' , '314':'133' , '315':'135' , '316':'137' , '317':'139' , '318':'141' , '319':'143' , - + '401g':'102' , '401d':'104' , '402g':'106' , '402d':'108' , '403g':'110' , '403d':'112' , '404g':'114' , '404d':'116' , '405g':'118' , '405d':'120' , '406g':'122' , '406d':'124' , @@ -237,14 +237,14 @@ chbre_prises={ 'a' : '004g':'206' , '004d':'048' , '005g':'145' , '005d':'147' , '006g':'146' , '006d':'148' , '007g':'202' , '007d':'204' , '008g':'205' , '008d':'203' , - + '201':'002' , '202':'004' , '203':'006' , '204':'008' , '205':'010' , '206':'012' , '207':'014' , '208':'016' , '209g':'018' , '209d':'020' , '210g':'022' , '210d':'024' , '211g':'026' , '211d':'028' , '212':'030' , '213':'032' , '214':'034' , '215':'036' , '216':'038' , '217':'040' , '218':'042' , '219':'044' } , - + 'i' : {'110d':'201' , '403g':'202' , '105g':'203' , '209g':'204' , '309g':'205' , '312':'206' , 'cl2':'207' , 'cl3':'208' , @@ -267,7 +267,7 @@ chbre_prises={ 'a' : '211g':'121' , '203':'122' , '210d':'119' , '202':'120' , '210g':'117' , '201':'118' , '209d':'115' , '219':'116' , '218':'113' , - + '315':'034' , '308':'035' , '314':'036' , '307':'037' , '313':'038' , '306':'040' , '305':'039' , '311d':'042' , '304':'009' , '311g':'010' , '303':'008' , '302':'006' , @@ -285,35 +285,35 @@ chbre_prises={ 'a' : {'002g':'001' , '102g':'002' , '108g':'003' , '212d':'004' , '002d':'005' , '102d':'006' , '108d':'007' , '213g':'008' , '003g':'009' , '103g':'010' , '109g':'011' , '213d':'012' , - '003d':'013' , '103d':'014' , '109d':'015' , '214':'016' , - '004g':'017' , '104g':'018' , '110g':'019' , '215':'020' , - '004d':'021' , '104d':'022' , '110d':'023' , '216':'024' , + '003d':'013' , '103d':'014' , '109d':'015' , '214':'016' , + '004g':'017' , '104g':'018' , '110g':'019' , '215':'020' , + '004d':'021' , '104d':'022' , '110d':'023' , '216':'024' , '005g':'025' , '105g':'026' , '111g':'027' , '217':'028' , - '005d':'029' , '105d':'030' , '111d':'031' , '218':'032' , - '106g':'033' , 'cl1':'034' , '112g':'035' , '219':'036' , - '106d':'037' , '211g':'038' , '112d':'039' , '220':'040' , - '107g':'041' , '211d':'042' , '101g':'043' , '221':'044' , + '005d':'029' , '105d':'030' , '111d':'031' , '218':'032' , + '106g':'033' , 'cl1':'034' , '112g':'035' , '219':'036' , + '106d':'037' , '211g':'038' , '112d':'039' , '220':'040' , + '107g':'041' , '211d':'042' , '101g':'043' , '221':'044' , '107d':'045' , '212g':'046' , '101d':'047' , '222':'048' , - - '311g':'101' , '309':'102' , '223':'103' , '320':'104' , - '311d':'105' , '310':'106' , '201':'107' , '321':'108' , - '312g':'109' , 'cl3':'110' , '202':'111' , '322':'112' , + + '311g':'101' , '309':'102' , '223':'103' , '320':'104' , + '311d':'105' , '310':'106' , '201':'107' , '321':'108' , + '312g':'109' , 'cl3':'110' , '202':'111' , '322':'112' , '312d':'113' , '406g':'114' , '203':'115' , '323':'116' , '313g':'117' , '406d':'118' , '204':'119' , '301':'120' , - '313d':'121' , '407g':'122' , '205':'123' , '302':'124' , - '314':'125' , '407d':'126' , '206':'127' , '303':'128' , - '315':'129' , '408g':'130' , '207':'131' , '304':'132' , - '316':'133' , '408d':'134' , '208':'135' , '305':'136' , - '317':'137' , '409g':'138' , '209':'139' , '306':'140' , - '318':'141' , '409d':'142' , '210':'143' , '307':'144' , + '313d':'121' , '407g':'122' , '205':'123' , '302':'124' , + '314':'125' , '407d':'126' , '206':'127' , '303':'128' , + '315':'129' , '408g':'130' , '207':'131' , '304':'132' , + '316':'133' , '408d':'134' , '208':'135' , '305':'136' , + '317':'137' , '409g':'138' , '209':'139' , '306':'140' , + '318':'141' , '409d':'142' , '210':'143' , '307':'144' , '319':'145' , '410g':'146' , 'cl2':'147' , '308':'148' , '410d':'201' , '403d':'202' , '411g':'203' , '404g':'204' , - '411d':'205' , '404d':'206' , '412g':'207' , '405g':'208' , - '412d':'209' , '405d':'210' , '413g':'211' , 'XXX':'212' , - '413d':'213' , 'cl0':'214' , '401g':'215' , 'XXX':'216' , - '401d':'217' , 'XXX':'218' , '402g':'219' , 'XXX':'220' , - '402d':'221' , 'XXX':'222' , '403g':'223' } , + '411d':'205' , '404d':'206' , '412g':'207' , '405g':'208' , + '412d':'209' , '405d':'210' , '413g':'211' , 'XXX':'212' , + '413d':'213' , 'cl0':'214' , '401g':'215' , 'XXX':'216' , + '401d':'217' , 'XXX':'218' , '402g':'219' , 'XXX':'220' , + '402d':'221' , 'XXX':'222' , '403g':'223' } , 'm' : {'413':'001' , '429':'002' , '513':'003' , '414':'004' , @@ -348,12 +348,12 @@ chbre_prises={ 'a' : '120':'213' , '204':'214' , '219':'215' , '121':'216' , '205':'217' , '220':'218' , '122':'219' , '206':'220' , '221':'221' , '123':'222' , '206b':'223', '222':'224' , - '124':'225' , '207':'226' , '223':'227' , '125':'228' , + '124':'225' , '207':'226' , '223':'227' , '125':'228' , '208':'229' , '224':'230' , '126':'231' , '209':'232' , '225':'233' , '127':'234' , '210':'235' , '226':'236' , '128':'237' , '211':'238' , '227':'239' , '129':'240' , '212':'241' , '228':'242' , '130':'243' , '213':'244' , - '229':'245' , '131':'246' , '214':'247' , '230':'248' , + '229':'245' , '131':'246' , '214':'247' , '230':'248' , '133':'301' , '148':'302' , '164':'303' , '134':'304' , '149':'305' , '165':'306' , '135':'307' , '150':'308' , @@ -374,7 +374,7 @@ chbre_prises={ 'a' : '247':'413' , '263':'414' , '342':'415' , '248':'416' , '264':'417' , '343':'418' , '249':'419' , '265':'420' , '344':'421' , '250':'422' , '266':'423' , '345':'424' , - '251':'425' , '267':'426' , '346':'427' , '252':'428' , + '251':'425' , '267':'426' , '346':'427' , '252':'428' , '268':'429' , '347':'430' , '253':'431' , '333':'432' , '348':'433' , '254':'434' , '334':'435' , '349':'436' , '255':'437' , '335':'438' , '350':'439' , '256':'440' , @@ -486,7 +486,7 @@ uplink_prises={ 'a' : { 49 : 'uplink->backbone', 50 : 'uplink->batc-1', 149 : 'uplink->batc-0', 150 : 'uplink->batc-2', 225 : 'uplink->batc-1' }, -'g' : +'g' : { 49 : 'uplink->backbone', 50 : 'uplink->batg-1', 149 : 'uplink->batg-0', 150 : 'uplink->batg-2', 249 : 'uplink->batg-1', 250 : 'uplink->batg-4', @@ -496,7 +496,7 @@ uplink_prises={ 'a' : { 49 : 'uplink->backbone', 50 : 'uplink->bath-1', 149 : 'uplink->bath-0', 150 : 'uplink->bath-2', 225 : 'uplink->bath-1' }, -'i' : +'i' : { 49 : 'uplink->backbone', 50 : 'uplink->bati-1', 149 : 'uplink->bati-0', 150 : 'uplink->bati-2', 225 : 'uplink->bati-1', 226 : 'libre-service' }, @@ -557,27 +557,27 @@ def all_switchs(bat=None): switchs.sort(cmp) return switchs -# Locaux clubs : lecture dans chbre_prises et ajout des locaux dans les bats non +# Locaux clubs : lecture dans chbre_prises et ajout des locaux dans les bats non # manageables def locaux_clubs() : """ Retourne le dictionaire des locaux club : {bat: [locaux]} """ # Corespondance chbre -> nom du local club locaux_clubs = { 'Bcl0' : 'Kfet' , - 'Bcl1' : 'Med', + 'Bcl1' : 'Med', 'Pcl0' : 'Bds' , 'Mcl0' : 'Shape', 'Mcl1' : 'Krobot', 'EXT' : 'EXT' } # Ajout des locaux d'étage A, B et C - for b in 'ABC' : + for b in 'ABC' : for i in range(2,7) : locaux_clubs['%scl%i' % ( b, i)] = '%i@%s' % (i, b) # Ajout de ceux des H, I et J - for b in 'HIJ' : + for b in 'HIJ' : for i in range(1,5) : locaux_clubs['%scl%i' % ( b, i)] = '%i@%s' % (i, b) # Supression du 2@B et 4@J locaux_clubs.pop('Bcl2') locaux_clubs.pop('Jcl4') - + return locaux_clubs diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 1c1d0e34..405ef1e4 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -72,7 +72,7 @@ def set_bases(adher): * Téléphone * Chambre """ - + # Construction de la boite de dialogue arg = u'--title "Inscription adhérent" ' arg += u'--form "" 0 0 0 ' @@ -82,11 +82,11 @@ def set_bases(adher): arg += u'"Chambre :" 4 1 "%s" 4 11 05 00 ' % adher.chbre() arg += u'"(bat+numéro)" 4 17 "" 0 0 0 0 ' arg += u'"EXT pour chambre extérieure au campus" 5 1 "" 0 0 0 0 ' - + # Affichage annul, result = dialog(arg) if annul: return 1 - + # Traitement err = '' try: adher.nom(result[0]) @@ -97,9 +97,9 @@ def set_bases(adher): try: adher.tel(result[2]) except ValueError, c: err += c.args[0] + '\n' - + err += _set_chbre(adher, result[3]) - + # Des erreurs ? if err: arg = u'--title "Inscription adhérent" ' @@ -107,13 +107,13 @@ def set_bases(adher): dialog(arg) # On redemande return set_bases(adher) - + if adher.chbre() == 'EXT': # Il faut demander l'adresse extérieure - if set_addr_ext(adher): + if set_addr_ext(adher): # Annulation return set_bases(adher) - + def _set_chbre(adher, chbre): """ Attribution de la chambre chbre à l'adhérent fourni Retourne une chaine (unicode) avec l'erreur éventuelle @@ -121,10 +121,10 @@ def _set_chbre(adher, chbre): if chbre == '????': # Réservé à un usage interne return u'Chambre invalide\n' - + try: c = adher.chbre(chbre) except EnvironmentError, c: return c.args[0] + '\n' - except ValueError, c: + except ValueError, c: if len(c.args) == 2: # La chambre est occup-Aée-b squatteur = c.args[1] @@ -137,13 +137,13 @@ def _set_chbre(adher, chbre): squatteur.chbre('????') squatteur.save() # On recommence, le géneur doit être parti. - return _set_chbre(adher, chbre) + return _set_chbre(adher, chbre) return c.args[0] + '\n' - + return u'' - + def set_addr_ext(adher): - """ Définition de l'adresse extérieure d'un adhérent + """ Définition de l'adresse extérieure d'un adhérent La chambre de cet adhérent doit être EXT, sinon erreur """ arg = u'--title "Adresse extérieure de %s" ' % adher.Nom() arg += u'--form "" 0 0 0 ' @@ -154,7 +154,7 @@ def set_addr_ext(adher): # Affichage annul, result = dialog(arg) if annul: return 1 - + try: adher.adresse(result) except ValueError, c: arg = u'--title "Adresse extérieure de %s" ' % adher.Nom() @@ -162,9 +162,9 @@ def set_addr_ext(adher): dialog(arg) # On redemande return set_addr_ext(adher) - + def set_etudes(adher): - """ + """ Définition des études en 3 questions : * établissement * année administrative @@ -198,10 +198,10 @@ def set_etudes(adher): arg += u'"IUFM" "" ' if not adher.etudes(0): arg += u'"Autre" ""' - + annul, result = dialog(arg) if annul: return 1 - + if result[0] == 'Autre': arg = u'--title "Etudes de %s (1/3)" ' % adher.Nom() arg += u'--inputbox "Précisez l\'établissement d\'études" 0 0 "%s"' % adher.etudes(0) @@ -213,9 +213,9 @@ def set_etudes(adher): arg += u'--msgbox "Réponse invalide\n\n\n" 0 0' dialog(arg) return __etudes_etab() - + etudes[0] = result[0] - + def __etudes_annee(): arg = u'--title "Etudes de %s (2/3)" ' % adher.Nom() if etudes[0] == 'ENS': @@ -247,7 +247,7 @@ def set_etudes(adher): if annul: return 1 else: result = ['Autre'] - + if result[0] == 'Autre': arg = u'--title "Etudes de %s (2/3)" ' % adher.Nom() arg += u'--inputbox "Année adminstrative :\nET UNIQUEMENT l\'ANNEE : la section sera demandée après." 0 0 "%s"' % adher.etudes(1) @@ -264,7 +264,7 @@ def set_etudes(adher): def __etudes_section(): arg = u'--title "Etudes de %s (3/3)" ' % adher.Nom() - + # Pour l'ENS if etudes[0] == 'ENS': arg += u'--default-item "%s" ' % adher.etudes(2) @@ -274,7 +274,7 @@ def set_etudes(adher): arg += u'--menu "Choisissez le laboratoire :" 0 0 0 ' if not etudes[1] in '1234': arg += u'"CMLA" "Centre de Mathématiques et de Leurs Applications" ' - arg += u'"GAPP" "Groupe d\'Analyse des Politiques Publiques" ' + arg += u'"GAPP" "Groupe d\'Analyse des Politiques Publiques" ' arg += u'"IDHE" "Institutions et Dynamiques Historiques de l\'Economie" ' arg += u'"LBPA" "Laboratoire de Biotechnologies et Pharmacologie génétique Appliquées" ' arg += u'"LMT" "Laboratoire de Mécanique et Technologie" ' @@ -308,7 +308,7 @@ def set_etudes(adher): arg += u'"D2" "Economie gestion" ' arg += u'"D3" "Sciences sociales" ' arg += u'"E" "Anglais" ' - + arg += u'"Autre" ""' annul, result = dialog(arg) if annul: return 1 @@ -318,7 +318,7 @@ def set_etudes(adher): arg += u'--msgbox "Réponse invalide\n\n\n" 0 0' dialog(arg) return __etudes_annee() - + else: result = ['Autre'] @@ -333,11 +333,11 @@ def set_etudes(adher): arg += u'--msgbox "Réponse invalide\n\n\n" 0 0' dialog(arg) return __etudes_section() - + etudes[2] = result[0] etudes = ['', '', ''] - + step = 1 while 1: if step == 1: @@ -347,12 +347,12 @@ def set_etudes(adher): if __etudes_annee(): step -= 1 else: step += 1 if step == 3: - if __etudes_section(): step -= 1 + if __etudes_section(): step -= 1 else: break - - try: + + try: adher.etudes(etudes) - except ValueError, c: + except ValueError, c: arg = u'--title "Etudes de %s" ' % adher.Nom() arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) @@ -383,10 +383,10 @@ def set_mail(adher): arg += u'"Laisser le compte crans" "(login : %s)"' % adher.compte() else: arg += u'"Créer un compte crans" "(adresse @crans.org)"' - + annul, result = dialog(arg) if annul: return 1 - + if result[0].split()[0] == 'Laisser': break elif result[0].split()[0] == 'Créer': @@ -402,14 +402,14 @@ def set_mail_ext(adher): if default.find('@') == -1: # C'était une adresse crans default = '' - + arg = u'--title "Adresse mail extérieure pour %s" ' % adher.Nom() arg += u'--inputbox "Adresse : " 0 0 "%s"' % default annul, result = dialog(arg) if annul: return 1 try: adher.mail(result[0]) - except ValueError, c: + except ValueError, c: arg = u'--title "Adresse mail extérieure de %s" ' % adher.Nom() arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) @@ -424,25 +424,25 @@ def set_etat_civil(adher): arg += u'--msgbox "Vous n\'avez pas les droits necessaires pour effectuer cette opération.\n\n\n" 0 0' dialog(arg) return - + # Construction de la boite de dialogue arg = u'--title "État-civil de %s" ' % adher.Nom() arg += u'--form "" 0 0 0 ' arg += u'"Nom :" 1 1 "%s" 1 13 20 20 ' % adher.nom() arg += u'"Prénom :" 2 1 "%s" 2 13 20 20 ' % adher.prenom() - + # Affichage annul, result = dialog(arg) if annul: return - + # Traitement err = '' try: adher.nom(result[0]) except ValueError, c: err += c.args[0] + '\n' - + try: adher.prenom(result[1]) except ValueError, c: err += c.args[0] + '\n' - + # Des erreurs ? if err: arg = u'--title "État-civil de %s" ' % adher.Nom() @@ -450,7 +450,7 @@ def set_etat_civil(adher): dialog(arg) # On redemande return set_etat_civil(adher) - + # On change éventuellement le compte if adher.compte(): # On demande au câbleur s'il faut garder le compte ou pas @@ -463,7 +463,7 @@ def set_etat_civil(adher): arg += u'et donc de tous les fichiers, mails, etc. associés !\Z0\ZR\n\n\n" ' arg += u'0 0' no = not dialog(arg)[0] - + if no: # L'utilisateur n'utilise pas son compte, on le supprime... adher.supprimer_compte() @@ -477,7 +477,7 @@ def set_compte(adher): """ Créé un compte sur vert pour un adhérent. """ - + # Message d'avertissement arg = u'--title "Création compte crans pour %s" ' % adher.Nom() arg += u'--colors --yesno "\Zr\Z1AVERTISSEMENT :\Zn \n' @@ -485,21 +485,21 @@ def set_compte(adher): arg += u'0 0' no, res = dialog(arg) if no: return 1 - + # Il faut déterminer le login login = adher.nom() - + # Première tentative err = 0 try: login = adher.compte(login) except ValueError, c: - try: + try: c.args[1] # Le compte existe => 2ème tentative (1ere lettre prénom + nom) login = adher.prenom()[0] +login login = login.lower() err = 2 - except: + except: err = 1 except EnvironmentError, c: err = 1 # Locké @@ -515,7 +515,7 @@ def set_compte(adher): annul, result = dialog(arg) if annul: return 1 login = result[0] - + e = 0 try: login = adher.compte(login) except EnvironmentError, c: e = c.args[0] @@ -529,32 +529,32 @@ def set_compte(adher): txt = u"Le compte ne sera créé que lors de l'enregistrement des données\n\n" txt += u"L'adresse mail de l'adhérent est : %s@crans.org\n" % login - + a = adher.canonical_alias() if a: txt += u"L'adhérent possède également l'alias : %s@crans.org" % a else: txt += u"\n\Zr\Z1L'adresse mail %s.%s@crans.org étant déja prise l'adhérent ne peut pas l'utiliser.\Zn" % (adher.prenom(), adher.nom()) - + txt += u'\n' - + arg = u'--title "Création compte crans pour %s" ' % adher.Nom() arg += u'--colors --msgbox "%s\n\n\n" 0 0' % txt dialog(arg) - + def set_droits(adher): """ Définition des droits de l'adhérent """ arg = u'--title "Droits de %s" ' % adher.Nom() arg += u'--separate-output ' arg += u'--checklist "" 0 0 0 ' - + droits = adher.droits() for key in droits_possibles: actif = key in droits if actif: actif = u'on' - if isadm or key not in droits_critiques: + if isadm or key not in droits_critiques: arg += u'"%s" " " "%s" ' % (key, actif) - + annul, result = dialog(arg) if annul: return 1 @@ -568,7 +568,7 @@ def set_droits(adher): adher.droits_light(result) else: adher.droits(result) - + def del_adher(adher): """ Destruction adhérent @@ -606,7 +606,7 @@ def del_adher(adher): arg += u'--msgbox "Machines détruites\n\n\n" 0 0' dialog(arg) return - + while 1: arg = u'--title "Destruction adhérent %s " --colors ' % adher.Nom() arg += u'--inputbox "\Zr\Z1ATTENTION\Zn : la destruction est définitive\n\n%s.\n\nCommentaire à insérer ?" 0 0' % quoi @@ -616,15 +616,15 @@ def del_adher(adher): arg = u'--title "Destruction adherent" ' arg += u'--msgbox "Le commentaire est obligatoire\n\n\n" 0 0' dialog(arg) - + if u'Nounou' in adher.droits() and not isadm: arg = u'--title "Destruction adherent" ' arg += u'--msgbox "Vous n\'avez pas les droits necessaires pour effectuer cette opération.\n\n\n" 0 0' dialog(arg) return - + adher.delete(res[0]) - + arg = u'--title "Destruction adhérent" ' arg += u'--msgbox "Adhérent détruit\n\n\n" 0 0' dialog(arg) @@ -677,7 +677,7 @@ def set_imprimeurs(club): print 'Choix invalide' continue if choix: break - + if not choix: continue @@ -714,20 +714,20 @@ def set_club_nom(club): annul, res = dialog(arg) if annul: return 1 else: - try: + try: club.Nom(res[0]) except ValueError, c: arg = u'--title "Nom club" ' arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) - + def set_local(club): """ Défini le local d'un club """ try: club.chbre('&é"') # Fait une erreur except ValueError, c: locaux = c.args[1] - + arg = u'--title "Local du club" ' arg += u'--default-item "%s" ' % club.chbre() arg += u'--menu "Choisissez le local du club :" 0 0 0 ' @@ -740,15 +740,15 @@ def set_local(club): arg += u'"%s" "%s" ' % (k, locaux[k]) annul, result = dialog(arg) if annul: return 1 - else: + else: club.chbre(result[0]) - + def set_club_compte(club): """ Créé un compte sur vert pour un club. """ - + while 1: arg = u'--title "Création d\'un compte crans pour %s" ' % club.Nom() arg += u'--inputbox "Choix du login\n' @@ -760,7 +760,7 @@ def set_club_compte(club): annul, result = dialog(arg) if annul: return 1 login = result[0] - + e = 0 try: login = club.compte(login) except EnvironmentError, c: e = c.args[0] @@ -774,9 +774,9 @@ def set_club_compte(club): txt = u"Le compte ne sera créé que lors de l'enregistrement des données\n\n" txt += u"L'adresse mail du club est : %s@crans.org\n" % login - + txt += u'\n' - + arg = u'--title "Création compte crans pour %s" ' % club.Nom() arg += u'--colors --msgbox "%s\n\n\n" 0 0' % txt dialog(arg) @@ -788,20 +788,20 @@ def set_club_compte(club): def set_rque(clas): """Définit le commentaire (méthode info de clas)""" return __prompt_input_menu(clas.info, u'Remarque', u"Ajouter ou modifier une remarque\nPour ajouter une remarque modifier la dernière de la liste.") - + def __prompt_input_menu(method, titre, prompt): arg = u'--title "%s" ' % titre arg += u'--extra-label "Ajout/modif" ' arg += u'--inputmenu "%s\nPour supprimer, laisser le champ vide." 0 100 7 ' % prompt invite = '##nouveau##' - + i = 1 for item in method(): if item == '': continue arg += u'"%d" "%s" '% (i, item) i += 1 arg += '"%d" "%s" '% (i, invite) - + annul, result = dialog(arg) if annul: return 1 @@ -811,22 +811,22 @@ def __prompt_input_menu(method, titre, prompt): if result[0] != 'RENAMED': # Pas de modif return - + # maintenant result = ['RENAMED', 'X', 'nouvelle remarque'] num = int(result[1]) val = result[2].strip() - + if val == invite: # Rien à faire return - - try: + + try: if num == i: # Nouvelle valeur if val: method(val) - else: + else: method([num-1, val]) - + except ValueError, c: arg = u'--title "%s" ' % titre arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] @@ -834,7 +834,7 @@ def __prompt_input_menu(method, titre, prompt): return __prompt_input_menu(method, titre, prompt) else: return __prompt_input_menu(method, titre, prompt) - + def set_solde(clas): """ Débit ou crédit d'un compte """ while 1: @@ -842,19 +842,19 @@ def set_solde(clas): arg += u'--inputbox "Solde actuel : %s\n Opération à effectuer (+ pour crédits et - pour débit) ?" 0 0 "" ' % clas.solde() annul, res = dialog(arg) if annul: return 1 - + # Ajout du commentaire arg = u'--title "Crédit / débit du compte de %s" ' % clas.Nom() arg += u'--inputbox "Commentaire à insérer ?" 0 0' annul, comment = dialog(arg) - + if not annul: if comment[0]: comment = comment[0] else: comment = None - - try: + + try: clas.solde(res[0], comment) db.services_to_restart('mail_solde', ['%s a fait %s euros pour %s [%s]' %(script_utilisateur, res[0],clas._data['uid'][0], comment)]) break @@ -862,9 +862,9 @@ def set_solde(clas): arg = u'--title "Opération impossible" ' arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) - + def confirm(clas): - """ Demande confirmation avant enregistrement""" + """ Demande confirmation avant enregistrement""" # On va faire en texte, les couleurs ne passent pas en curses os.system('clear') aff(clas) @@ -881,10 +881,10 @@ def confirm(clas): arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) return 1 - + print res affich_tools.prompt(u"Appuyez sur ENTREE pour continuer") - + def set_blackliste(clas): """ Édite ou ajoute un item de la blackliste """ bl = clas.blacklist() @@ -903,7 +903,7 @@ def set_blackliste(clas): annul, res = dialog(arg) if annul: return 1 index = int(res[0]) - 1 - + # Édition if index != -1: t = clas.blacklist()[index].split('$') @@ -913,7 +913,7 @@ def set_blackliste(clas): t[1] = strftime('%d/%m/%Y %H:%M', localtime(int(t[1]))) else: t = ['now', '-', '', ''] - + step = 1 while 1: if step == 1: @@ -927,7 +927,7 @@ def set_blackliste(clas): if annul: return 1 t[2] = res[0] step += 1 - + if step == 2: # Dates + commentaire arg = u'--title "Blacklistage %s" ' % clas.Nom() @@ -941,7 +941,7 @@ def set_blackliste(clas): arg += u'"Commentaire (pas de dollar) : " 5 1 "%s" 6 1 52 0 ' % t[3] annul, r = dialog(arg) if annul: return 1 - + # Ajout des heures t[0] = r[0].strip() if len(t[0]) == 10: t[0] += ' 00:00' @@ -958,7 +958,7 @@ def set_blackliste(clas): dialog(arg) step -= 1 continue - + try: if t[1] != 'now' and t[1] != '-': t[1] = int(mktime(strptime(t[1], '%d/%m/%Y %H:%M'))) @@ -979,19 +979,19 @@ def set_blackliste(clas): t[3] = c else: t[3] = login - - try: + + try: if index == -1: clas.blacklist(t) else: clas.blacklist((index, t)) step += 1 - except ValueError, c: + except ValueError, c: arg = u'--title "Erreur" ' arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) step -= 1 - + if step == 3: if confirm(clas): step -= 1 else: break @@ -1027,7 +1027,7 @@ def set_admin(proprio): """ # Le proprietaire a-t-il une section carte d'étudiant (pas les clubs) ? has_card = proprio.idn != 'cid' - + # Initialisation des différentes checkbox carte = on_off(ann_scol in proprio.carteEtudiant()) paiement = on_off(ann_scol in proprio.paiement()) @@ -1036,11 +1036,11 @@ def set_admin(proprio): paiement_ok = on_off('p' in proprio.controle()) carte_ok = on_off('c' in proprio.controle()) if has_card: charte_MA = on_off(proprio.charteMA()) - + # Construction de la boîte de dialogue texte = [] checklist = [] - + if has_card: if carte_ok == 'off' or iscontroleur: checklist.append(u'"1" "Carte d\'étudiant %d/%d fournie" "%s"' % @@ -1056,12 +1056,12 @@ def set_admin(proprio): texte.append(u'Cotisation/charte vérifiées') else: texte.append(u'Adhérent non payant') - + # TODO: controle pour le précâblage if config.precab: checklist.append(u'"3" "Adhésion %d/%d réglée et charte signée (précâblage)" "%s"' % (ann_scol+1, ann_scol+2, precab)) - + if iscontroleur: if has_card: checklist.append(u'"4" "Carte d\'étudiant vérifiée" "%s"' % carte_ok) @@ -1075,17 +1075,17 @@ def set_admin(proprio): dialog(u'--title "État administratif de %s non modifiable" --msgbox "%s\n" 0 0 ' % (proprio.Nom(), '\n'.join(texte))) return - - + + # Il y a qqch de modifiable, on construit la checklist arg = u'--title "Etat administratif de %s" ' % proprio.Nom() arg += u'--separate-output ' arg += u'--checklist "%s\n" 0 0 0 ' % '\n'.join(texte) arg += u' '.join(checklist) - + annul, result = dialog(arg) if annul: return 1 - + # Traitement if has_card: if '1\n' in result: @@ -1095,7 +1095,7 @@ def set_admin(proprio): if '4\n' in result: proprio.controle('+c') elif iscontroleur: - proprio.controle('-c') + proprio.controle('-c') if '2\n' in result and ann_scol not in proprio.paiement(): # On est en train de renouveller l'adhésion @@ -1147,24 +1147,24 @@ def set_admin(proprio): ## Fonctions de remplissage ou modification des paramètres club def new_club(club): - step = 1 + step = 1 while 1: - + if step == 1: # Responsable if set_responsable(club): return 1 else: step += 1 - + if step == 2: # Nom du club if set_club_nom(club): step -= 1 else: step += 1 - + if step == 3: # Local if set_local(club): step -= 1 else: step += 1 - + if step == 4: # Administratif if set_admin(club): step -= 1 @@ -1181,7 +1181,7 @@ def new_club(club): else: break def modif_club(club): - """ + """ Modification du club fourni (instance de club) Retourne 1 si annulation. """ @@ -1202,9 +1202,9 @@ def modif_club(club): arg += u'"Remarque" "Ajouter ou modifer un commentaire" ' annul, res = dialog(arg) - + if annul: return 1 - + elif res[0] == 'NomClub': set_club_nom(club) elif res[0] == 'Responsable': @@ -1225,25 +1225,25 @@ def modif_club(club): __prompt_input_menu(club.alias, 'Alias mail', "Entrez ou modifier un alias mail.\nPour ajouter un alias modifier le dernier de la liste.") elif res[0] == 'Solde': set_solde(club) - + if club.modifs: return confirm(club) def select_club(clas): """ Choix d'un club """ arg = u'--title "Recherche d\'un club" ' - + clubs = clas.search('cid=*')['club'] if not clubs: # Pas de club dans la base arg += '--msgbox "Il n\'y a pas de clubs inscrits dans la base\n\n\n" 0 0 ' dialog(arg) - return + return arg += u'--menu "Choisissez un club :" 0 0 0 ' for club in clubs: arg += '"%s" "%s" ' % (club.id(), club.Nom()) annul, res = dialog(arg) - if annul: return + if annul: return return clas.search('cid=%s' % res[0], 'w')['club'][0] def del_club(club): @@ -1258,7 +1258,7 @@ def del_club(club): arg = u'--title "Destruction club" ' arg += u'--msgbox "Le commentaire est obligatoire\n\n\n" 0 0' dialog(arg) - + club.delete(res[0]) arg = u'--title "Destruction club" ' arg += u'--msgbox "Club détruit\n\n\n" 0 0' @@ -1268,7 +1268,7 @@ def del_club(club): ## Fonctions de remplissage ou modification des paramètres machine def set_wifi(machine): - """ + """ Définition des paramètres spécifiques d'une borne wifi : * Canaux * Puissance @@ -1283,9 +1283,9 @@ def set_wifi(machine): dialog(arg) # On redemande return 1 - + nom = machine.nom() - + # Construction de la boite de dialogue arg = u'--title "Paramètres spécifiques wifi de "%s"" ' % (nom) arg += u'--form "" 0 0 0 ' @@ -1299,7 +1299,7 @@ def set_wifi(machine): arg += u'"Position N :" 3 1 "%s" 3 14 12 0 ' % "" arg += u'"Position E :" 3 29 "%s" 3 42 12 0 ' % "" - arg += u'"Hotspot :" 4 1 "%s" 4 10 5 0 ' % (machine.hotspot() and 'oui' or 'non') + arg += u'"Hotspot :" 4 1 "%s" 4 10 5 0 ' % (machine.hotspot() and 'oui' or 'non') arg += u'"Nvram (cf wiki) :" 5 1 "%s" 6 1 100 0 ' % ', '.join(machine.nvram()) # Affichage @@ -1313,7 +1313,7 @@ def set_wifi(machine): try: machine.puissance(result[1]) except ValueError, c: err += c.args[0] + '\n' - + try: #On n'enregistre pas une position vide if result[2].strip() and result[3].strip(): @@ -1322,14 +1322,14 @@ def set_wifi(machine): else: machine.position((result[2].strip(),result[3].strip())) except ValueError, c: err += c.args[0] + '\n' - + if result[4].lower().strip() == "oui": machine.hotspot(True) elif result[4].lower().strip() == "non": machine.hotspot(False) else: err += "Les valeurs possibles pour le parametre hotspot\n sont \"oui\" ou \"non\"\n" - + try: #On vérifie toutes les variables avant de sauvegarder for nvram in result[5].split(','): @@ -1351,12 +1351,12 @@ def set_wifi(machine): dialog(arg) # On redemande return set_wifi(machine) - + if machine.modifs and confirm(machine): return set_wifi(machine) def set_machine(machine): - """ + """ Définition des paramètres d'une machine : * Nom de machine * Adresse MAC @@ -1375,7 +1375,7 @@ def set_machine(machine): else: nom = machine.nom().split('.')[0] l = 17 - + # Construction de la boite de dialogue arg = u'--title "Paramètres machine" ' arg += u'--form "" 0 0 0 ' @@ -1387,7 +1387,7 @@ def set_machine(machine): arg += u'"PortsTCP machine->ext :" 5 1 "%s" 5 25 50 0 ' % ' '.join(machine.portTCPout()) arg += u'"PortsUDP ext->machine :" 6 1 "%s" 6 25 50 0 ' % ' '.join(machine.portUDPin()) arg += u'"PortsUDP machine->ext :" 7 1 "%s" 7 25 50 0 ' % ' '.join(machine.portUDPout()) - if isadm and machine.proprietaire().__class__ == AssociationCrans: + if isadm and machine.proprietaire().__class__ == AssociationCrans: arg += u'"Prise :" 8 1 "%s" 8 9 5 0 ' % machine.prise() else: @@ -1402,9 +1402,9 @@ def set_machine(machine): try: machine.nom(result[0]) except ValueError, c: err += c.args[0] + '\n' except EnvironmentError, c: err += c.args[0] + '\n' - + try: machine.mac(result[1]) - except ValueError, c: + except ValueError, c: if len(c.args)>1 and c.args[1] == 1 and isadm: # Mac en double arg = u'--title "Adresse MAC" ' @@ -1429,14 +1429,14 @@ def set_machine(machine): except EnvironmentError, c: err += c.args[0] + '\n' else: err += c.args[0] + '\n' - + except EnvironmentError, c: err += c.args[0] + '\n' - + try: machine.ip(result[2]) except ValueError, c: err += c.args[0] + '\n' except EnvironmentError, c: err += c.args[0] + '\n' except RuntimeError, c: err += c.args[0] + '\n' # Plus d'IP libres, peut-être à traiter differement ? - + if isadm: try: machine.portTCPin(result[3].split()) @@ -1444,11 +1444,11 @@ def set_machine(machine): machine.portUDPin(result[5].split()) machine.portUDPout(result[6].split()) except ValueError, c: err += c.args[0] + '\n' - - if isadm and machine.proprietaire().__class__ == AssociationCrans: + + if isadm and machine.proprietaire().__class__ == AssociationCrans: try: machine.prise(result[-1]) except ValueError, c: err += c.args[0] + '\n' - + # Des erreurs ? if err: arg = u'--title "Paramètres machine" ' @@ -1456,7 +1456,7 @@ def set_machine(machine): dialog(arg) # On redemande return set_machine(machine) - + if machine.modifs and confirm(machine): return set_machine(machine) @@ -1471,13 +1471,13 @@ def set_machine_alias(machine): if __prompt_input_menu(machine.alias, 'Alias machine', "Entrez ou modifier un alias machine.\nPour ajouter un alias modifier le dernier de la liste.") or confirm(machine): machine.restore() return 1 - + def del_machine(machine): """ Destruction machine """ while 1: - arg = u'--title "Destruction machine %s" --colors ' % machine.nom() + arg = u'--title "Destruction machine %s" --colors ' % machine.nom() arg += u'--inputbox "\Zr\Z1ATTENTION\Zn : la destruction est définitive\nCommentaire à insérer ?" 0 0' annul, res = dialog(arg) if annul: return 1 @@ -1485,20 +1485,20 @@ def del_machine(machine): arg = u'--title "Destruction machine" ' arg += u'--msgbox "Le commentaire est obligatoire\n\n\n" 0 0' dialog(arg) - - try: + + try: machine.delete(res[0]) except EnvironmentError, c: arg = u'--title "Destruction machine" ' arg += u'--msgbox "ERREUR n°%s\n\n\n" 0 0' % c.args[0] dialog(arg) return 1 - + arg = u'--title "Destruction machine" ' arg += u'--msgbox "Machine détruite\n\n\n" 0 0' dialog(arg) - + #################################### ## Fonctions principales d'interface @@ -1529,16 +1529,16 @@ def new_adher(adher): else: step += 1 if not confirm(adher): break - + arg = u'--title "Inscription Mailing liste de communication ENS" --yesno "\nInscrire l\'adhérent à la mailing liste de communication de l\'ENS ?\n\n\n" 0 0' no, res = dialog(arg) if not no: mail = adher.mail() if mail.find('@') == -1: mail += '@crans.org' adher.services_to_restart('ML_ens', [mail]) - + def modif_adher(adher): - """ + """ Modification de l'adhérent fourni (instance de adhérent) Retourne 1 si annulation. """ @@ -1582,9 +1582,9 @@ def modif_adher(adher): arg += u'"Solde" "Effectuer un débit/crédit pour cet adhérent" ' annul, res = dialog(arg) - + if annul: return 1 - + if res[0] == 'Etudes': set_etudes(adher) elif res[0] == 'État-civil': @@ -1619,7 +1619,7 @@ def modif_adher(adher): if annul: return 1 if result[0] == '2': if set_addr_ext(adher): - # Annulation + # Annulation return modif_adher(adher) adher.chbre('EXT') elif result[0] == '3': @@ -1646,14 +1646,14 @@ def modif_adher(adher): m.delete("Depart du campus") adher.delete("Depart du campus") return - + else: while 1: arg = u'--title "Déménagement de %s" ' % adher.Nom() arg += u'--inputbox "Chambre ?" 0 0 ' annul, res = dialog(arg) if annul: return modif_adher(adher) - + e = _set_chbre(adher, res[0]) if res[0] == 'EXT': # Il faut demander l'adresse extérieure @@ -1667,60 +1667,60 @@ def modif_adher(adher): else: break - + elif res[0] == 'Téléphone': while 1: arg = u'--title "Changement numéro de téléphone de de %s" ' % adher.Nom() arg += u'--inputbox "Nouveau numéro ?" 0 0 "%s" ' % adher.tel() annul, res = dialog(arg) if annul: return modif_adher(adher) - - try: + + try: adher.tel(res[0].replace(' ', '')) break except ValueError, c: arg = u'--title "Changement numéro de téléphone de de %s" ' % adher.Nom() arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) - + elif res[0] == 'Alias': __prompt_input_menu(adher.alias, 'Alias mail', "Entrez ou modifier un alias mail.\nPour ajouter un alias modifier le dernier de la liste.") - + elif res[0] == 'Shell': while 1: arg = u'--title "Nouveau shell pour %s" ' % adher.Nom() arg += u'--inputbox "Shell : " 0 0 "%s" ' % adher.chsh() annul, res = dialog(arg) if annul: return modif_adher(adher) - - try: + + try: adher.chsh(res[0]) break except ValueError, c: arg = u'--title "Changement du shell de %s" ' % adher.Nom() arg += u'--msgbox "%s\n\n\n" 0 0' % c.args[0] dialog(arg) - + elif res[0] == 'Solde': set_solde(adher) - + if adher.modifs: return confirm(adher) def modif_machine(machine): - """ + """ Modification de la machine fournie (instance de machine) Retourne 1 si annulation. """ - + if not isadm: step = 1 while 1: - + if step == 1: if set_machine(machine): return 1 else: step = 2 - + if step == 2: if set_rque(machine): step = 1 else: return @@ -1738,11 +1738,11 @@ def modif_machine(machine): arg += u'"Wifi" "Modifier les paramètres spécifiques aux bornes wifi" ' - + annul, res = dialog(arg) - + if annul: return 1 - + if res[0] == 'Informations': set_machine(machine) return @@ -1771,10 +1771,10 @@ def select(clas, quoi, mde=''): exemples : quoi = 'adhérent a' => Votre choix ? adhérent aid=: il faut que le dernier caractère de quoi soit a pour adhérent ou m pour machine Retourne None si annulation. - + si m = ro ouvre l'objet en mode read-only """ - + s= ['', '', '', '', '', '', '', '', '', ''] def f(a): try: @@ -1792,16 +1792,16 @@ def select(clas, quoi, mde=''): arg += u'"Chambre :" 4 1 "%s" 4 13 05 00 ' % s[3] arg += u'"aid :" 5 1 "%s" 5 13 5 5 ' % s[4] arg += u'"Login / mail :" 6 1 "%s" 6 16 30 00 ' % s[5] - arg += u'"Machine :" 1 35 "" 0 0 0 0 ' + arg += u'"Machine :" 1 35 "" 0 0 0 0 ' arg += u'"Nom :" 2 37 "%s" 2 43 17 17 ' % s[6] arg += u'"Mac :" 3 37 "%s" 3 43 17 17 ' % s[7] arg += u'"IP :" 4 37 "%s" 4 43 15 15 ' % s[8] arg += u'"mid :" 5 37 "%s" 5 43 5 5 ' % s[9] arg += u'"Les champs vides sont ignorés." 7 1 "" 0 0 0 0' - + annul, result = dialog(arg) if annul: return - + if result[0][:4] == 'HELP': arg = u'--title Aide ' arg += u'--msgbox "Il n\'est pas necessaire de remplir tous les champs.\n' @@ -1814,11 +1814,11 @@ def select(clas, quoi, mde=''): i = i.strip().decode(encoding) if not i: i= u'*' s.append(i) - + ### Contruction de la chaîne de recherche filtre_adher = u'nom=%s&prenom=%s&tel=%s&chbre=%s&aid=%s&mail=%s&' % tuple(s[:6]) filtre_machine = u'host=%s&macAddress=%s&ipHostNumber=%s&mid=%s&' % tuple(s[6:]) - + filtre= '' if filtre_adher.count('=*&') != 6: # Au moins une condition adhérent @@ -1833,7 +1833,7 @@ def select(clas, quoi, mde=''): arg += u'--msgbox "Il faut au moins une condition.\n\n\n" 0 0' dialog(arg) continue - + ### Recherche try: if mde == 'ro': @@ -1845,7 +1845,7 @@ def select(clas, quoi, mde=''): arg += u'--msgbox "Caractère interdit.\n\n\n" 0 0' dialog(arg) continue - + # Affichage if quoi[-1] == 'a': valid = res['adherent'] @@ -1866,14 +1866,14 @@ def select(clas, quoi, mde=''): valid.append(m) else: raise TypeError('Argument fonction invalide') - + if not valid or (len(valid) == 1 and quoi[-1] == 'a' and valid[0].__class__ == AssociationCrans): arg = u'--title "Recherche" ' arg += u'--msgbox "Aucun résultat.\n\n\n" 0 0' dialog(arg) # Retour au formulaire continue - + if len(valid) == 1: # Une seule réponse choix = valid[0] @@ -1895,15 +1895,15 @@ def select(clas, quoi, mde=''): print 'Choix invalide' continue if choix: break - + if not choix: # Retour à l'interface de recherche continue - + os.system('clear') print "Sélection : " aff(choix) - + while 1: r = affich_tools.prompt(u'Confirmer sélection ? [O/N]') if r == 'O' or r == 'o': @@ -1914,13 +1914,13 @@ def select(clas, quoi, mde=''): break print 'Répondre O ou N' # Retour à la confirmation - + if choix: if mde != 'ro' and not choix._modifiable: arg = u'--title "Recherche" ' arg += u'--msgbox "Objet sélectionné locké, attendre.\n\n\n" 0 0' dialog(arg) - return + return return choix # Sinon retour interface de sélection @@ -1928,12 +1928,12 @@ def menu_principal(): """ Affiche le menu de choix initial """ - + # que signifient toutes ces initiales ? # (a)jouter, (m)odifier, (d)eleter # (M)achine, (A)dherent, (C)lub, K=crans, (B)orne # (c)ourant = déja selectionné - + proprio = None becane = None choix = None @@ -1974,7 +1974,7 @@ def menu_principal(): arg += u'"aKB" "Ajouter une borne wifi" "" ' annul, result = dialog(arg) if annul: break - + if result[0][:4] == 'HELP': arg = u'--title Aide ' arg += u'--msgbox "Interface utilisable au clavier ou a la souris pour les terminaux le supportant.\n' @@ -1990,48 +1990,48 @@ def menu_principal(): if choix == 'aA': # Inscription nouvel adhérent proprio = Adherent() - if new_adher(proprio): + if new_adher(proprio): del proprio proprio = None else: choix = 'aMc' # ajout d'une machine - + elif choix == 'mA': # Modif adhérent proprio = select(db, u'adhérent à modifier a') if not proprio: continue choix = 'mAc' - + elif choix == 'aMA': # Ajout machine, adhérent à choisir proprio = select(db, u'adhérent auquel ajouter une machine a') if not proprio: continue choix= 'aMc' - + elif choix == 'aMC': # Ajout machine, club à choisir proprio = select_club(db) if not proprio: continue choix= 'aMc' - + elif choix == 'mM': # Modif machine, machine à choisir becane = select(db, u'machine à modifier m') if not becane: continue choix= 'mMc' - + elif choix == 'aC': # Ajout d'un club proprio = Club() if new_club(proprio): del proprio ; proprio = None else: choix = 'aMc' # ajout d'une machine - + elif choix == 'mC': # Modif club proprio = select_club(db) if not proprio: continue choix= 'mCc' - + elif choix == 'dA': # Destruction adhérent proprio = select(db, u'adhérent à détruire a') @@ -2039,14 +2039,14 @@ def menu_principal(): if del_adher(proprio): continue del(proprio) ; proprio= None del(becane) ; becane= None - + elif choix == 'dM': # Destruction machine becane = select(db, u'machine à détruire m') if not becane: continue if del_machine(becane): continue del(becane) ; becane= None - + elif choix == 'dC': # Destruction club proprio = select_club(db) @@ -2054,32 +2054,32 @@ def menu_principal(): if del_club(proprio): continue del(proprio) ; proprio= None del(becane) ; becane= None - + elif choix == 'aKM': # Ajout machine au crans becane = MachineCrans(AssociationCrans(db.conn)) if set_machine(becane): becane.restore() - + elif choix == 'aKB': # Ajout borne wifi becane = BorneWifi(AssociationCrans(db.conn)) if set_machine(becane): becane.restore() - - ############################################## - + + ############################################## + if choix == 'aMc': # Ajout d'une machine à l'adhérent/au club courant # On ne peut avoir de machine fixe si on n'a pas payé # la caution caution_ok = 'k' in proprio.controle() - + # On ne peut avoir une machine fixe que si on a pas # déjà une machine fixe, sauf si on est membre actif # (expérimental) - + if not isinstance(proprio, Club) and not proprio.adherentPayant(): # Les gens qui ne paient pas n'ont le droit qu'à une # seule machine fixe @@ -2127,17 +2127,17 @@ def menu_principal(): del(becane) becane = None - + if choix == 'mAc': # Modif propriétaire courant del(becane) - becane= None + becane= None # On supprime la machine car des modifs du propriétaire (bat) ne seraient # alors pas vu par l'instance actuelle de machine if modif_adher(proprio): # Annulation des modifs proprio.restore() - + elif choix == 'mMc': # Modif machine courante if not proprio: @@ -2149,13 +2149,13 @@ def menu_principal(): elif modif_machine(becane): # Annulation des modifs becane.restore() - + elif choix == 'mCc': # Modif club courant if modif_club(proprio): # Annulation des modifs proprio.restore() - + os.system('clear') def killed(a, z): @@ -2164,10 +2164,10 @@ def killed(a, z): if __name__ == '__main__': global debug debug = 0 - + signal.signal(signal.SIGTERM, killed) # Interception du signal TERM signal.signal(signal.SIGINT, signal.SIG_DFL) # Comportement normal de Ctrl-C - + # Traitement des options try: if len(sys.argv) > 1: @@ -2177,11 +2177,11 @@ if __name__ == '__main__': except getopt.error, msg: print msg sys.exit(255) - + for opt, val in options: if opt == '--debug': debug = 1 - + if isadm: debug = 1 @@ -2202,12 +2202,12 @@ if __name__ == '__main__': except: if not debug: os.system('clear') print """Une erreur fatale s'est produite durant l'exécution.""" - + # Report de bug import traceback from cStringIO import StringIO from smtplib import SMTP - + s = StringIO() sys.stderr = s traceback.print_exc() @@ -2217,11 +2217,11 @@ if __name__ == '__main__': if not debug and To: # Paramètres pour le mail From = script_utilisateur + '@crans.org' - + entete_mail = """From: %s To: %s -Subject: Bugreport %s - +Subject: Bugreport %s + """ % (From, ','.join(To), sys.argv[0].split('/')[-1]) # Envoi mail @@ -2240,11 +2240,11 @@ Subject: Bugreport %s sys.stderr.write(traceback) print '-'*40 exit = 1 - + # Restart des services signal.signal(signal.SIGINT, signal.SIG_IGN) # Pas de Ctrl-C signal.signal(signal.SIGTERM, signal.SIG_IGN) # Pas de kill non plus - + try: serv = db.services_to_restart() except: @@ -2260,10 +2260,10 @@ Subject: Bugreport %s print "Les services suivants seront redémarrés: " for s in serv: print '\t%s' % s - + if debug: print '-*- Fin -*-' - + # Rétablissement du Ctrl-C signal.signal(signal.SIGINT, signal.SIG_DFL) sys.exit(exit) - +