[tv/vignettes/vignettes.py] On utilise des Exception
darcs-hash:20090304095016-8fbb1-026c014c25ca20407b5dbbadb44435a3a3d52622.gz
This commit is contained in:
parent
3ec374e3bc
commit
d7caa59a30
1 changed files with 47 additions and 40 deletions
|
@ -77,17 +77,29 @@ def vignettes() :
|
||||||
nom = line.split(':')[0]
|
nom = line.split(':')[0]
|
||||||
ip = line.split(':')[-1]
|
ip = line.split(':')[-1]
|
||||||
print '%s %s' %(str(ip),str(nom))
|
print '%s %s' %(str(ip),str(nom))
|
||||||
|
try :
|
||||||
fqdn = socket.gethostbyaddr(ip)[0]
|
fqdn = socket.gethostbyaddr(ip)[0]
|
||||||
|
except gai.error, err :
|
||||||
|
print 'On n\'arrive pas à résoudre ce nom %s %s' % (ip,err[1])
|
||||||
|
continue
|
||||||
|
except :
|
||||||
|
print 'Erreur inconnue'
|
||||||
|
continue
|
||||||
|
else :
|
||||||
#on évite les radios, peu de debit et pas de vignettes
|
#on évite les radios, peu de debit et pas de vignettes
|
||||||
if nom[0:3]=='rad' :
|
if nom[0:3]=='rad' :
|
||||||
#C'est une radio on cherche un logo
|
#C'est une radio on cherche un logo
|
||||||
ok=0 #désolé vince j'ai essayé les exceptions mois c pas si simple
|
|
||||||
nom_court=(' '.join(nom.split(' ')[2:])).lower()
|
nom_court=(' '.join(nom.split(' ')[2:])).lower()
|
||||||
print "On s'occupe de la radio %s" % nom_court
|
print "On s'occupe de la radio %s" % nom_court
|
||||||
for file in os.listdir('%s /logos_radios' % img_dir):
|
for file in os.listdir('%s /logos_radios' % img_dir):
|
||||||
if file.startswith(nom_court):
|
try :
|
||||||
shutil.copy(' %s/logos_radios/%s' % (img_dir,file),'%s/%s.jpg' % (img_dir,fqdn))
|
shutil.copy(' %s/logos_radios/%s' % (img_dir,file),'%s/%s.jpg' % (img_dir,fqdn))
|
||||||
shutil.copy(' %s/logos_radios/%s' % (img_dir,file),'%s/%s_petites.jpg' % (img_dir,fqdn))
|
shutil.copy(' %s/logos_radios/%s' % (img_dir,file),'%s/%s_petites.jpg' % (img_dir,fqdn))
|
||||||
|
except :
|
||||||
|
#il n'y a pas de logo :-(
|
||||||
|
chaines_probleamatiques.append('<b><u>Chaine :</u></b> %s<br><b><u>IP :</u></b> %s:1234<br><br>\n' %(nom,ip))
|
||||||
|
continue
|
||||||
|
else :
|
||||||
if col == 2 :
|
if col == 2 :
|
||||||
col = 1
|
col = 1
|
||||||
html.write('</tr><tr>\n')
|
html.write('</tr><tr>\n')
|
||||||
|
@ -99,12 +111,6 @@ def vignettes() :
|
||||||
else :
|
else :
|
||||||
col_petites += 1
|
col_petites += 1
|
||||||
ajoute_image(nom,fqdn,ip,html,html_petites)
|
ajoute_image(nom,fqdn,ip,html,html_petites)
|
||||||
ok=1 #désolé vince j'ai essayé les exceptions mois c pas si simple
|
|
||||||
if not ok:
|
|
||||||
#il n'y a pas de logo :-(
|
|
||||||
chaines_probleamatiques.append('<b><u>Chaine :</u></b> %s<br><b><u>IP :</u></b> %s:1234<br><br>\n' %(nom,ip))
|
|
||||||
print "\t Fait"
|
|
||||||
continue
|
|
||||||
print 'on s\'occupe de %s %s' % (ip,nom)
|
print 'on s\'occupe de %s %s' % (ip,nom)
|
||||||
print '\trecuperation du flux'
|
print '\trecuperation du flux'
|
||||||
#ip port duree
|
#ip port duree
|
||||||
|
@ -160,6 +166,7 @@ def vignettes() :
|
||||||
for line in chaines_probleamatiques :
|
for line in chaines_probleamatiques :
|
||||||
html.write(line)
|
html.write(line)
|
||||||
html_petites.write(line)
|
html_petites.write(line)
|
||||||
|
|
||||||
#on ecrit la vraie fin
|
#on ecrit la vraie fin
|
||||||
html.write(trame_piedpage)
|
html.write(trame_piedpage)
|
||||||
html.close()
|
html.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue