[Mac_prises] Début de passage à postgresql
This commit is contained in:
parent
c039058708
commit
baf4aa3645
1 changed files with 10 additions and 8 deletions
|
@ -10,6 +10,7 @@ from commands import getstatusoutput
|
|||
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
import annuaires_pg
|
||||
import psycopg2
|
||||
|
||||
# nécessite apparemment que l'objet conn soit bien créé lors de l'exec
|
||||
# de annuaires_pg, il faut être root (ou dans je ne sais quel groupe)
|
||||
|
@ -17,8 +18,6 @@ import annuaires_pg
|
|||
# (plante lamentablement quand j'essaye avec mon compte sur vo, sous
|
||||
# ipython. Mais si je sudo ipython, ça marche...
|
||||
|
||||
def is_really_crans(chbre):
|
||||
|
||||
def liste_prises_macs(switch):
|
||||
u'''
|
||||
Fonction générant un dictionnaire (macs) contenant pour chaque prise une
|
||||
|
@ -92,9 +91,12 @@ if __name__ == '__main__':
|
|||
split = switch.replace('.adm.crans.org', '').split('-')
|
||||
bat, num_switch = split[0][-1], int(split[1][0])
|
||||
|
||||
if not os.path.isdir("bat%s/%d"%(bat, num_switch)):
|
||||
os.makedirs("bat%s/%d"%(bat, num_switch))
|
||||
pgsql = psycopg2.connect(database="mac_prises", user="crans")
|
||||
curseur = pgsql.cursor()
|
||||
|
||||
for chbre in macs:
|
||||
with open('bat%s/%d/%s%03d.macs'%(bat, num_switch, bat, prise), 'w') as f:
|
||||
f.writelines(sorted(macs[prise]))
|
||||
# if not os.path.isdir("bat%s/%d"%(bat, num_switch)):
|
||||
# os.makedirs("bat%s/%d"%(bat, num_switch))
|
||||
#
|
||||
# for chbre in macs:
|
||||
# with open('bat%s/%d/%s%03d.macs'%(bat, num_switch, bat, prise), 'w') as f:
|
||||
# f.writelines(sorted(macs[prise]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue