Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1451 Le 13/06/2008, à 11:00

Ekinoks

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

terato a écrit :

Est ce qu'il y a un moyen pour faire en sorte que mon conky situé en haut de l'ecran puisse avoir les memes caractéristique qu'un tableau de bord, c'est a dire que les fenetres n'aille pas plus haut que la barre.

Il y a un moyen, utiliser un tableau de bord... :^/

L'astuce est ensuite de le mettre la transparence à 100%  wink

Edit : oups, désolé... je n'avais pas vue que quelqu'un avais dit la meme réponse puis supprimé (évité de supprimer vos messages s'il vous plait...)

Dernière modification par Ekinoks (Le 13/06/2008, à 11:06)

Hors ligne

#1452 Le 13/06/2008, à 11:30

titimoi

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Ekinoks a écrit :
terato a écrit :

Est ce qu'il y a un moyen pour faire en sorte que mon conky situé en haut de l'ecran puisse avoir les memes caractéristique qu'un tableau de bord, c'est a dire que les fenetres n'aille pas plus haut que la barre.

Il y a un moyen, utiliser un tableau de bord... :^/

L'astuce est ensuite de le mettre la transparence à 100%  wink

Edit : oups, désolé... je n'avais pas vue que quelqu'un avais dit la meme réponse puis supprimé (évité de supprimer vos messages s'il vous plait...)

oui j'ai supprimé car j'avais dit une bêtise !, cela ne fonctionne pas et j'ai expliqué pourquoi wink

Hors ligne

#1453 Le 13/06/2008, à 22:48

tof54

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

ah ba grâce au paquet "pymetar" j'y vois déjà mieux, ya des éléments qui apparaissent (enfin ! smile) donc pour ma part la solution est proche

Hors ligne

#1454 Le 14/06/2008, à 11:15

rOm_08

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

J'ai enfin réussi a tout faire avec Conky cool

capture41ox1.th.jpg

Merci encore à tous ceux qui ont postés leur .conkyrc wink


Ubuntu Lucid Lynx 10.4 | Asus P5E Deluxe | Core2Quad Q9550 | ATI HD4870 512Mo | 4Go de RAM | Coolermaster Real Power M620 | Hitachi 1To

Hors ligne

#1455 Le 14/06/2008, à 11:21

Lenezir

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Joli tout ça big_smile
Tu pourrais mettre la liste de tous tes conky stp ? big_smile
Et tu utilises quel dock stp ?
Merci big_smile

Hors ligne

#1456 Le 14/06/2008, à 12:01

rOm_08

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Pas de soucis wink

Tout d'abord pour le dock c'est Avant Windows Navigator.

Le script de lancement .conkystart.sh :

#!/bin/bash

sleep 15
conky -c /home/rom/.conkyrc  &
conky -c /home/rom/.conkyrc2 &
conky -c /home/rom/.conkyrc3 &
conky -c /home/rom/.conkyrc4 &
conky -c /home/rom/.conkyrc5 &
conky -c /home/rom/.conkyrc6 &
conky -c /home/rom/.conkyrc7 &
conky -c /home/rom/.conkyrc8 &
conky -c /home/rom/.conkyrc9 &
exit

Le .conkyrc (System) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment top_left

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 2

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 20
gap_y 40

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
minimum_size 280 5


TEXT
${color}
${alignc}~~{~{ rOm` }~}~~

${alignc}We are the  ${color}${time %A %d %B %Y} 
${alignc}$color  And it is  ${color}${time %H:%M:%S}    $color

${alignc}${color}# System :

${alignc}Ubuntu 8.04 Hardy Heron
${alignc}$sysname $kernel on $machine $freq_g GHz
${alignc}Uptime: $uptime

Le .conkyrc (Météo) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment top_right

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 1

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 20
gap_y 50

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
minimum_size 280 5


TEXT
${alignc}${color}# Weather :

${alignc}${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=CN --refetch}

${alignc}${color }Jour: ${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=DW}
${alignc}${color }Conditions: ${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=CC}
${alignc}${font Weather:size=36}${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=WF}${font}
${alignc}${color }Température: ${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=HT -u}C
${alignc}${color }Vent: ${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=WS -u} Km/h
${alignc}${color }Direction vent: ${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=WD}
${alignc}${color }Humidité: ${color }${execi 3600 python ~/scripts/conkyForecast.py --location=FRXX0067 --datatype=HM}

Le .conkyrc3 (Espace Disque) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment bottom_right

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 2

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 20
gap_y 100

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
minimum_size 280 5




TEXT
${alignc}${color}# Hard Drive Space :

${color}Linux             ${fs_used /}/${fs_size /}${alignr}${fs_used_perc /}%
${color}${fs_bar 6 /}

${color}Données       ${fs_used /media/Donnés}/${fs_size /media/Donnés}${alignr}${fs_used_perc /media/Donnés}%
${color}${fs_bar 6 /media/Donnés}

${color}Jeu                 ${fs_used /media/disk}/${fs_size /media/disk}${alignr}${fs_used_perc /media/disk}%
${color}${fs_bar 6 /media/disk}

${color}Clé USB          ${if_mounted /media/ROM_USB}${fs_used /media/ROM_USB}/${fs_size /media/ROM_USB}${alignr}${fs_used_perc /media/ROM_USB}%
${color}${fs_bar 6 /media/ROM_USB}${else}Not Connected$endif

${color}Ipod                ${if_mounted /media/IPOD_ROM}${fs_used /media/IPOD_ROM}/${fs_size /media/IPOD_ROM}${alignr}${fs_used_perc /media/IPOD_ROM}%
${color}${fs_bar 6 /media/IPOD_ROM}${else}Not Connected$endif

Le .conkyrc4 (Amarok) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment bottom_right

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 1

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 20
gap_y 420

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
minimum_size 280 5

#Max
maximum_width 280


TEXT
${alignc}${color}# Amarok :
${if_running amarokapp}
${alignc}${execi 10 ~/scripts/amarok artist}
${alignc}${execi 10 ~/scripts/amarok title}
${alignc}${execi 5 dcop amarok player currentTime}/${execi 10 dcop amarok player totalTime}
${execibar 1 ~/scripts/amarok progress}
${alignc}"${execi 10 ~/scripts/amarok album}"

${color}Bitrate: ${execi 10 dcop amarok player bitrate}kbps${alignr}Vol: ${execi 10 dcop amarok player getVolume}%

Le .conkyrc5 (Wifi) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment bottom_left

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 2

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 20
gap_y 100

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no




TEXT
${alignc}${color}# Wireless :

Power :  ${alignr}${color}${wireless_link_qual_perc wlan0}${color}%
${color}${wireless_link_bar 6 wlan0}
${alignc}${color}Local IP : ${color}${addr wlan0}$alignr${color}

${color}Download :${color} ${downspeed wlan0} k/s${color} ${offset 80}${color}$alignr Upload:${color} ${upspeed wlan0} k/s
${color}Downloaded: ${color}${totaldown wlan0}$alignr ${color} ${color}Uploaded: ${color}${totalup wlan0}
${downspeedgraph wlan0 32,150 FFFFFF FFFFFF} ${alignr}${upspeedgraph wlan0 32,150 FFFFFF FFFFFF}

Le .conkyrc6 (CPU et RAM) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment bottom_left

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 2

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 20
gap_y 360

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no




TEXT
${alignc}${color}# Use CPU : 

${alignc}${color}Intel Core2Duo E6750 @ 2.66GHz

Core 1: ${color}${freq cpu1}Mhz $alignr${color}Core 2: ${color}${freq cpu2}Mhz
${color}${cpubar cpu1 5,85} :${cpu cpu1}%  $alignr${color}${cpubar cpu2 5,85} :${cpu cpu2}%
${cpugraph cpu1 25,150 FFFFFF FFFFFF}  ${alignr}${cpugraph cpu2 25,150 FFFFFF FFFFFF}


${alignc}${color}# Use Memory :

${alignc}${color}G.Skill DDRII PC6400 4x1Go

RAM :${color} $mem/$memmax - $memperc% ${color}${membar}
Swap :${color} $swap/$swapmax - $swapperc% ${color}${swapbar}

Le .conkyrc7 (Temperature) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment top_right

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 2

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 560
gap_y 50

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
#minimum_size 250 5
#maximum_width 500




TEXT
           ${font openlogos:size=152}v${font}

${alignc}${color}# Temperature :

${alignc}${font} Core0: ${execi 2 expr `cat /sys/devices/platform/coretemp.0/temp1_input | cut -c1,2` + 15}°C | ${font} Core1: ${execi 2 expr `cat /sys/devices/platform/coretemp.1/temp1_input | cut -c1,2` + 15}°C | ${font}GPU: ${execi 60 nvidia-settings -query GPUCoreTemp | perl -ne 'print $1 if /GPUCoreTemp.*?: (\d+)./;'}°C | ${font}M/B: ${execi 2 cat /sys/devices/platform/it87.656/temp1_input | cut -c1,2}°C
${alignc}HDD System: $color${execi 10 hddtemp -n /dev/sda3}°C | HDD Data: $color${execi 10 hddtemp -n /dev/sdb1}°C
${alignc}${font} Vcore: ${hwmon in 0}V | ${font} Vram: ${hwmon in 1}V

Le .conkyrc8 (Calendrier) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment bottom_right

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Mono:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 2

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 650
gap_y 100

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
#minimum_size 250 5
#maximum_width 500




TEXT
${alignc}${color}# Calendar :

${color}${alignc}${execi 1 ~/scripts/calendar.sh first_part}${alignr}${color red}${execi 1 ~/scripts/calendar.sh today }
${color blue}${execi 1 ~/scripts/calendar.sh second_part}

Le .conkyrc9 (Pense Bête) :

# Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
#min_port_monitor_connections 64

#emplacement
alignment bottom_right

#pour que corky tourne en arriere plan
background yes
#background no #pour les tests

#nombre d'echantillons a utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 4

#affiche le texte sur la sortie standard
out_to_console no

# Utiliser Xft (polices lissées etc)
use_xft yes

#police a utiliser : use_xft doit etre a "yes"
xftfont DejaVu Sans Condensed Oblique:size=10

# utiliser sa propre fenetre ?
own_window yes

#type de fenetre : normal(avec le cadre) / override / desktop
own_window_type override

#pseudo transparence?
own_window_transparent yes

# taux de raffraichissement de la fenetre (en secondes)
update_interval 1

# pour eviter le clignotement de la semaine (fonctionne pas chez moi)
double_buffer yes

# afficher les ombres?
draw_shades no

# afficher des contours ?
draw_outline no

#contours autour des blocs de texte?
draw_borders no

# contour en trait-tillés, longueur d'un trait en pixels
stippled_borders 10

#largeur des marges (n'a pas l'air de fonctionner)
border_margin 20

# largeur du contour
border_width 1

# couleur par defaut du texte, de l'ombre et du contour
default_color white
default_shade_color white
default_outline_color white

# ecart avec le bord x=gauche ou droit y= haut ou bas
gap_x 580
gap_y 380

# Ajoute des espaces apres certains objets pour eviter de les faire bouger.
# Fonctionne uniquement avec la police Monospace
use_spacer no

# Soustraire les mémoires tampons de la mémoire utiliser ?
no_buffers yes

# Tout le texte en majuscule ?
uppercase no

# Minimum size of text area
minimum_size 280 5

#Max
maximum_width 280

TEXT
${alignc}${color}# To do :

${alignc}${exec cat /home/rom/Pense_Bete/Pense_Bete.txt}
${alignc}${exec cat /home/rom/Pense_Bete/Pense_Bete1.txt}
${alignc}${exec cat /home/rom/Pense_Bete/Pense_Bete2.txt}
${alignc}${exec cat /home/rom/Pense_Bete/Pense_Bete3.txt}
${alignc}${exec cat /home/rom/Pense_Bete/Pense_Bete4.txt}
${alignc}${exec cat /home/rom/Pense_Bete/Pense_Bete5.txt}

Et voila wink

Merci pour vos avis wink Sa fait bien plaisir smile


Ubuntu Lucid Lynx 10.4 | Asus P5E Deluxe | Core2Quad Q9550 | ATI HD4870 512Mo | 4Go de RAM | Coolermaster Real Power M620 | Hitachi 1To

Hors ligne

#1457 Le 14/06/2008, à 12:32

Lenezir

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Merci big_smile
Euh est-ce que tu pourrais ajouter le script conkyForecast.py stp ?
Je n'arrive pas à le télécharger sur ubuntu.com hmm

Dernière modification par Imoreion (Le 14/06/2008, à 12:33)

Hors ligne

#1458 Le 14/06/2008, à 12:46

rOm_08

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Oui je l'avais oublié lol

conkyForecast.py :

#!/usr/bin/python
# -*- coding: utf-8 -*-
###############################################################################
# conkyForecast.py is a (not so) simple (anymore) python script to gather 
# details of the current weather for use in conky.
#
#  Author: Kaivalagi
# Created: 13/04/2008
# Modifications:
#	14/04/2008	Allow day ranges for forecast data
#	14/04/2008	Check for connectivity to xoap service
#	18/04/2008	Allow the setting of spaces for ranged output
#	18/04/2008	Allow Night and Day forecast output
#	18/04/2008	Support locale for condition code text "CC" option, awaiting spanish language translation
#	18/04/2008	Use pickling for class data rather than opening xml, this bypasses the need to interrogate cached data
#	19/04/2008	Added spanish condition text - Thanks Bruce M
#	19/04/2008	Added isnumeric check on all numeric output with units suffix
#	19/04/2008	Altered pickle file naming to include location code
#	19/04/2008	Added spanish week days conversion via locale
#	20/04/2008	Added decent command argument parser
#	20/04/2008	Added --shortweekday option, if given the day of week data type is shortened to 3 characters
#	21/04/2008	Fixed locale options for forecast output
#	21/04/2008	Added --template option to allow custom output using a single exec call :)
#	21/04/2008	Added --hideunits option to remove, for example, mph and C from output
#	23/04/2008	Removed --imperial option from template, this MUST be set as a standard option on the script call and not used in the template file. 
#	23/04/2008	Readded --imperial option to template, enabling metric or imperial values per datatype. Note when using templates command line option will not work.
#	23/04/2008	Added output notifying user if the location given is bad
#	24/04/2008	Added handling for no connectivity, will revert to cached data now (erroring if no cache exists). Tests by trying to open xoap.weather.com
#	24/04/2008	Fixed Celsius to fahrenheit conversion
#	06/05/2008	Updated url used after webservice was updated
#	09/05/2008	Consolidated current condition and forecast data fetch into one call
#	09/05/2008	Added Sunrise and sunset to datatypes, these are specific to both current conditions and forecast data
#	09/05/2008	Added moon phase, barometer reading and barometer description to datatypes, these are only specific to current conditions and so are N/A in forecasted output
#	09/05/2008	Added unit conversions for barometer from mb to inches (imperial)
#   09/05/2008  Updated spanish condition text - Thanks Bruce M
#   10/05/2008  Added french locale data - Thanks benpaka
#   12/05/2008  Added new BF (bearing font) datatype to provide an arrow character (use with Arrow.ttf font) instead of NSEW output from WD (wind direction)
#   12/05/2008  Updated WD output to be locale specific, currently supports default english and spanish - Thanks Bruce M
#	18/05/2008	Added new MF (moon font) datatype to provide a moon font character (characters incorrect and no dedicated font yet).
#	21/05/2008	For current conditions the --datatype=LT option now displays "feels like" temperature rather than the current temperature
#	28/05/2008	Arrows reported to be pointing in the wrong direction. Correction provided by jjgomera
#	03/06/2008	Updated MF function, added days #26, #27, #28 nad #29 to complete the cycle. Corrections provided by Bruce M/uboops/HippyRandall
#
# TODO:
# Consolidate pkl files into one file/class
# ??? Any more requirements out there?

import sys, os, socket, urllib2, datetime, time
from xml.dom import minidom
from stat import *
from optparse import OptionParser
import locale
import gettext
import pickle
from math import *

APP="conkyForecast.py"
DIR=os.path.dirname (__file__) + '/locale'
gettext.bindtextdomain(APP, DIR)
gettext.textdomain(APP)
_ = gettext.gettext

class CommandLineParser:

	parser = None

	def __init__(self):

		self.parser = OptionParser()
		self.parser.add_option("-l","--location", dest="location", default="UKXX0103", type="string", metavar="CODE", help=u"location code for weather data [default: %default],Use the following url to determine your location code by city name: http://xoap.weather.com/search/search?where=Norwich")
		self.parser.add_option("-d","--datatype",dest="datatype", default="HT", type="string", metavar="DATATYPE", help=u"[default: %default] The data type options are: DW (Day Of Week), WF (Weather Font Output), LT (Forecast:Low Temp,Current:Feels Like Temp), HT (Forecast:High Temp,Current:Current Temp), CC (Current Conditions), CT (Conditions Text), PC (Precipitation Chance), HM (Humidity), WD (Wind Direction), WS (Wind Speed), WG (Wind Gusts), CN (City Name), SR (sunrise), SS (sunset), MP (moon phase), MF (moon font), BR (barometer reading), BD (barometer description). Not applicable at command line when using templates.")
		self.parser.add_option("-s","--startday",dest="startday", type="int", metavar="NUMBER", help=u"define the starting day number, if omitted current conditions are output. Not applicable at command line when using templates.")
		self.parser.add_option("-e","--endday",dest="endday", type="int", metavar="NUMBER", help=u"define the ending day number, if omitted only starting day data is output. Not applicable at command line when using templates.")
		self.parser.add_option("-S","--spaces",dest="spaces", type="int", default=1, metavar="NUMBER", help=u"[default: %default] Define the number of spaces between ranged output. Not applicable at command line when using templates.")
		self.parser.add_option("-t","--template",dest="template", type="string", metavar="FILE", help=u"define a template file to generate output in one call. A displayable item in the file is in the form {--datatype=HT --startday=1}. The following are possible options within each item: --datatype,--startday,--endday,--night,--shortweekday,--imperial,--hideunits,--spaces . Note that the short forms of the options are not currently supported! None of these options are applicable at command line when using templates.")
		self.parser.add_option("-L","--locale",dest="locale", type="string", help=u"override the system locale for language output (en=english, es=spanish, fr=french, more to come)")
		self.parser.add_option("-i","--imperial",dest="imperial", default=False, action="store_true", help=u"request imperial units, if omitted output is in metric. Not applicable at command line when using templates.")
		self.parser.add_option("-n","--night",dest="night", default=False, action="store_true", help=u"switch output to night data, if omitted day output will be output. Not applicable at command line when using templates.")
		self.parser.add_option("-w","--shortweekday",dest="shortweekday", default=False, action="store_true", help=u"Shorten the day of week data type to 3 characters. Not applicable at command line when using templates.")
		self.parser.add_option("-u","--hideunits",dest="hideunits", default=False, action="store_true", help=u"Hide units such as mph or C, degree symbols (°) are still shown. Not applicable at command line when using templates.")
		self.parser.add_option("-v","--verbose",dest="verbose", default=False, action="store_true", help=u"request verbose output, no a good idea when running through conky!")
		self.parser.add_option("-r","--refetch",dest="refetch", default=False, action="store_true", help=u"fetch data regardless of data expiry")

	def parse_args(self):
		(options, args) = self.parser.parse_args()
		return (options, args)

	def print_help(self):
		return self.parser.print_help()

class WeatherData:
	def __init__(self, day_of_week, low, high, condition_code, condition_text, precip, humidity, wind_dir, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc):
		self.day_of_week = u""+day_of_week
		self.low = u""+low
		self.high = u""+high
		self.condition_code = u""+condition_code
		self.condition_text = u""+condition_text
		self.precip = u""+precip
		self.humidity = u""+humidity
		self.wind_dir = u""+wind_dir
		self.wind_speed = u""+wind_speed
		self.wind_gusts = u""+wind_gusts
		self.city = u""+city
		self.sunrise = u""+sunrise
		self.sunset = u""+sunset
		self.moon_phase = u""+moon_phase
		self.moon_icon = u""+moon_icon		
		self.bar_read = u""+bar_read
		self.bar_desc = u""+bar_desc


class WeatherText:

	conditions_text = {
		"0": _(u"Tornado"),
		"1": _(u"Tropical Storm"),
		"2": _(u"Hurricane"),
		"3": _(u"Severe Thunderstorms"),
		"4": _(u"Thunderstorms"),
		"5": _(u"Mixed Rain and Snow"),
		"6": _(u"Mixed Rain and Sleet"),
		"7": _(u"Mixed Precipitation"),
		"8": _(u"Freezing Drizzle"),
		"9": _(u"Drizzle"),
		"10": _(u"Freezing Rain"),
		"11": _(u"Showers"),
		"12": _(u"Showers"),
		"13": _(u"Snow Flurries"),
		"14": _(u"Light Snow Showers"),
		"15": _(u"Blowing Snow"),
		"16": _(u"Snow"),
		"17": _(u"Hail"),
		"18": _(u"Sleet"),
		"19": _(u"Dust"),
		"20": _(u"Fog"),
		"21": _(u"Haze"),
		"22": _(u"Smoke"),
		"23": _(u"Blustery"), 
		"24": _(u"Windy"),
		"25": _(u"Cold"),
		"26": _(u"Cloudy"),
		"27": _(u"Mostly Cloudy"),
		"28": _(u"Mostly Cloudy"),
		"29": _(u"Partly Cloudy"),
		"30": _(u"Partly Cloudy"),
		"31": _(u"Clear"),
		"32": _(u"Clear"),
		"33": _(u"Fair"),
		"34": _(u"Fair"),
		"35": _(u"Mixed Rain and Hail"),
		"36": _(u"Hot"),
		"37": _(u"Isolated Thunderstorms"),
		"38": _(u"Scattered Thunderstorms"),
		"39": _(u"Scattered Thunderstorms"),
		"40": _(u"Scattered Showers"),
		"41": _(u"Heavy Snow"),
		"42": _(u"Scattered Snow Showers"),
		"43": _(u"Heavy Snow"),
		"44": _(u"Partly Cloudy"),
		"45": _(u"Thunder Showers"),
		"46": _(u"Snow Showers"),
		"47": _(u"Isolated Thunderstorms"),
		"na": _(u"N/A"),
		"-": _(u"N/A")
	}

	conditions_text_es = {
        "0": _(u"Tornado"),
        "1": _(u"Tormenta Tropical"),
        "2": _(u"Huracá¡n"),
        "3": _(u"Tormentas Fuertes"),
        "4": _(u"Tormentas"),
        "5": _(u"Lluvia y Nieve Mezclada"),
        "6": _(u"Lluvia y Aguanieve Mezclada"),
        "7": _(u"Aguanieve"),
        "8": _(u"Llovizna Helada"),
        "9": _(u"Llovizna"),
        "10": _(u"Lluvia Engelante"), # o lluvia helada
        "11": _(u"Chaparrones"),
        "12": _(u"Chaparrones"),
        "13": _(u"Nieve Ligera"),
        "14": _(u"Nieve Ligera"),
        "15": _(u"Ventisca de Nieve"),
        "16": _(u"Nieve"),
        "17": _(u"Granizo"),
        "18": _(u"Aguanieve"),
        "19": _(u"Polvo"),
        "20": _(u"Niebla"),
        "21": _(u"Bruma"),
        "22": _(u"Humo"),
        "23": _(u"Tempestad"),
        "24": _(u"Ventoso"),
        "25": _(u"Fráo"),
        "26": _(u"Muy Nublado"),
        "27": _(u"Principalmente Nublado"),
        "28": _(u"Principalmente Nublado"),
        "29": _(u"Parcialmente Nublado"),
        "30": _(u"Parcialmente Nublado"),
        "31": _(u"Despejado"),
        "32": _(u"Despejado"),
        "33": _(u"Algo Nublado"),
        "34": _(u"Algo Nublado"),
        "35": _(u"Lluvia con Granizo"),
        "36": _(u"Calor"),
        "37": _(u"Tormentas Aisladas"),
        "38": _(u"Tormentas Dispersas"),
        "39": _(u"Tormentas Dispersas"),
        "40": _(u"Chubascos Dispersos"),
        "41": _(u"Nieve Pesada"),
        "42": _(u"Nevadas Débiles y Dispersas"),
        "43": _(u"Nevada Intensa"),
        "44": _(u"Nubes Dispersas"),
        "45": _(u"Tormentas"),
        "46": _(u"Nevadas Dispersas"),
        "47": _(u"Tormentas Aisladas"),
        "na": _(u"N/A"),
        "-": _(u"N/A")
    }

	conditions_text_fr = {
        "0": _(u"Tornade"),
        "1": _(u"Tempête Tropicale"),
        "2": _(u"Ouragan"),
        "3": _(u"Orages Violents"),
        "4": _(u"Orageux"),
        "5": _(u"Pluie et Neige"),
        "6": _(u"Pluie et Neige Mouillée"),
        "7": _(u"Variable avec averses"),
        "8": _(u"Bruine Givrante"),
        "9": _(u"Bruine"),
        "10": _(u"Pluie Glacante"),
        "11": _(u"Averses"),
        "12": _(u"Averses"),
        "13": _(u"Légère Neige"),
        "14": _(u"Forte Neige"),
        "15": _(u"Tempête de Neige"),
        "16": _(u"Neige"),
        "17": _(u"Grêle"),
        "18": _(u"Pluie/Neige"),
        "19": _(u"Nuage de poussière"),
        "20": _(u"Brouillard"),
        "21": _(u"Brume"),
        "22": _(u"Fumée"),
        "23": _(u"Tres Venteux"),
        "24": _(u"Venteux"),
        "25": _(u"Froid"),
        "26": _(u"Nuageux"),
        "27": _(u"Tres Nuageux"),
        "28": _(u"Tres Nuageux"),
        "29": _(u"Nuages Disséminés"),
        "30": _(u"Nuages Disséminés"),
        "31": _(u"Beau"),
        "32": _(u"Beau"),
        "33": _(u"Belles Éclaircies"),
        "34": _(u"Belles Éclaircies"),
        "35": _(u"Pluie avec Grêle"),
        "36": _(u"Chaleur"),
        "37": _(u"Orages Isolés"),
        "38": _(u"Orages Localisés"),
        "39": _(u"Orages Localisés"),
        "40": _(u"Averses Localisées"),
        "41": _(u"Neige Lourde"),
        "42": _(u"Tempête de Neige Localisées"),
        "43": _(u"Neige Lourde"),
        "44": _(u"Nuages Disséminés"),
        "45": _(u"Orages"),
        "46": _(u"Tempête de Neige"),
        "47": _(u"Orages Isolés"),
        "na": _(u"N/A"),
        "-": _(u"N/A")
	}
	
	conditions_weather_font = {
		"0": _(u"W"),
		"1": _(u"V"),
		"2": _(u"W"),
		"3": _(u"s"),
		"4": _(u"p"),
		"5": _(u"k"),
		"6": _(u"k"),
		"7": _(u"g"),
		"8": _(u"g"),
		"9": _(u"g"),
		"10": _(u"h"),
		"11": _(u"g"),
		"12": _(u"g"),
		"13": _(u"k"),
		"14": _(u"k"),
		"15": _(u"k"),
		"16": _(u"k"),
		"17": _(u"k"),
		"18": _(u"k"),
		"19": _(u"e"),
		"20": _(u"e"),
		"21": _(u"a"),
		"22": _(u"d"),
		"23": _(u"d"), 
		"24": _(u"d"),
		"25": _(u"d"),
		"26": _(u"e"),
		"27": _(u"e"),
		"28": _(u"e"),
		"29": _(u"c"),
		"30": _(u"c"),
		"31": _(u"a"),
		"32": _(u"a"),
		"33": _(u"b"),
		"34": _(u"b"),
		"35": _(u"k"),
		"36": _(u"a"),
		"37": _(u"f"),
		"38": _(u"f"),
		"39": _(u"f"),
		"40": _(u"g"),
		"41": _(u"k"),
		"42": _(u"k"),
		"43": _(u"k"),
		"44": _(u"b"),
		"45": _(u"g"),
		"46": _(u"k"),
		"47": _(u"f"),
		"na": _(u""),
		"-": _(u"")
	}

	conditions_moon_font = {
		"0": _(u"1"),
		"1": _(u"N"),
		"2": _(u"O"),
		"3": _(u"P"),
		"4": _(u"Q"),
		"5": _(u"R"),
		"6": _(u"S"),
		"7": _(u"T"),
		"8": _(u"U"),
		"9": _(u"V"),
		"10": _(u"W"),
		"11": _(u"X"),
		"12": _(u"Y"),
		"13": _(u"Z"),
		"14": _(u"0"),
		"15": _(u"0"),
		"16": _(u"A"),
		"17": _(u"B"),
		"18": _(u"C"),
		"19": _(u"D"),
		"20": _(u"E"),
		"21": _(u"F"),
		"22": _(u"G"),
		"23": _(u"H"),
		"24": _(u"I"),
		"25": _(u"J"),
		"26": _(u"K"),
		"27": _(u"L"),
		"28": _(u"M"),
		"29": _(u"1"),
		"na": _(u""),
		"-": _(u"")
	}
		
	day_of_week = {
		"Today": _(u"Today"),
		"Monday": _(u"Monday"),
		"Tuesday": _(u"Tuesday"),
		"Wednesday": _(u"Wednesday"),
		"Thursday": _(u"Thursday"),
		"Friday": _(u"Friday"),
		"Saturday": _(u"Saturday"),
		"Sunday": _(u"Sunday")
	}

	day_of_week_short = {
		"Today": _(u"Now"),
		"Monday": _(u"Mon"),
		"Tuesday": _(u"Tue"),
		"Wednesday": _(u"Wed"),
		"Thursday": _(u"Thu"),
		"Friday": _(u"Fri"),
		"Saturday": _(u"Sat"),
		"Sunday": _(u"Sun")
	}

	day_of_week_es = {
		"Today": _(u"hoy"),
		"Monday": _(u"lunes"),
		"Tuesday": _(u"martes"),
		"Wednesday": _(u"miércoles"),
		"Thursday": _(u"jueves"),
		"Friday": _(u"viernes"),
		"Saturday": _(u"sábado"),
		"Sunday": _(u"domingo")
	}

	day_of_week_short_es = {
		"Today": _(u"hoy"),
		"Monday": _(u"lun"),
		"Tuesday": _(u"mar"),
		"Wednesday": _(u"mié"),
		"Thursday": _(u"jue"),
		"Friday": _(u"vie"),
		"Saturday": _(u"sáb"),
		"Sunday": _(u"dom")
	}

	day_of_week_fr = {
		"Today": _(u"Aujourd'hui"),
		"Monday": _(u"Lundi"),
		"Tuesday": _(u"Mardi"),
		"Wednesday": _(u"Mercredi"),
		"Thursday": _(u"Jeudi"),
		"Friday": _(u"Vendredi"),
		"Saturday": _(u"Samedi"),
		"Sunday": _(u"Dimanche")
	}

	day_of_week_short_fr = {
		"Today": _(u"Auj"),
		"Monday": _(u"Lun"),
		"Tuesday": _(u"Mar"),
		"Wednesday": _(u"Mer"),
		"Thursday": _(u"Jeu"),
		"Friday": _(u"Ven"),
		"Saturday": _(u"Sam"),
		"Sunday": _(u"Dim")
	}

	bearing_arrow_font = {
		"N": _(u"i"),
		"NNE": _(u"j"),
		"NE": _(u"k"),
		"ENE": _(u"l"),
		"E": _(u"m"),
		"ESE": _(u"n"),
		"SE": _(u"o"),
		"SSE": _(u"p"),
		"S": _(u"a"),
		"SSW": _(u"b"),
		"SW": _(u"c"),
		"WSW": _(u"d"),
		"W": _(u"e"),
		"WNW": _(u"f"),
		"NW": _(u"g"),
		"NNW": _(u"h"),
		"N/A": _(u" ")
	}

	bearing_text_es = {
		"N": _(u"N"),
		"NNE": _(u"NNE"),
		"NE": _(u"NE"),
		"ENE": _(u"ENE"),
		"E": _(u"E"),
		"ESE": _(u"ESE"),
		"SE": _(u"SE"),
		"SSE": _(u"SSE"),
		"S": _(u"S"),
		"SSW": _(u"SSO"),
		"SW": _(u"SO"),
		"WSW": _(u"WOW"),
		"W": _(u"O"),
		"WNW": _(u"ONO"),
		"NW": _(u"NO"),
		"NNW": _(u"NNO"),
		"N/A": _(u"N\A")
	}

	bearing_text_fr = {
		"N": _(u"N"),
		"NNE": _(u"NNE"),
		"NE": _(u"NE"),
		"ENE": _(u"ENE"),
		"E": _(u"E"),
		"ESE": _(u"ESE"),
		"SE": _(u"SE"),
		"SSE": _(u"SSE"),
		"S": _(u"S"),
		"SSW": _(u"SSO"),
		"SW": _(u"SO"),
		"WSW": _(u"WOW"),
		"W": _(u"O"),
		"WNW": _(u"ONO"),
		"NW": _(u"NO"),
		"NNW": _(u"NNO"),
		"N/A": _(u"N\A")		
	}
			  
class GlobalWeather:

	current_conditions = []
	day_forecast = []
	night_forecast = []

	locale = "en"

	options = None
	weatherxmldoc = ""

 	TEMP_FILEPATH_CURRENT = "/tmp/conkyForecast-c-LOCATION.pkl"
	TEMP_FILEPATH_DAYFORECAST = "/tmp/conkyForecast-df-LOCATION.pkl"
	TEMP_FILEPATH_NIGHTFORECAST = "/tmp/conkyForecast-nf-LOCATION.pkl"
 	EXPIRY_MINUTES = 10
	DEFAULT_SPACING = u" "
		

	def __init__(self,options):

		self.options = options
		
		if self.options.locale == None:
			try:
				self.locale = locale.getdefaultlocale()[0][0:2]
				#self.locale = "es" #uncomment this line to force Spanish locale
				#self.locale = "fr" #uncomment this line to force French locale				
			except:
				print "locale not set"
		else:
			self.locale = self.options.locale
			#self.locale = "es" #uncomment this line to force Spanish locale
			#self.locale = "fr" #uncomment this line to force French locale	

		if self.options.verbose == True:
			print >> sys.stdout, "locale set to ",self.locale

	def getText(self,nodelist):
		rc = ""
		for node in nodelist:
			if node.nodeType == node.TEXT_NODE:
				rc = rc + node.data
		return rc


	def getSpaces(self,spaces):
		string = u""
		if spaces == None:
			string = self.DEFAULT_SPACING
		else:
			for i in range(0, spaces+1):
				string = string + u" "
		return string


	def isNumeric(self,string):
		try:
			dummy = float(string)
			return True
		except:
			return False

	def isConnectionAvailable(self):
		# ensure we can access weather.com's server by opening the url
		try:
			usock = urllib2.urlopen('http://xoap.weather.com')
			usock.close()
			return True
		except:
			return False

	def getBearingText(self,bearing):
		bearing = float(bearing)
		if bearing < 11.25:
			return u"N"
		elif bearing < 33.75:
			return u"NNE"
		elif bearing < 56.25:
			return u"NE"
		elif bearing < 78.75:
			return u"ENE"
		elif bearing < 101.25:
			return u"E"
		elif bearing < 123.75:
			return u"ESE"
		elif bearing < 146.25:
			return u"SE"
		elif bearing < 168.75:
			return u"SSE"
		elif bearing < 191.25:
			return u"S"
		elif bearing < 213.75:
			return u"SSW"
		elif bearing < 236.25:
			return u"SW"
		elif bearing < 258.75:
			return u"WSW"
		elif bearing < 281.25:
			return u"W"
		elif bearing < 303.75:
			return u"WNW"
		elif bearing < 326.25:
			return u"NW"
		elif bearing < 348.75:
			return u"NNW"
		else:
			return "N/A"

	def convertCelsiusToFahrenheit(self,temp):
		return str(int(floor(((float(temp)*9.0)/5.0)+32)))

	def convertKilometresToMiles(self,dist):
		return str(int(floor(float(dist)*0.621371192)))

	def convertMillibarsToInches(self,mb):
		return str(int(floor(float(mb)/33.8582)))

	def getTemplateList(self,template):

		templatelist = []
	
		for template_part in template.split("{"):
			if template_part != "":
				for template_part in template_part.split("}"):
					if template_part != "":
						templatelist.append(u""+template_part)

		return templatelist


	def getOutputText(self,datatype,startday,endday,night,shortweekday,imperial,hideunits,spaces):
		#try:
			output = u""
		
			# define current units for output
			if hideunits == False:
				if imperial == False:
					tempunit = u"°C"
					speedunit = u"kph"
					pressureunit = u"mb"
				else:
					tempunit = u"°F"
					speedunit = u"mph"
					pressureunit = u"in"
			else:
				tempunit = u"°"
				speedunit = u""
				pressureunit = u""

			if startday == None: # current conditions

				if datatype == "DW":
					if self.locale == "es":
						if shortweekday == True:
							output = WeatherText.day_of_week_short_es[self.current_conditions[0].day_of_week]
						else:
							output = WeatherText.day_of_week_es[self.current_conditions[0].day_of_week]
					elif self.locale == "fr":
						if shortweekday == True:
							output = WeatherText.day_of_week_short_fr[self.current_conditions[0].day_of_week]
						else:
							output = WeatherText.day_of_week_fr[self.current_conditions[0].day_of_week]							
					else:
						if shortweekday == True:
							output = WeatherText.day_of_week_short[self.current_conditions[0].day_of_week]
						else:
							output = WeatherText.day_of_week[self.current_conditions[0].day_of_week]
				elif datatype == "WF": # weather font
					output = WeatherText.conditions_weather_font[self.current_conditions[0].condition_code]
				elif datatype == "LT":
					string = self.current_conditions[0].low
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertCelsiusToFahrenheit(string)
						string = string + tempunit
					output = string
				elif datatype == "HT":
					string = self.current_conditions[0].high
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertCelsiusToFahrenheit(string)
						string = string + tempunit
					output = string
				elif datatype == "CC":
					if self.locale == "es":
						output = WeatherText.conditions_text_es[self.current_conditions[0].condition_code]
					elif self.locale == "fr":
						output = WeatherText.conditions_text_fr[self.current_conditions[0].condition_code]						
					else:
						output = WeatherText.conditions_text[self.current_conditions[0].condition_code] 
				elif datatype == "CT":
					output = self.current_conditions[0].condition_text
				elif datatype == "PC":
					string = self.current_conditions[0].precip
					if self.isNumeric(string) == True:
						string = string + u"%"
					output = string
				elif datatype == "HM":
					string = self.current_conditions[0].humidity
					if self.isNumeric(string) == True:
						string = string + u"%"
					output = string
				elif datatype == "WD":
					string = self.current_conditions[0].wind_dir
					if self.isNumeric(string) == True:
						string = self.getBearingText(string)
						
					if self.locale == "es":
						output = WeatherText.bearing_text_es[string]
					elif self.locale == "fr":
						output = WeatherText.bearing_text_fr[string]
					else:
						output = string
											
				elif datatype == "BF":
					string = self.current_conditions[0].wind_dir
					if self.isNumeric(string) == True:
						string = WeatherText.bearing_arrow_font[self.getBearingText(string)]
					output = string					
				elif datatype == "WS":
					string = self.current_conditions[0].wind_speed
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertKilometresToMiles(string)
						string = string + speedunit
					output = string
				elif datatype == "WG":
					string = self.current_conditions[0].wind_gusts
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertKilometresToMiles(string)
						string = string + speedunit
					output = string
				elif datatype == "CN":
					output = self.current_conditions[0].city
				elif datatype == "SR":
					output = self.current_conditions[0].sunrise
				elif datatype == "SS":
					output = self.current_conditions[0].sunset
				elif datatype == "MP":
					output = self.current_conditions[0].moon_phase
				elif datatype == "MF":
					output = WeatherText.conditions_moon_font[self.current_conditions[0].moon_icon]							
				elif datatype == "BR":
					string = self.current_conditions[0].bar_read
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertMillibarsToInches(string)
						string = string + pressureunit
					output = string
				elif datatype == "BD":
					output = self.current_conditions[0].bar_desc
				else:
					output = "\nERROR:Unknown data type requested"

			else: # forecast data

				if endday == None: # if no endday was set use startday
					endday = startday

				if night == True: # night forecast required

					for day_number in range(startday, endday+1):

						if datatype == "DW":
							if self.locale == "es":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_es[self.night_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_es[self.night_forecast[day_number].day_of_week]
							elif self.locale == "fr":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_fr[self.night_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_fr[self.night_forecast[day_number].day_of_week]
							else:
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short[self.night_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week[self.night_forecast[day_number].day_of_week]
						elif datatype == "WF": # weather font
							output = output + self.getSpaces(spaces) + WeatherText.conditions_weather_font[self.night_forecast[day_number].condition_code]
						elif datatype == "LT":
							string = self.night_forecast[day_number].low
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string

						elif datatype == "HT":
							string = self.night_forecast[day_number].high
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CC":
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_es[self.night_forecast[day_number].condition_code]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_fr[self.night_forecast[day_number].condition_code]
							else:
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text[self.night_forecast[day_number].condition_code]
						elif datatype == "CT":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].condition_text
						elif datatype == "PC":
							string = self.night_forecast[day_number].precip
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "HM":
							string = self.night_forecast[day_number].humidity
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WD":
							string = self.night_forecast[day_number].wind_dir
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_es[string]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_fr[string]
							else:
								output = output + self.getSpaces(spaces) + string
                            
						elif datatype == "BF":
							output = output + self.getSpaces(spaces) + WeatherText.bearing_arrow_font[self.night_forecast[day_number].wind_dir]
						elif datatype == "WS":
							string = self.night_forecast[day_number].wind_speed
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WG":
							string = self.night_forecast[day_number].wind_gusts
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CN":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].city
						elif datatype == "SR":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].sunrise
						elif datatype == "SS":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].sunset
						elif datatype == "MP":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].moon_phase
						elif datatype == "MF":
							output = output + self.getSpaces(spaces) + WeatherText.conditions_moon_font[self.night_forecast[day_number].moon_icon]
						elif datatype == "BR":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].bar_read
						elif datatype == "BD":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].bar_desc
						else:
							output = "\nERROR:Unknown data type requested"
							break

				else: # day forecast wanted

					for day_number in range(startday, endday+1):

						if datatype == "DW":
							if self.locale == "es":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_es[self.day_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_es[self.day_forecast[day_number].day_of_week]
							elif self.locale == "fr":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_fr[self.day_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_fr[self.day_forecast[day_number].day_of_week]									
							else:
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short[self.day_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week[self.day_forecast[day_number].day_of_week]
						elif datatype == "WF": # weather font
							output = output + self.getSpaces(spaces) + WeatherText.conditions_weather_font[self.day_forecast[day_number].condition_code]
						elif datatype == "LT":
							string = self.day_forecast[day_number].low
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "HT":
							string = self.day_forecast[day_number].high
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CC":
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_es[self.day_forecast[day_number].condition_code]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_fr[self.day_forecast[day_number].condition_code]
							else:
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text[self.day_forecast[day_number].condition_code]
						elif datatype == "CT":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].condition_text
						elif datatype == "PC":
							string = self.day_forecast[day_number].precip
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "HM":
							string = self.day_forecast[day_number].humidity
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WD":
							string = self.day_forecast[day_number].wind_dir
							
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_es[string]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_fr[string]
							else:
								output = output + self.getSpaces(spaces) + string	

						elif datatype == "BF":
							output = output + self.getSpaces(spaces) + WeatherText.bearing_arrow_font[self.day_forecast[day_number].wind_dir]
						elif datatype == "WS":
							string = self.day_forecast[day_number].wind_speed
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WG":
							string = self.day_forecast[day_number].wind_gusts
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CN":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].city
						elif datatype == "SR":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].sunrise
						elif datatype == "SS":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].sunset
						elif datatype == "MP":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].moon_phase
						elif datatype == "MF":
							output = output + self.getSpaces(spaces) + WeatherText.conditions_moon_font[self.day_forecast[day_number].moon_icon]
						elif datatype == "BR":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].bar_read
						elif datatype == "BD":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].bar_desc
						else:
							output = u"\nERROR:Unknown data type requested"
							break

			output = u""+output.strip(u" ") # lose leading/trailing spaces
			return output

		#except:
			#print "getOutputText:Unexpected error: ", sys.exc_info()[0]


	def getOutputTextFromTemplate(self,template):
		#try:

			# keys to template data
			DATATYPE_KEY = "--datatype="
			STARTDAY_KEY = "--startday="
			ENDDAY_KEY = "--endday="
			NIGHT_KEY = "--night"
			SHORTWEEKDAY_KEY = "--shortweekday"
			IMPERIAL_KEY = "--imperial"
			HIDEUNITS_KEY = "--hideunits"
			SPACES_KEY = "--spaces="

			output = u""

			optionfound = False

			#load the file
			try:
				fileinput = open(self.options.template)
				template = fileinput.read()
				fileinput.close()
			except:
				output = u"Template file no found!"

			templatelist = self.getTemplateList(template)

			# lets walk through the template list and determine the output for each item found
			for i in range(0,len(templatelist)-1):

				pos = templatelist[i].find(DATATYPE_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(DATATYPE_KEY)
					datatype = templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" ")
				else:
					datatype = None

				pos = templatelist[i].find(STARTDAY_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(STARTDAY_KEY)
					startday = int(templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" "))
				else:
					startday = None

				pos = templatelist[i].find(ENDDAY_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(ENDDAY_KEY)
					endday = int(templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" "))
				else:
					endday = None

				pos = templatelist[i].find(NIGHT_KEY)
				if pos != -1:
					optionfound = True
					night = True
				else:
					night = False

				pos = templatelist[i].find(SHORTWEEKDAY_KEY)
				if pos != -1:
					optionfound = True
					shortweekday = True
				else:
					shortweekday = False

				pos = templatelist[i].find(IMPERIAL_KEY)
				if pos != -1:
					optionfound = True
					imperial = True
				else:
					imperial = False

				pos = templatelist[i].find(HIDEUNITS_KEY)
				if pos != -1:
					optionfound = True
					hideunits = True
				else:
					hideunits = False

				pos = templatelist[i].find(SPACES_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(SPACES_KEY)
					spaces = int(templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" "))
				else:
					spaces = 1

				if optionfound == True:
					templatelist[i] = self.getOutputText(datatype,startday,endday,night,shortweekday,imperial,hideunits,spaces)
					optionfound = False

			# go through the list concatenating the output now that it's been populated
			for item in templatelist:
				output = output + item

			return output

		#except:
			#print "getOutputTextFromTemplate:Unexpected error: ", sys.exc_info()[0]


	def fetchData(self):

		# always fetch metric data, use conversation functions on this data
		file_path_current = self.TEMP_FILEPATH_CURRENT.replace("LOCATION",self.options.location)
		file_path_dayforecast = self.TEMP_FILEPATH_DAYFORECAST.replace("LOCATION",self.options.location)
		file_path_nightforecast = self.TEMP_FILEPATH_NIGHTFORECAST.replace("LOCATION",self.options.location)

		if self.isConnectionAvailable() == False:
			if os.path.exists(file_path_current):
				RefetchData = False
			else: # no connection, no cache, bang!
				print "No internet connection is available and no cached weather data exists."
		elif self.options.refetch == True:
			RefetchData = True
		else:
	 		# does the data need retrieving again?
	 		if os.path.exists(file_path_current):
	 			lastmodDate = time.localtime(os.stat(file_path_current)[ST_MTIME])
				expiryDate = (datetime.datetime.today() - datetime.timedelta(minutes=self.EXPIRY_MINUTES)).timetuple()

				if expiryDate > lastmodDate:
					RefetchData = True
				else:
					RefetchData = False
			else:
				RefetchData = True


                # fetch the current conditions data, either from the website or by 'unpickling'
 		if RefetchData == True:

			# obtain current conditions data from xoap service
			try:

				# http://xoap.weather.com/weather/local/UKXX0103?cc=*&dayf=5&link=xoap&prod=xoap&par=1061785028&key=e374effbfd74930b

				url = 'http://xoap.weather.com/weather/local/' + self.options.location + '?cc=*&dayf=8&link=xoap&prod=xoap&par=1061785028&key=e374effbfd74930b&unit=m'
				if self.options.verbose == True:
					print >> sys.stdout, "fetching weather data from ",url

				usock = urllib2.urlopen(url)
				xml = usock.read()
				usock.close()
				self.weatherxmldoc = minidom.parseString(xml)
			except:
				print "fetchData:Unexpected error: ", sys.exc_info()[0]
				print "Unable to contact weather source for current conditions"

			# tell the user if the location is bad...
			found = xml.find("Invalid location provided")
			if found != -1:
				print "Invalid location provided"

			# interrogate weather data, load into class structure and pickle it
			try:

				# prepare weather data lists
				self.current_conditions = []
				self.day_forecast = []
				self.night_forecast = []

				# collect general data
				weather_n = self.weatherxmldoc.documentElement
				location_n = weather_n.getElementsByTagName('loc')[0]
				city_n = location_n.getElementsByTagName('dnam')[0]
				city = self.getText(city_n.childNodes)

				# collect current conditions data
				day_of_week = u"Today"
				precip = u"N/A"
				sunrise_n = location_n.getElementsByTagName('sunr')[0]
				sunrise = self.getText(sunrise_n.childNodes)
				sunset_n = location_n.getElementsByTagName('suns')[0]
				sunset = self.getText(sunset_n.childNodes)
				current_condition_n = weather_n.getElementsByTagName('cc')[0]
				current_desc_n = current_condition_n.getElementsByTagName('t')[0]
				current_desc = self.getText(current_desc_n.childNodes)
				current_code_n = current_condition_n.getElementsByTagName('icon')[0]
				current_code = self.getText(current_code_n.childNodes)
				current_temp_n = current_condition_n.getElementsByTagName('tmp')[0]
				current_temp = self.getText(current_temp_n.childNodes)
				current_temp_feels_n = current_condition_n.getElementsByTagName('flik')[0]
				current_temp_feels = self.getText(current_temp_feels_n.childNodes)
				bar_n = current_condition_n.getElementsByTagName('bar')[0]
				bar_read_n = bar_n.getElementsByTagName('r')[0]
				bar_read = self.getText(bar_read_n.childNodes)
				bar_desc_n = bar_n.getElementsByTagName('d')[0]
				bar_desc = self.getText(bar_desc_n.childNodes)
				wind_n = current_condition_n.getElementsByTagName('wind')[0]
				wind_speed_n = wind_n.getElementsByTagName('s')[0]
				wind_speed = self.getText(wind_speed_n.childNodes)
				wind_gust_n = wind_n.getElementsByTagName('gust')[0]
				wind_gusts = self.getText(wind_gust_n.childNodes)
				wind_dir_n = wind_n.getElementsByTagName('d')[0]
				wind_direction = self.getText(wind_dir_n.childNodes)
				humidity_n = current_condition_n.getElementsByTagName('hmid')[0]
				humidity = self.getText(humidity_n.childNodes)
				moon_n = current_condition_n.getElementsByTagName('moon')[0]
				moon_icon_n = moon_n.getElementsByTagName('icon')[0]
				moon_icon = self.getText(moon_icon_n.childNodes)
				moon_phase_n = moon_n.getElementsByTagName('t')[0]
				moon_phase = self.getText(moon_phase_n.childNodes)
				current_conditions_data = WeatherData(day_of_week, current_temp_feels, current_temp, current_code, current_desc, precip, humidity, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
				self.current_conditions.append(current_conditions_data)

				# collect forecast data
				bar_read = u"N/A"
				bar_desc = u"N/A"
				moon_phase = u"N/A"
				moon_icon = u"na"
				forecast_n = weather_n.getElementsByTagName('dayf')[0]
				day_nodes = forecast_n.getElementsByTagName('day')
	
				for day in day_nodes:
					day_of_week = day.getAttribute('t')
					day_of_year = day.getAttribute('dt')
					high_temp_n = day.getElementsByTagName('hi')[0]
					high_temp = self.getText(high_temp_n.childNodes)
					low_temp_n = day.getElementsByTagName('low')[0]
					low_temp = self.getText(low_temp_n.childNodes)

					sunrise_n = day.getElementsByTagName('sunr')[0]
					sunrise = self.getText(sunrise_n.childNodes)
					sunset_n = day.getElementsByTagName('suns')[0]
					sunset = self.getText(sunset_n.childNodes)

					# day forecast specific data
					daytime_n = day.getElementsByTagName('part')[0] # day
					condition_code_n = daytime_n.getElementsByTagName('icon')[0]
					condition_code = self.getText(condition_code_n.childNodes)
					condition_n = daytime_n.getElementsByTagName('t')[0]
					condition = self.getText(condition_n.childNodes)
					precip_n = daytime_n.getElementsByTagName('ppcp')[0]
					precip = self.getText(precip_n.childNodes)
					humidity_n = daytime_n.getElementsByTagName('hmid')[0]
					humidity = self.getText(humidity_n.childNodes)
					wind_n = daytime_n.getElementsByTagName('wind')[0]
					wind_speed_n = wind_n.getElementsByTagName('s')[0]
					wind_speed = self.getText(wind_speed_n.childNodes)
					wind_direction_n = wind_n.getElementsByTagName('t')[0]
					wind_direction = self.getText(wind_direction_n.childNodes)
					wind_gusts_n = wind_n.getElementsByTagName('gust')[0]
					wind_gusts = self.getText(wind_gusts_n.childNodes)
					day_forecast_data = WeatherData(day_of_week, low_temp, high_temp, condition_code, condition, precip, humidity, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
					self.day_forecast.append(day_forecast_data) 	

					# night forecast specific data
					daytime_n = day.getElementsByTagName('part')[1] # night
					condition_code_n = daytime_n.getElementsByTagName('icon')[0]
					condition_code = self.getText(condition_code_n.childNodes)
					condition_n = daytime_n.getElementsByTagName('t')[0]
					condition = self.getText(condition_n.childNodes)
					precip_n = daytime_n.getElementsByTagName('ppcp')[0]
					precip = self.getText(precip_n.childNodes)
					humidity_n = daytime_n.getElementsByTagName('hmid')[0]
					humidity = self.getText(humidity_n.childNodes)
					wind_n = daytime_n.getElementsByTagName('wind')[0]
					wind_speed_n = wind_n.getElementsByTagName('s')[0]
					wind_speed = self.getText(wind_speed_n.childNodes)
					wind_direction_n = wind_n.getElementsByTagName('t')[0]
					wind_direction = self.getText(wind_direction_n.childNodes)
					wind_gusts_n = wind_n.getElementsByTagName('gust')[0]
					wind_gusts = self.getText(wind_gusts_n.childNodes)
					night_forecast_data = WeatherData(day_of_week, low_temp, high_temp, condition_code, condition, precip, humidity, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
					self.night_forecast.append(night_forecast_data) 


				# pickle the data for next time!
				fileoutput = open(file_path_current, 'w')
 				pickle.dump(self.current_conditions,fileoutput)
		 		fileoutput.close()

				fileoutput = open(file_path_dayforecast, 'w')
 				pickle.dump(self.day_forecast,fileoutput)
		 		fileoutput.close()

				fileoutput = open(file_path_nightforecast, 'w')
 				pickle.dump(self.night_forecast,fileoutput)
		 		fileoutput.close()
		
			except:
				print "fetchData:Unexpected error: ", sys.exc_info()[0]
				print "Unable to interrogate the weather data"

		else: # fetch weather data from pickled class files
			if self.options.verbose == True:
				print >> sys.stdout, "fetching weather data from file: ",file_path_current

 			fileinput = open(file_path_current, 'r')
			self.current_conditions = pickle.load(fileinput)
			fileinput.close()

			if self.options.verbose == True:
				print >> sys.stdout, "fetching day forecast data from files: ",file_path_dayforecast, file_path_nightforecast

 			fileinput = open(file_path_dayforecast, 'r')
			self.day_forecast = pickle.load(fileinput)
			fileinput.close()

			if self.options.verbose == True:
				print >> sys.stdout, "fetching day forecast data from files: ",file_path_nightforecast, file_path_nightforecast

 			fileinput = open(file_path_nightforecast, 'r')
			self.night_forecast = pickle.load(fileinput)
			fileinput.close()

	def outputData(self):
		#try:

			if self.options.template != None:

				output = self.getOutputTextFromTemplate(self.options.template)

			else:

				output = self.getOutputText(self.options.datatype,self.options.startday,self.options.endday,self.options.night,self.options.shortweekday,self.options.imperial,self.options.hideunits,self.options.spaces)


			print output.encode("utf-8")

		#except:
			#print "outputData:Unexpected error: ", sys.exc_info()[0]

if __name__ == "__main__":

	parser = CommandLineParser()
	(options, args) = parser.parse_args()

	if options.verbose == True:
		print >> sys.stdout, "location:",options.location
		print >> sys.stdout, "imperial:",options.imperial
		print >> sys.stdout, "datatype:",options.datatype
		print >> sys.stdout, "night:",options.night
		print >> sys.stdout, "start day:",options.startday
		print >> sys.stdout, "end day:",options.endday
		print >> sys.stdout, "spaces:",options.spaces
		print >> sys.stdout, "verbose:",options.verbose
		print >> sys.stdout, "refetch:",options.refetch

	# create new global weather object
	weather = GlobalWeather(options)
	weather.fetchData()
	weather.outputData()

Ubuntu Lucid Lynx 10.4 | Asus P5E Deluxe | Core2Quad Q9550 | ATI HD4870 512Mo | 4Go de RAM | Coolermaster Real Power M620 | Hitachi 1To

Hors ligne

#1459 Le 14/06/2008, à 13:18

Lenezir

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Nickel merci ! big_smile
Euh quel est ton fond d'écran stp ? big_smile

Dernière modification par Imoreion (Le 14/06/2008, à 13:25)

Hors ligne

#1460 Le 14/06/2008, à 17:56

rOm_08

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Il est dans le pack Mac4Lin_v0.4.

Le voici :

aquabluefq4.th.jpg


Ubuntu Lucid Lynx 10.4 | Asus P5E Deluxe | Core2Quad Q9550 | ATI HD4870 512Mo | 4Go de RAM | Coolermaster Real Power M620 | Hitachi 1To

Hors ligne

#1461 Le 14/06/2008, à 18:02

Lenezir

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Merci big_smile

Hors ligne

#1462 Le 14/06/2008, à 18:09

tof54

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

ainsi que calendar.sh stp smile

Hors ligne

#1463 Le 14/06/2008, à 18:41

Hamtaro

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

rOm_08 a écrit :

Oui je l'avais oublié lol

conkyForecast.py :

#!/usr/bin/python
# -*- coding: utf-8 -*-
###############################################################################
# conkyForecast.py is a (not so) simple (anymore) python script to gather 
# details of the current weather for use in conky.
#
#  Author: Kaivalagi
# Created: 13/04/2008
# Modifications:
#	14/04/2008	Allow day ranges for forecast data
#	14/04/2008	Check for connectivity to xoap service
#	18/04/2008	Allow the setting of spaces for ranged output
#	18/04/2008	Allow Night and Day forecast output
#	18/04/2008	Support locale for condition code text "CC" option, awaiting spanish language translation
#	18/04/2008	Use pickling for class data rather than opening xml, this bypasses the need to interrogate cached data
#	19/04/2008	Added spanish condition text - Thanks Bruce M
#	19/04/2008	Added isnumeric check on all numeric output with units suffix
#	19/04/2008	Altered pickle file naming to include location code
#	19/04/2008	Added spanish week days conversion via locale
#	20/04/2008	Added decent command argument parser
#	20/04/2008	Added --shortweekday option, if given the day of week data type is shortened to 3 characters
#	21/04/2008	Fixed locale options for forecast output
#	21/04/2008	Added --template option to allow custom output using a single exec call :)
#	21/04/2008	Added --hideunits option to remove, for example, mph and C from output
#	23/04/2008	Removed --imperial option from template, this MUST be set as a standard option on the script call and not used in the template file. 
#	23/04/2008	Readded --imperial option to template, enabling metric or imperial values per datatype. Note when using templates command line option will not work.
#	23/04/2008	Added output notifying user if the location given is bad
#	24/04/2008	Added handling for no connectivity, will revert to cached data now (erroring if no cache exists). Tests by trying to open xoap.weather.com
#	24/04/2008	Fixed Celsius to fahrenheit conversion
#	06/05/2008	Updated url used after webservice was updated
#	09/05/2008	Consolidated current condition and forecast data fetch into one call
#	09/05/2008	Added Sunrise and sunset to datatypes, these are specific to both current conditions and forecast data
#	09/05/2008	Added moon phase, barometer reading and barometer description to datatypes, these are only specific to current conditions and so are N/A in forecasted output
#	09/05/2008	Added unit conversions for barometer from mb to inches (imperial)
#   09/05/2008  Updated spanish condition text - Thanks Bruce M
#   10/05/2008  Added french locale data - Thanks benpaka
#   12/05/2008  Added new BF (bearing font) datatype to provide an arrow character (use with Arrow.ttf font) instead of NSEW output from WD (wind direction)
#   12/05/2008  Updated WD output to be locale specific, currently supports default english and spanish - Thanks Bruce M
#	18/05/2008	Added new MF (moon font) datatype to provide a moon font character (characters incorrect and no dedicated font yet).
#	21/05/2008	For current conditions the --datatype=LT option now displays "feels like" temperature rather than the current temperature
#	28/05/2008	Arrows reported to be pointing in the wrong direction. Correction provided by jjgomera
#	03/06/2008	Updated MF function, added days #26, #27, #28 nad #29 to complete the cycle. Corrections provided by Bruce M/uboops/HippyRandall
#
# TODO:
# Consolidate pkl files into one file/class
# ??? Any more requirements out there?

import sys, os, socket, urllib2, datetime, time
from xml.dom import minidom
from stat import *
from optparse import OptionParser
import locale
import gettext
import pickle
from math import *

APP="conkyForecast.py"
DIR=os.path.dirname (__file__) + '/locale'
gettext.bindtextdomain(APP, DIR)
gettext.textdomain(APP)
_ = gettext.gettext

class CommandLineParser:

	parser = None

	def __init__(self):

		self.parser = OptionParser()
		self.parser.add_option("-l","--location", dest="location", default="UKXX0103", type="string", metavar="CODE", help=u"location code for weather data [default: %default],Use the following url to determine your location code by city name: http://xoap.weather.com/search/search?where=Norwich")
		self.parser.add_option("-d","--datatype",dest="datatype", default="HT", type="string", metavar="DATATYPE", help=u"[default: %default] The data type options are: DW (Day Of Week), WF (Weather Font Output), LT (Forecast:Low Temp,Current:Feels Like Temp), HT (Forecast:High Temp,Current:Current Temp), CC (Current Conditions), CT (Conditions Text), PC (Precipitation Chance), HM (Humidity), WD (Wind Direction), WS (Wind Speed), WG (Wind Gusts), CN (City Name), SR (sunrise), SS (sunset), MP (moon phase), MF (moon font), BR (barometer reading), BD (barometer description). Not applicable at command line when using templates.")
		self.parser.add_option("-s","--startday",dest="startday", type="int", metavar="NUMBER", help=u"define the starting day number, if omitted current conditions are output. Not applicable at command line when using templates.")
		self.parser.add_option("-e","--endday",dest="endday", type="int", metavar="NUMBER", help=u"define the ending day number, if omitted only starting day data is output. Not applicable at command line when using templates.")
		self.parser.add_option("-S","--spaces",dest="spaces", type="int", default=1, metavar="NUMBER", help=u"[default: %default] Define the number of spaces between ranged output. Not applicable at command line when using templates.")
		self.parser.add_option("-t","--template",dest="template", type="string", metavar="FILE", help=u"define a template file to generate output in one call. A displayable item in the file is in the form {--datatype=HT --startday=1}. The following are possible options within each item: --datatype,--startday,--endday,--night,--shortweekday,--imperial,--hideunits,--spaces . Note that the short forms of the options are not currently supported! None of these options are applicable at command line when using templates.")
		self.parser.add_option("-L","--locale",dest="locale", type="string", help=u"override the system locale for language output (en=english, es=spanish, fr=french, more to come)")
		self.parser.add_option("-i","--imperial",dest="imperial", default=False, action="store_true", help=u"request imperial units, if omitted output is in metric. Not applicable at command line when using templates.")
		self.parser.add_option("-n","--night",dest="night", default=False, action="store_true", help=u"switch output to night data, if omitted day output will be output. Not applicable at command line when using templates.")
		self.parser.add_option("-w","--shortweekday",dest="shortweekday", default=False, action="store_true", help=u"Shorten the day of week data type to 3 characters. Not applicable at command line when using templates.")
		self.parser.add_option("-u","--hideunits",dest="hideunits", default=False, action="store_true", help=u"Hide units such as mph or C, degree symbols (°) are still shown. Not applicable at command line when using templates.")
		self.parser.add_option("-v","--verbose",dest="verbose", default=False, action="store_true", help=u"request verbose output, no a good idea when running through conky!")
		self.parser.add_option("-r","--refetch",dest="refetch", default=False, action="store_true", help=u"fetch data regardless of data expiry")

	def parse_args(self):
		(options, args) = self.parser.parse_args()
		return (options, args)

	def print_help(self):
		return self.parser.print_help()

class WeatherData:
	def __init__(self, day_of_week, low, high, condition_code, condition_text, precip, humidity, wind_dir, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc):
		self.day_of_week = u""+day_of_week
		self.low = u""+low
		self.high = u""+high
		self.condition_code = u""+condition_code
		self.condition_text = u""+condition_text
		self.precip = u""+precip
		self.humidity = u""+humidity
		self.wind_dir = u""+wind_dir
		self.wind_speed = u""+wind_speed
		self.wind_gusts = u""+wind_gusts
		self.city = u""+city
		self.sunrise = u""+sunrise
		self.sunset = u""+sunset
		self.moon_phase = u""+moon_phase
		self.moon_icon = u""+moon_icon		
		self.bar_read = u""+bar_read
		self.bar_desc = u""+bar_desc


class WeatherText:

	conditions_text = {
		"0": _(u"Tornado"),
		"1": _(u"Tropical Storm"),
		"2": _(u"Hurricane"),
		"3": _(u"Severe Thunderstorms"),
		"4": _(u"Thunderstorms"),
		"5": _(u"Mixed Rain and Snow"),
		"6": _(u"Mixed Rain and Sleet"),
		"7": _(u"Mixed Precipitation"),
		"8": _(u"Freezing Drizzle"),
		"9": _(u"Drizzle"),
		"10": _(u"Freezing Rain"),
		"11": _(u"Showers"),
		"12": _(u"Showers"),
		"13": _(u"Snow Flurries"),
		"14": _(u"Light Snow Showers"),
		"15": _(u"Blowing Snow"),
		"16": _(u"Snow"),
		"17": _(u"Hail"),
		"18": _(u"Sleet"),
		"19": _(u"Dust"),
		"20": _(u"Fog"),
		"21": _(u"Haze"),
		"22": _(u"Smoke"),
		"23": _(u"Blustery"), 
		"24": _(u"Windy"),
		"25": _(u"Cold"),
		"26": _(u"Cloudy"),
		"27": _(u"Mostly Cloudy"),
		"28": _(u"Mostly Cloudy"),
		"29": _(u"Partly Cloudy"),
		"30": _(u"Partly Cloudy"),
		"31": _(u"Clear"),
		"32": _(u"Clear"),
		"33": _(u"Fair"),
		"34": _(u"Fair"),
		"35": _(u"Mixed Rain and Hail"),
		"36": _(u"Hot"),
		"37": _(u"Isolated Thunderstorms"),
		"38": _(u"Scattered Thunderstorms"),
		"39": _(u"Scattered Thunderstorms"),
		"40": _(u"Scattered Showers"),
		"41": _(u"Heavy Snow"),
		"42": _(u"Scattered Snow Showers"),
		"43": _(u"Heavy Snow"),
		"44": _(u"Partly Cloudy"),
		"45": _(u"Thunder Showers"),
		"46": _(u"Snow Showers"),
		"47": _(u"Isolated Thunderstorms"),
		"na": _(u"N/A"),
		"-": _(u"N/A")
	}

	conditions_text_es = {
        "0": _(u"Tornado"),
        "1": _(u"Tormenta Tropical"),
        "2": _(u"Huracá¡n"),
        "3": _(u"Tormentas Fuertes"),
        "4": _(u"Tormentas"),
        "5": _(u"Lluvia y Nieve Mezclada"),
        "6": _(u"Lluvia y Aguanieve Mezclada"),
        "7": _(u"Aguanieve"),
        "8": _(u"Llovizna Helada"),
        "9": _(u"Llovizna"),
        "10": _(u"Lluvia Engelante"), # o lluvia helada
        "11": _(u"Chaparrones"),
        "12": _(u"Chaparrones"),
        "13": _(u"Nieve Ligera"),
        "14": _(u"Nieve Ligera"),
        "15": _(u"Ventisca de Nieve"),
        "16": _(u"Nieve"),
        "17": _(u"Granizo"),
        "18": _(u"Aguanieve"),
        "19": _(u"Polvo"),
        "20": _(u"Niebla"),
        "21": _(u"Bruma"),
        "22": _(u"Humo"),
        "23": _(u"Tempestad"),
        "24": _(u"Ventoso"),
        "25": _(u"Fráo"),
        "26": _(u"Muy Nublado"),
        "27": _(u"Principalmente Nublado"),
        "28": _(u"Principalmente Nublado"),
        "29": _(u"Parcialmente Nublado"),
        "30": _(u"Parcialmente Nublado"),
        "31": _(u"Despejado"),
        "32": _(u"Despejado"),
        "33": _(u"Algo Nublado"),
        "34": _(u"Algo Nublado"),
        "35": _(u"Lluvia con Granizo"),
        "36": _(u"Calor"),
        "37": _(u"Tormentas Aisladas"),
        "38": _(u"Tormentas Dispersas"),
        "39": _(u"Tormentas Dispersas"),
        "40": _(u"Chubascos Dispersos"),
        "41": _(u"Nieve Pesada"),
        "42": _(u"Nevadas Débiles y Dispersas"),
        "43": _(u"Nevada Intensa"),
        "44": _(u"Nubes Dispersas"),
        "45": _(u"Tormentas"),
        "46": _(u"Nevadas Dispersas"),
        "47": _(u"Tormentas Aisladas"),
        "na": _(u"N/A"),
        "-": _(u"N/A")
    }

	conditions_text_fr = {
        "0": _(u"Tornade"),
        "1": _(u"Tempête Tropicale"),
        "2": _(u"Ouragan"),
        "3": _(u"Orages Violents"),
        "4": _(u"Orageux"),
        "5": _(u"Pluie et Neige"),
        "6": _(u"Pluie et Neige Mouillée"),
        "7": _(u"Variable avec averses"),
        "8": _(u"Bruine Givrante"),
        "9": _(u"Bruine"),
        "10": _(u"Pluie Glacante"),
        "11": _(u"Averses"),
        "12": _(u"Averses"),
        "13": _(u"Légère Neige"),
        "14": _(u"Forte Neige"),
        "15": _(u"Tempête de Neige"),
        "16": _(u"Neige"),
        "17": _(u"Grêle"),
        "18": _(u"Pluie/Neige"),
        "19": _(u"Nuage de poussière"),
        "20": _(u"Brouillard"),
        "21": _(u"Brume"),
        "22": _(u"Fumée"),
        "23": _(u"Tres Venteux"),
        "24": _(u"Venteux"),
        "25": _(u"Froid"),
        "26": _(u"Nuageux"),
        "27": _(u"Tres Nuageux"),
        "28": _(u"Tres Nuageux"),
        "29": _(u"Nuages Disséminés"),
        "30": _(u"Nuages Disséminés"),
        "31": _(u"Beau"),
        "32": _(u"Beau"),
        "33": _(u"Belles Éclaircies"),
        "34": _(u"Belles Éclaircies"),
        "35": _(u"Pluie avec Grêle"),
        "36": _(u"Chaleur"),
        "37": _(u"Orages Isolés"),
        "38": _(u"Orages Localisés"),
        "39": _(u"Orages Localisés"),
        "40": _(u"Averses Localisées"),
        "41": _(u"Neige Lourde"),
        "42": _(u"Tempête de Neige Localisées"),
        "43": _(u"Neige Lourde"),
        "44": _(u"Nuages Disséminés"),
        "45": _(u"Orages"),
        "46": _(u"Tempête de Neige"),
        "47": _(u"Orages Isolés"),
        "na": _(u"N/A"),
        "-": _(u"N/A")
	}
	
	conditions_weather_font = {
		"0": _(u"W"),
		"1": _(u"V"),
		"2": _(u"W"),
		"3": _(u"s"),
		"4": _(u"p"),
		"5": _(u"k"),
		"6": _(u"k"),
		"7": _(u"g"),
		"8": _(u"g"),
		"9": _(u"g"),
		"10": _(u"h"),
		"11": _(u"g"),
		"12": _(u"g"),
		"13": _(u"k"),
		"14": _(u"k"),
		"15": _(u"k"),
		"16": _(u"k"),
		"17": _(u"k"),
		"18": _(u"k"),
		"19": _(u"e"),
		"20": _(u"e"),
		"21": _(u"a"),
		"22": _(u"d"),
		"23": _(u"d"), 
		"24": _(u"d"),
		"25": _(u"d"),
		"26": _(u"e"),
		"27": _(u"e"),
		"28": _(u"e"),
		"29": _(u"c"),
		"30": _(u"c"),
		"31": _(u"a"),
		"32": _(u"a"),
		"33": _(u"b"),
		"34": _(u"b"),
		"35": _(u"k"),
		"36": _(u"a"),
		"37": _(u"f"),
		"38": _(u"f"),
		"39": _(u"f"),
		"40": _(u"g"),
		"41": _(u"k"),
		"42": _(u"k"),
		"43": _(u"k"),
		"44": _(u"b"),
		"45": _(u"g"),
		"46": _(u"k"),
		"47": _(u"f"),
		"na": _(u""),
		"-": _(u"")
	}

	conditions_moon_font = {
		"0": _(u"1"),
		"1": _(u"N"),
		"2": _(u"O"),
		"3": _(u"P"),
		"4": _(u"Q"),
		"5": _(u"R"),
		"6": _(u"S"),
		"7": _(u"T"),
		"8": _(u"U"),
		"9": _(u"V"),
		"10": _(u"W"),
		"11": _(u"X"),
		"12": _(u"Y"),
		"13": _(u"Z"),
		"14": _(u"0"),
		"15": _(u"0"),
		"16": _(u"A"),
		"17": _(u"B"),
		"18": _(u"C"),
		"19": _(u"D"),
		"20": _(u"E"),
		"21": _(u"F"),
		"22": _(u"G"),
		"23": _(u"H"),
		"24": _(u"I"),
		"25": _(u"J"),
		"26": _(u"K"),
		"27": _(u"L"),
		"28": _(u"M"),
		"29": _(u"1"),
		"na": _(u""),
		"-": _(u"")
	}
		
	day_of_week = {
		"Today": _(u"Today"),
		"Monday": _(u"Monday"),
		"Tuesday": _(u"Tuesday"),
		"Wednesday": _(u"Wednesday"),
		"Thursday": _(u"Thursday"),
		"Friday": _(u"Friday"),
		"Saturday": _(u"Saturday"),
		"Sunday": _(u"Sunday")
	}

	day_of_week_short = {
		"Today": _(u"Now"),
		"Monday": _(u"Mon"),
		"Tuesday": _(u"Tue"),
		"Wednesday": _(u"Wed"),
		"Thursday": _(u"Thu"),
		"Friday": _(u"Fri"),
		"Saturday": _(u"Sat"),
		"Sunday": _(u"Sun")
	}

	day_of_week_es = {
		"Today": _(u"hoy"),
		"Monday": _(u"lunes"),
		"Tuesday": _(u"martes"),
		"Wednesday": _(u"miércoles"),
		"Thursday": _(u"jueves"),
		"Friday": _(u"viernes"),
		"Saturday": _(u"sábado"),
		"Sunday": _(u"domingo")
	}

	day_of_week_short_es = {
		"Today": _(u"hoy"),
		"Monday": _(u"lun"),
		"Tuesday": _(u"mar"),
		"Wednesday": _(u"mié"),
		"Thursday": _(u"jue"),
		"Friday": _(u"vie"),
		"Saturday": _(u"sáb"),
		"Sunday": _(u"dom")
	}

	day_of_week_fr = {
		"Today": _(u"Aujourd'hui"),
		"Monday": _(u"Lundi"),
		"Tuesday": _(u"Mardi"),
		"Wednesday": _(u"Mercredi"),
		"Thursday": _(u"Jeudi"),
		"Friday": _(u"Vendredi"),
		"Saturday": _(u"Samedi"),
		"Sunday": _(u"Dimanche")
	}

	day_of_week_short_fr = {
		"Today": _(u"Auj"),
		"Monday": _(u"Lun"),
		"Tuesday": _(u"Mar"),
		"Wednesday": _(u"Mer"),
		"Thursday": _(u"Jeu"),
		"Friday": _(u"Ven"),
		"Saturday": _(u"Sam"),
		"Sunday": _(u"Dim")
	}

	bearing_arrow_font = {
		"N": _(u"i"),
		"NNE": _(u"j"),
		"NE": _(u"k"),
		"ENE": _(u"l"),
		"E": _(u"m"),
		"ESE": _(u"n"),
		"SE": _(u"o"),
		"SSE": _(u"p"),
		"S": _(u"a"),
		"SSW": _(u"b"),
		"SW": _(u"c"),
		"WSW": _(u"d"),
		"W": _(u"e"),
		"WNW": _(u"f"),
		"NW": _(u"g"),
		"NNW": _(u"h"),
		"N/A": _(u" ")
	}

	bearing_text_es = {
		"N": _(u"N"),
		"NNE": _(u"NNE"),
		"NE": _(u"NE"),
		"ENE": _(u"ENE"),
		"E": _(u"E"),
		"ESE": _(u"ESE"),
		"SE": _(u"SE"),
		"SSE": _(u"SSE"),
		"S": _(u"S"),
		"SSW": _(u"SSO"),
		"SW": _(u"SO"),
		"WSW": _(u"WOW"),
		"W": _(u"O"),
		"WNW": _(u"ONO"),
		"NW": _(u"NO"),
		"NNW": _(u"NNO"),
		"N/A": _(u"N\A")
	}

	bearing_text_fr = {
		"N": _(u"N"),
		"NNE": _(u"NNE"),
		"NE": _(u"NE"),
		"ENE": _(u"ENE"),
		"E": _(u"E"),
		"ESE": _(u"ESE"),
		"SE": _(u"SE"),
		"SSE": _(u"SSE"),
		"S": _(u"S"),
		"SSW": _(u"SSO"),
		"SW": _(u"SO"),
		"WSW": _(u"WOW"),
		"W": _(u"O"),
		"WNW": _(u"ONO"),
		"NW": _(u"NO"),
		"NNW": _(u"NNO"),
		"N/A": _(u"N\A")		
	}
			  
class GlobalWeather:

	current_conditions = []
	day_forecast = []
	night_forecast = []

	locale = "en"

	options = None
	weatherxmldoc = ""

 	TEMP_FILEPATH_CURRENT = "/tmp/conkyForecast-c-LOCATION.pkl"
	TEMP_FILEPATH_DAYFORECAST = "/tmp/conkyForecast-df-LOCATION.pkl"
	TEMP_FILEPATH_NIGHTFORECAST = "/tmp/conkyForecast-nf-LOCATION.pkl"
 	EXPIRY_MINUTES = 10
	DEFAULT_SPACING = u" "
		

	def __init__(self,options):

		self.options = options
		
		if self.options.locale == None:
			try:
				self.locale = locale.getdefaultlocale()[0][0:2]
				#self.locale = "es" #uncomment this line to force Spanish locale
				#self.locale = "fr" #uncomment this line to force French locale				
			except:
				print "locale not set"
		else:
			self.locale = self.options.locale
			#self.locale = "es" #uncomment this line to force Spanish locale
			#self.locale = "fr" #uncomment this line to force French locale	

		if self.options.verbose == True:
			print >> sys.stdout, "locale set to ",self.locale

	def getText(self,nodelist):
		rc = ""
		for node in nodelist:
			if node.nodeType == node.TEXT_NODE:
				rc = rc + node.data
		return rc


	def getSpaces(self,spaces):
		string = u""
		if spaces == None:
			string = self.DEFAULT_SPACING
		else:
			for i in range(0, spaces+1):
				string = string + u" "
		return string


	def isNumeric(self,string):
		try:
			dummy = float(string)
			return True
		except:
			return False

	def isConnectionAvailable(self):
		# ensure we can access weather.com's server by opening the url
		try:
			usock = urllib2.urlopen('http://xoap.weather.com')
			usock.close()
			return True
		except:
			return False

	def getBearingText(self,bearing):
		bearing = float(bearing)
		if bearing < 11.25:
			return u"N"
		elif bearing < 33.75:
			return u"NNE"
		elif bearing < 56.25:
			return u"NE"
		elif bearing < 78.75:
			return u"ENE"
		elif bearing < 101.25:
			return u"E"
		elif bearing < 123.75:
			return u"ESE"
		elif bearing < 146.25:
			return u"SE"
		elif bearing < 168.75:
			return u"SSE"
		elif bearing < 191.25:
			return u"S"
		elif bearing < 213.75:
			return u"SSW"
		elif bearing < 236.25:
			return u"SW"
		elif bearing < 258.75:
			return u"WSW"
		elif bearing < 281.25:
			return u"W"
		elif bearing < 303.75:
			return u"WNW"
		elif bearing < 326.25:
			return u"NW"
		elif bearing < 348.75:
			return u"NNW"
		else:
			return "N/A"

	def convertCelsiusToFahrenheit(self,temp):
		return str(int(floor(((float(temp)*9.0)/5.0)+32)))

	def convertKilometresToMiles(self,dist):
		return str(int(floor(float(dist)*0.621371192)))

	def convertMillibarsToInches(self,mb):
		return str(int(floor(float(mb)/33.8582)))

	def getTemplateList(self,template):

		templatelist = []
	
		for template_part in template.split("{"):
			if template_part != "":
				for template_part in template_part.split("}"):
					if template_part != "":
						templatelist.append(u""+template_part)

		return templatelist


	def getOutputText(self,datatype,startday,endday,night,shortweekday,imperial,hideunits,spaces):
		#try:
			output = u""
		
			# define current units for output
			if hideunits == False:
				if imperial == False:
					tempunit = u"°C"
					speedunit = u"kph"
					pressureunit = u"mb"
				else:
					tempunit = u"°F"
					speedunit = u"mph"
					pressureunit = u"in"
			else:
				tempunit = u"°"
				speedunit = u""
				pressureunit = u""

			if startday == None: # current conditions

				if datatype == "DW":
					if self.locale == "es":
						if shortweekday == True:
							output = WeatherText.day_of_week_short_es[self.current_conditions[0].day_of_week]
						else:
							output = WeatherText.day_of_week_es[self.current_conditions[0].day_of_week]
					elif self.locale == "fr":
						if shortweekday == True:
							output = WeatherText.day_of_week_short_fr[self.current_conditions[0].day_of_week]
						else:
							output = WeatherText.day_of_week_fr[self.current_conditions[0].day_of_week]							
					else:
						if shortweekday == True:
							output = WeatherText.day_of_week_short[self.current_conditions[0].day_of_week]
						else:
							output = WeatherText.day_of_week[self.current_conditions[0].day_of_week]
				elif datatype == "WF": # weather font
					output = WeatherText.conditions_weather_font[self.current_conditions[0].condition_code]
				elif datatype == "LT":
					string = self.current_conditions[0].low
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertCelsiusToFahrenheit(string)
						string = string + tempunit
					output = string
				elif datatype == "HT":
					string = self.current_conditions[0].high
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertCelsiusToFahrenheit(string)
						string = string + tempunit
					output = string
				elif datatype == "CC":
					if self.locale == "es":
						output = WeatherText.conditions_text_es[self.current_conditions[0].condition_code]
					elif self.locale == "fr":
						output = WeatherText.conditions_text_fr[self.current_conditions[0].condition_code]						
					else:
						output = WeatherText.conditions_text[self.current_conditions[0].condition_code] 
				elif datatype == "CT":
					output = self.current_conditions[0].condition_text
				elif datatype == "PC":
					string = self.current_conditions[0].precip
					if self.isNumeric(string) == True:
						string = string + u"%"
					output = string
				elif datatype == "HM":
					string = self.current_conditions[0].humidity
					if self.isNumeric(string) == True:
						string = string + u"%"
					output = string
				elif datatype == "WD":
					string = self.current_conditions[0].wind_dir
					if self.isNumeric(string) == True:
						string = self.getBearingText(string)
						
					if self.locale == "es":
						output = WeatherText.bearing_text_es[string]
					elif self.locale == "fr":
						output = WeatherText.bearing_text_fr[string]
					else:
						output = string
											
				elif datatype == "BF":
					string = self.current_conditions[0].wind_dir
					if self.isNumeric(string) == True:
						string = WeatherText.bearing_arrow_font[self.getBearingText(string)]
					output = string					
				elif datatype == "WS":
					string = self.current_conditions[0].wind_speed
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertKilometresToMiles(string)
						string = string + speedunit
					output = string
				elif datatype == "WG":
					string = self.current_conditions[0].wind_gusts
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertKilometresToMiles(string)
						string = string + speedunit
					output = string
				elif datatype == "CN":
					output = self.current_conditions[0].city
				elif datatype == "SR":
					output = self.current_conditions[0].sunrise
				elif datatype == "SS":
					output = self.current_conditions[0].sunset
				elif datatype == "MP":
					output = self.current_conditions[0].moon_phase
				elif datatype == "MF":
					output = WeatherText.conditions_moon_font[self.current_conditions[0].moon_icon]							
				elif datatype == "BR":
					string = self.current_conditions[0].bar_read
					if self.isNumeric(string) == True:
						if imperial == True:
							string = self.convertMillibarsToInches(string)
						string = string + pressureunit
					output = string
				elif datatype == "BD":
					output = self.current_conditions[0].bar_desc
				else:
					output = "\nERROR:Unknown data type requested"

			else: # forecast data

				if endday == None: # if no endday was set use startday
					endday = startday

				if night == True: # night forecast required

					for day_number in range(startday, endday+1):

						if datatype == "DW":
							if self.locale == "es":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_es[self.night_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_es[self.night_forecast[day_number].day_of_week]
							elif self.locale == "fr":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_fr[self.night_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_fr[self.night_forecast[day_number].day_of_week]
							else:
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short[self.night_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week[self.night_forecast[day_number].day_of_week]
						elif datatype == "WF": # weather font
							output = output + self.getSpaces(spaces) + WeatherText.conditions_weather_font[self.night_forecast[day_number].condition_code]
						elif datatype == "LT":
							string = self.night_forecast[day_number].low
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string

						elif datatype == "HT":
							string = self.night_forecast[day_number].high
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CC":
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_es[self.night_forecast[day_number].condition_code]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_fr[self.night_forecast[day_number].condition_code]
							else:
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text[self.night_forecast[day_number].condition_code]
						elif datatype == "CT":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].condition_text
						elif datatype == "PC":
							string = self.night_forecast[day_number].precip
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "HM":
							string = self.night_forecast[day_number].humidity
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WD":
							string = self.night_forecast[day_number].wind_dir
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_es[string]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_fr[string]
							else:
								output = output + self.getSpaces(spaces) + string
                            
						elif datatype == "BF":
							output = output + self.getSpaces(spaces) + WeatherText.bearing_arrow_font[self.night_forecast[day_number].wind_dir]
						elif datatype == "WS":
							string = self.night_forecast[day_number].wind_speed
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WG":
							string = self.night_forecast[day_number].wind_gusts
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CN":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].city
						elif datatype == "SR":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].sunrise
						elif datatype == "SS":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].sunset
						elif datatype == "MP":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].moon_phase
						elif datatype == "MF":
							output = output + self.getSpaces(spaces) + WeatherText.conditions_moon_font[self.night_forecast[day_number].moon_icon]
						elif datatype == "BR":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].bar_read
						elif datatype == "BD":
							output = output + self.getSpaces(spaces) + self.night_forecast[day_number].bar_desc
						else:
							output = "\nERROR:Unknown data type requested"
							break

				else: # day forecast wanted

					for day_number in range(startday, endday+1):

						if datatype == "DW":
							if self.locale == "es":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_es[self.day_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_es[self.day_forecast[day_number].day_of_week]
							elif self.locale == "fr":
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short_fr[self.day_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_fr[self.day_forecast[day_number].day_of_week]									
							else:
								if shortweekday == True:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week_short[self.day_forecast[day_number].day_of_week]
								else:
									output = output + self.getSpaces(spaces) + WeatherText.day_of_week[self.day_forecast[day_number].day_of_week]
						elif datatype == "WF": # weather font
							output = output + self.getSpaces(spaces) + WeatherText.conditions_weather_font[self.day_forecast[day_number].condition_code]
						elif datatype == "LT":
							string = self.day_forecast[day_number].low
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "HT":
							string = self.day_forecast[day_number].high
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertCelsiusToFahrenheit(string)
								string = string + tempunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CC":
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_es[self.day_forecast[day_number].condition_code]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text_fr[self.day_forecast[day_number].condition_code]
							else:
								output = output + self.getSpaces(spaces) + WeatherText.conditions_text[self.day_forecast[day_number].condition_code]
						elif datatype == "CT":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].condition_text
						elif datatype == "PC":
							string = self.day_forecast[day_number].precip
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "HM":
							string = self.day_forecast[day_number].humidity
							if self.isNumeric(string) == True:
								string = string + u"%"
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WD":
							string = self.day_forecast[day_number].wind_dir
							
							if self.locale == "es":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_es[string]
							elif self.locale == "fr":
								output = output + self.getSpaces(spaces) + WeatherText.bearing_text_fr[string]
							else:
								output = output + self.getSpaces(spaces) + string	

						elif datatype == "BF":
							output = output + self.getSpaces(spaces) + WeatherText.bearing_arrow_font[self.day_forecast[day_number].wind_dir]
						elif datatype == "WS":
							string = self.day_forecast[day_number].wind_speed
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "WG":
							string = self.day_forecast[day_number].wind_gusts
							if self.isNumeric(string) == True:
								if imperial == True:
									string = self.convertKilometresToMiles(string)
								string = string + speedunit
							output = output + self.getSpaces(spaces) + string
						elif datatype == "CN":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].city
						elif datatype == "SR":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].sunrise
						elif datatype == "SS":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].sunset
						elif datatype == "MP":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].moon_phase
						elif datatype == "MF":
							output = output + self.getSpaces(spaces) + WeatherText.conditions_moon_font[self.day_forecast[day_number].moon_icon]
						elif datatype == "BR":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].bar_read
						elif datatype == "BD":
							output = output + self.getSpaces(spaces) + self.day_forecast[day_number].bar_desc
						else:
							output = u"\nERROR:Unknown data type requested"
							break

			output = u""+output.strip(u" ") # lose leading/trailing spaces
			return output

		#except:
			#print "getOutputText:Unexpected error: ", sys.exc_info()[0]


	def getOutputTextFromTemplate(self,template):
		#try:

			# keys to template data
			DATATYPE_KEY = "--datatype="
			STARTDAY_KEY = "--startday="
			ENDDAY_KEY = "--endday="
			NIGHT_KEY = "--night"
			SHORTWEEKDAY_KEY = "--shortweekday"
			IMPERIAL_KEY = "--imperial"
			HIDEUNITS_KEY = "--hideunits"
			SPACES_KEY = "--spaces="

			output = u""

			optionfound = False

			#load the file
			try:
				fileinput = open(self.options.template)
				template = fileinput.read()
				fileinput.close()
			except:
				output = u"Template file no found!"

			templatelist = self.getTemplateList(template)

			# lets walk through the template list and determine the output for each item found
			for i in range(0,len(templatelist)-1):

				pos = templatelist[i].find(DATATYPE_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(DATATYPE_KEY)
					datatype = templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" ")
				else:
					datatype = None

				pos = templatelist[i].find(STARTDAY_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(STARTDAY_KEY)
					startday = int(templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" "))
				else:
					startday = None

				pos = templatelist[i].find(ENDDAY_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(ENDDAY_KEY)
					endday = int(templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" "))
				else:
					endday = None

				pos = templatelist[i].find(NIGHT_KEY)
				if pos != -1:
					optionfound = True
					night = True
				else:
					night = False

				pos = templatelist[i].find(SHORTWEEKDAY_KEY)
				if pos != -1:
					optionfound = True
					shortweekday = True
				else:
					shortweekday = False

				pos = templatelist[i].find(IMPERIAL_KEY)
				if pos != -1:
					optionfound = True
					imperial = True
				else:
					imperial = False

				pos = templatelist[i].find(HIDEUNITS_KEY)
				if pos != -1:
					optionfound = True
					hideunits = True
				else:
					hideunits = False

				pos = templatelist[i].find(SPACES_KEY)
				if pos != -1:
					optionfound = True
					pos = pos + len(SPACES_KEY)
					spaces = int(templatelist[i][pos:pos+4].strip("}").strip("{").strip("-").strip(" "))
				else:
					spaces = 1

				if optionfound == True:
					templatelist[i] = self.getOutputText(datatype,startday,endday,night,shortweekday,imperial,hideunits,spaces)
					optionfound = False

			# go through the list concatenating the output now that it's been populated
			for item in templatelist:
				output = output + item

			return output

		#except:
			#print "getOutputTextFromTemplate:Unexpected error: ", sys.exc_info()[0]


	def fetchData(self):

		# always fetch metric data, use conversation functions on this data
		file_path_current = self.TEMP_FILEPATH_CURRENT.replace("LOCATION",self.options.location)
		file_path_dayforecast = self.TEMP_FILEPATH_DAYFORECAST.replace("LOCATION",self.options.location)
		file_path_nightforecast = self.TEMP_FILEPATH_NIGHTFORECAST.replace("LOCATION",self.options.location)

		if self.isConnectionAvailable() == False:
			if os.path.exists(file_path_current):
				RefetchData = False
			else: # no connection, no cache, bang!
				print "No internet connection is available and no cached weather data exists."
		elif self.options.refetch == True:
			RefetchData = True
		else:
	 		# does the data need retrieving again?
	 		if os.path.exists(file_path_current):
	 			lastmodDate = time.localtime(os.stat(file_path_current)[ST_MTIME])
				expiryDate = (datetime.datetime.today() - datetime.timedelta(minutes=self.EXPIRY_MINUTES)).timetuple()

				if expiryDate > lastmodDate:
					RefetchData = True
				else:
					RefetchData = False
			else:
				RefetchData = True


                # fetch the current conditions data, either from the website or by 'unpickling'
 		if RefetchData == True:

			# obtain current conditions data from xoap service
			try:

				# http://xoap.weather.com/weather/local/UKXX0103?cc=*&dayf=5&link=xoap&prod=xoap&par=1061785028&key=e374effbfd74930b

				url = 'http://xoap.weather.com/weather/local/' + self.options.location + '?cc=*&dayf=8&link=xoap&prod=xoap&par=1061785028&key=e374effbfd74930b&unit=m'
				if self.options.verbose == True:
					print >> sys.stdout, "fetching weather data from ",url

				usock = urllib2.urlopen(url)
				xml = usock.read()
				usock.close()
				self.weatherxmldoc = minidom.parseString(xml)
			except:
				print "fetchData:Unexpected error: ", sys.exc_info()[0]
				print "Unable to contact weather source for current conditions"

			# tell the user if the location is bad...
			found = xml.find("Invalid location provided")
			if found != -1:
				print "Invalid location provided"

			# interrogate weather data, load into class structure and pickle it
			try:

				# prepare weather data lists
				self.current_conditions = []
				self.day_forecast = []
				self.night_forecast = []

				# collect general data
				weather_n = self.weatherxmldoc.documentElement
				location_n = weather_n.getElementsByTagName('loc')[0]
				city_n = location_n.getElementsByTagName('dnam')[0]
				city = self.getText(city_n.childNodes)

				# collect current conditions data
				day_of_week = u"Today"
				precip = u"N/A"
				sunrise_n = location_n.getElementsByTagName('sunr')[0]
				sunrise = self.getText(sunrise_n.childNodes)
				sunset_n = location_n.getElementsByTagName('suns')[0]
				sunset = self.getText(sunset_n.childNodes)
				current_condition_n = weather_n.getElementsByTagName('cc')[0]
				current_desc_n = current_condition_n.getElementsByTagName('t')[0]
				current_desc = self.getText(current_desc_n.childNodes)
				current_code_n = current_condition_n.getElementsByTagName('icon')[0]
				current_code = self.getText(current_code_n.childNodes)
				current_temp_n = current_condition_n.getElementsByTagName('tmp')[0]
				current_temp = self.getText(current_temp_n.childNodes)
				current_temp_feels_n = current_condition_n.getElementsByTagName('flik')[0]
				current_temp_feels = self.getText(current_temp_feels_n.childNodes)
				bar_n = current_condition_n.getElementsByTagName('bar')[0]
				bar_read_n = bar_n.getElementsByTagName('r')[0]
				bar_read = self.getText(bar_read_n.childNodes)
				bar_desc_n = bar_n.getElementsByTagName('d')[0]
				bar_desc = self.getText(bar_desc_n.childNodes)
				wind_n = current_condition_n.getElementsByTagName('wind')[0]
				wind_speed_n = wind_n.getElementsByTagName('s')[0]
				wind_speed = self.getText(wind_speed_n.childNodes)
				wind_gust_n = wind_n.getElementsByTagName('gust')[0]
				wind_gusts = self.getText(wind_gust_n.childNodes)
				wind_dir_n = wind_n.getElementsByTagName('d')[0]
				wind_direction = self.getText(wind_dir_n.childNodes)
				humidity_n = current_condition_n.getElementsByTagName('hmid')[0]
				humidity = self.getText(humidity_n.childNodes)
				moon_n = current_condition_n.getElementsByTagName('moon')[0]
				moon_icon_n = moon_n.getElementsByTagName('icon')[0]
				moon_icon = self.getText(moon_icon_n.childNodes)
				moon_phase_n = moon_n.getElementsByTagName('t')[0]
				moon_phase = self.getText(moon_phase_n.childNodes)
				current_conditions_data = WeatherData(day_of_week, current_temp_feels, current_temp, current_code, current_desc, precip, humidity, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
				self.current_conditions.append(current_conditions_data)

				# collect forecast data
				bar_read = u"N/A"
				bar_desc = u"N/A"
				moon_phase = u"N/A"
				moon_icon = u"na"
				forecast_n = weather_n.getElementsByTagName('dayf')[0]
				day_nodes = forecast_n.getElementsByTagName('day')
	
				for day in day_nodes:
					day_of_week = day.getAttribute('t')
					day_of_year = day.getAttribute('dt')
					high_temp_n = day.getElementsByTagName('hi')[0]
					high_temp = self.getText(high_temp_n.childNodes)
					low_temp_n = day.getElementsByTagName('low')[0]
					low_temp = self.getText(low_temp_n.childNodes)

					sunrise_n = day.getElementsByTagName('sunr')[0]
					sunrise = self.getText(sunrise_n.childNodes)
					sunset_n = day.getElementsByTagName('suns')[0]
					sunset = self.getText(sunset_n.childNodes)

					# day forecast specific data
					daytime_n = day.getElementsByTagName('part')[0] # day
					condition_code_n = daytime_n.getElementsByTagName('icon')[0]
					condition_code = self.getText(condition_code_n.childNodes)
					condition_n = daytime_n.getElementsByTagName('t')[0]
					condition = self.getText(condition_n.childNodes)
					precip_n = daytime_n.getElementsByTagName('ppcp')[0]
					precip = self.getText(precip_n.childNodes)
					humidity_n = daytime_n.getElementsByTagName('hmid')[0]
					humidity = self.getText(humidity_n.childNodes)
					wind_n = daytime_n.getElementsByTagName('wind')[0]
					wind_speed_n = wind_n.getElementsByTagName('s')[0]
					wind_speed = self.getText(wind_speed_n.childNodes)
					wind_direction_n = wind_n.getElementsByTagName('t')[0]
					wind_direction = self.getText(wind_direction_n.childNodes)
					wind_gusts_n = wind_n.getElementsByTagName('gust')[0]
					wind_gusts = self.getText(wind_gusts_n.childNodes)
					day_forecast_data = WeatherData(day_of_week, low_temp, high_temp, condition_code, condition, precip, humidity, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
					self.day_forecast.append(day_forecast_data) 	

					# night forecast specific data
					daytime_n = day.getElementsByTagName('part')[1] # night
					condition_code_n = daytime_n.getElementsByTagName('icon')[0]
					condition_code = self.getText(condition_code_n.childNodes)
					condition_n = daytime_n.getElementsByTagName('t')[0]
					condition = self.getText(condition_n.childNodes)
					precip_n = daytime_n.getElementsByTagName('ppcp')[0]
					precip = self.getText(precip_n.childNodes)
					humidity_n = daytime_n.getElementsByTagName('hmid')[0]
					humidity = self.getText(humidity_n.childNodes)
					wind_n = daytime_n.getElementsByTagName('wind')[0]
					wind_speed_n = wind_n.getElementsByTagName('s')[0]
					wind_speed = self.getText(wind_speed_n.childNodes)
					wind_direction_n = wind_n.getElementsByTagName('t')[0]
					wind_direction = self.getText(wind_direction_n.childNodes)
					wind_gusts_n = wind_n.getElementsByTagName('gust')[0]
					wind_gusts = self.getText(wind_gusts_n.childNodes)
					night_forecast_data = WeatherData(day_of_week, low_temp, high_temp, condition_code, condition, precip, humidity, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
					self.night_forecast.append(night_forecast_data) 


				# pickle the data for next time!
				fileoutput = open(file_path_current, 'w')
 				pickle.dump(self.current_conditions,fileoutput)
		 		fileoutput.close()

				fileoutput = open(file_path_dayforecast, 'w')
 				pickle.dump(self.day_forecast,fileoutput)
		 		fileoutput.close()

				fileoutput = open(file_path_nightforecast, 'w')
 				pickle.dump(self.night_forecast,fileoutput)
		 		fileoutput.close()
		
			except:
				print "fetchData:Unexpected error: ", sys.exc_info()[0]
				print "Unable to interrogate the weather data"

		else: # fetch weather data from pickled class files
			if self.options.verbose == True:
				print >> sys.stdout, "fetching weather data from file: ",file_path_current

 			fileinput = open(file_path_current, 'r')
			self.current_conditions = pickle.load(fileinput)
			fileinput.close()

			if self.options.verbose == True:
				print >> sys.stdout, "fetching day forecast data from files: ",file_path_dayforecast, file_path_nightforecast

 			fileinput = open(file_path_dayforecast, 'r')
			self.day_forecast = pickle.load(fileinput)
			fileinput.close()

			if self.options.verbose == True:
				print >> sys.stdout, "fetching day forecast data from files: ",file_path_nightforecast, file_path_nightforecast

 			fileinput = open(file_path_nightforecast, 'r')
			self.night_forecast = pickle.load(fileinput)
			fileinput.close()

	def outputData(self):
		#try:

			if self.options.template != None:

				output = self.getOutputTextFromTemplate(self.options.template)

			else:

				output = self.getOutputText(self.options.datatype,self.options.startday,self.options.endday,self.options.night,self.options.shortweekday,self.options.imperial,self.options.hideunits,self.options.spaces)


			print output.encode("utf-8")

		#except:
			#print "outputData:Unexpected error: ", sys.exc_info()[0]

if __name__ == "__main__":

	parser = CommandLineParser()
	(options, args) = parser.parse_args()

	if options.verbose == True:
		print >> sys.stdout, "location:",options.location
		print >> sys.stdout, "imperial:",options.imperial
		print >> sys.stdout, "datatype:",options.datatype
		print >> sys.stdout, "night:",options.night
		print >> sys.stdout, "start day:",options.startday
		print >> sys.stdout, "end day:",options.endday
		print >> sys.stdout, "spaces:",options.spaces
		print >> sys.stdout, "verbose:",options.verbose
		print >> sys.stdout, "refetch:",options.refetch

	# create new global weather object
	weather = GlobalWeather(options)
	weather.fetchData()
	weather.outputData()

Merci pour le script, j'ai essayé de l'utiliser mais pas moyen....
J'ai testé dans le terminal et voici le résultat :

hamtaro@customtaro:~$ sudo /home/hamtaro/scripts/conkyForecast.py
  File "/home/hamtaro/scripts/conkyForecast.py", line 498
    TEMP_FILEPATH_CURRENT = "/tmp/conkyForecast-c-LOCATION.pkl"
    ^
IndentationError: unexpected indent

Comprends pas vraiment...

De plus, j'ai utilisé le script pour afficher des citations bashfr disponible ici : http://forum.ubuntu-fr.org/viewtopic.php?id=88336

Mais elles sont coupées. Ya un moyen pour autoriser le retour à la ligne ou un truc dans le genre ?

Voici mon conkyrc responsable (copié sur un autre du topic) :

# Position sur l'écran
alignment bottom_left

# Nombre d'échantillons à prendre en compte pour le monitoring du CPU
cpu_avg_samples 5

# Afficher les contours
draw_outline no

# Afficher des bordures autour des graphes
draw_graph_borders no

# Couleur par défaut (texte et bordure)
default_color white
color1 e2ae41

# Écart avec le bord gauche ou droit de l'écran
gap_x 10

# Écart avec le bord haut ou bas de l'écran
gap_y 40

# Soustraire les mémoires tampons de la mémoire utiliser
no_buffer no

# Taille minimale de la fenêtre
minimum_size 300 30
maximum_width 385

# Nombre d'échantillons pour faire la moyenne de l'utilisation réseau
net_avg_samples 5

# utiliser la pseudo-transparence 
own_window_transparent yes

# créer sa propre fenêtre
own_window yes

# Intervalle de rafraîchessement (en seconde)
update_interval 1

# Nombre total de rafraîchissement de Conky avant de quitter. 0 fait tourner Conky tout le temps.
total_run_times 0

# Utiliser Xft (polices lissées etc)
use_xft yes

# Police Xft à utiliser
xftfont Zekton:size=8:bold

# Utiliser l'extension Xdbe 
double_buffer yes

# Bordure en pointillés (en pixel)
stippled_borders 1

# Si own_window est vrai, vous pouvez utiliser les 'conseils' du gestionnaire de fenêtres pour gérer l'affichage de Conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

top_cpu_separate yes

TEXT
Citations bashfr
${stippled_hr }
${execi 180 ~/scripts/bashfr.pl -random2}
${stippled_hr }
${execi 180 ~/scripts/bashfr.pl -random2}
${stippled_hr }

Autre petit souci : ya t il un moyen pour éviter aux nouveaux documents de se glisser sous les "fenêtres" conky sur le bureau ou alors de rendre vraiment le conky implanté dans l'écran...

Si l'un de vous réponds au moins à une de mes questions, je serais vraiment ravi !

TCho, Hamtaro.

Hors ligne

#1464 Le 14/06/2008, à 19:00

toto999

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

TEMP_FILEPATH_CURRENT = "/tmp/conkyForecast-c-LOCATION.pkl"
    TEMP_FILEPATH_DAYFORECAST = "/tmp/conkyForecast-df-LOCATION.pkl"
    TEMP_FILEPATH_NIGHTFORECAST = "/tmp/conkyForecast-nf-LOCATION.pkl"
     EXPIRY_MINUTES = 10
    DEFAULT_SPACING = u" "

il faut que tout soit sur la meme colonne...

donc :

TEMP_FILEPATH_CURRENT = "/tmp/conkyForecast-c-LOCATION.pkl"
TEMP_FILEPATH_DAYFORECAST = "/tmp/conkyForecast-df-LOCATION.pkl"
TEMP_FILEPATH_NIGHTFORECAST = "/tmp/conkyForecast-nf-LOCATION.pkl"
EXPIRY_MINUTES = 10
DEFAULT_SPACING = u" "

#1465 Le 14/06/2008, à 19:11

Hamtaro

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

J'ai corrigé et voici encore ce que j'ai :

hamtaro@customtaro:~$ sudo python /home/hamtaro/scripts/conkyForecast.py
  File "/home/hamtaro/scripts/conkyForecast.py", line 1074
    expiryDate = (datetime.datetime.today() - datetime.timedelta(minutes=self.EXPIRY_MINUTES)).timetuple()
                                                                                                         ^
IndentationError: unindent does not match any outer indentation level

TCho, Hamtaro.

Hors ligne

#1466 Le 14/06/2008, à 19:14

Hamtaro

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

J'ai encore joué sur l'alignement et voici ce que j'obtiens :

IndentationError: unindent does not match any outer indentation level
hamtaro@customtaro:~$ sudo python /home/hamtaro/scripts/conkyForecast.py
  File "/home/hamtaro/scripts/conkyForecast.py", line 1080
    else:
       ^
SyntaxError: invalid syntax

Voir le fichier que j'ai : http://pastebin.com/m3b41e25b

Merci beaucoup pour ton aide

TCho, Hamtaro

Hors ligne

#1467 Le 14/06/2008, à 19:35

Hamtaro

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Bon....

Troisième post, désolé du flood...
J'ai corrigé, je pense, toutes les erreurs d'alignement et une nouvelle erreur fait son entrée :

hamtaro@customtaro:~$ sudo python /home/hamtaro/scripts/conkyForecast.py
Traceback (most recent call last):
  File "/home/hamtaro/scripts/conkyForecast.py", line 1297, in <module>
    weather.fetchData()
  File "/home/hamtaro/scripts/conkyForecast.py", line 1105, in fetchData
    found = xml.find("Invalid location provided")
UnboundLocalError: local variable 'xml' referenced before assignment

Voici le dernier fichier .py en date : http://pastebin.com/m6a2da207

Merci pour la future aide wink

TCho, Hamtaro.

Hors ligne

#1468 Le 14/06/2008, à 19:58

rOm_08

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

@ tof54: J'ai encore oublié un script lol

Voila le calendar.sh :

#! /bin/sh
#str=`echo '\033[01;32m29'`

DATE=`date | awk -F" " '{print $3}'`

case "$1" in
first_part)
cal | grep '[a-zA-Z]';
cal | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=0}
($1 == $0 && i==0) {print $1}
($1 != $0 && i==0){i=i+1;print $1}';
;;
today)
echo $DATE;
;;
second_part)
cal | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=1}
(i==0) {print $0}
($1 != $0 && i==1){i=i-1;print $2}
';
;;
esac

@ Hamtaro : pour les citations enlève le maximum_width mais après sa va déformé ton conky :s faudrait en faire deux.

Pour le conkyForecast.py je te le mets sur megaupload car peut être il c'est déformé dans la balise code.

http://www.megaupload.com/fr/?d=1ZP49S9X


Ubuntu Lucid Lynx 10.4 | Asus P5E Deluxe | Core2Quad Q9550 | ATI HD4870 512Mo | 4Go de RAM | Coolermaster Real Power M620 | Hitachi 1To

Hors ligne

#1469 Le 14/06/2008, à 20:13

tof54

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

merci pour le calendrier mais rOm_08 comment tu fait pour avoir des applications toujours sur AWN ? moi il ne me met que les applications en cours

EDIT : il faut changer les codes UK... dans ton script et le code FR ... dans ton conky c'est tout ?

Dernière modification par tof54 (Le 14/06/2008, à 20:33)

Hors ligne

#1470 Le 14/06/2008, à 20:53

rOm_08

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Pour la météo.

Sinon mon conky est en Anglais car c'est jolie lol

Pour AWN tu clique droit sur le dock, puis préférences, puis onglet Launcher et ajouter.

Tu peux aussi glisser/déposer les icones.

Et voila.


Ubuntu Lucid Lynx 10.4 | Asus P5E Deluxe | Core2Quad Q9550 | ATI HD4870 512Mo | 4Go de RAM | Coolermaster Real Power M620 | Hitachi 1To

Hors ligne

#1471 Le 14/06/2008, à 21:58

tof54

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

nan je voulais dire par rapport aux codes de ville, pour les launcher je test merci

EDIT : heu je doit être un boulet mais pas moyen d'ajouter un icône dans AWN, j'ai fais glisser/déposé de tous les moyens que je connaissait ainsi que par les launcher et rien n'apparait, besoin d'aide là

Dernière modification par tof54 (Le 14/06/2008, à 22:28)

Hors ligne

#1472 Le 14/06/2008, à 23:25

Hamtaro

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

rOm_08 a écrit :

@ tof54: J'ai encore oublié un script lol

Voila le calendar.sh :

#! /bin/sh
#str=`echo '\033[01;32m29'`

DATE=`date | awk -F" " '{print $3}'`

case "$1" in
first_part)
cal | grep '[a-zA-Z]';
cal | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=0}
($1 == $0 && i==0) {print $1}
($1 != $0 && i==0){i=i+1;print $1}';
;;
today)
echo $DATE;
;;
second_part)
cal | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=1}
(i==0) {print $0}
($1 != $0 && i==1){i=i-1;print $2}
';
;;
esac

@ Hamtaro : pour les citations enlève le maximum_width mais après sa va déformé ton conky :s faudrait en faire deux.

Pour le conkyForecast.py je te le mets sur megaupload car peut être il c'est déformé dans la balise code.

http://www.megaupload.com/fr/?d=1ZP49S9X

Merci, la partie météo marche nickel maintenant ! wink

Par contre, pas moyen d'afficher les citations trop longues de bashfr.
J'ai l'impression que le script est limité en nombre de caractères... Non ?

Voici mon screenshot :

c166a80ef64328e644293158b781ctt.jpg

Mon conkyrc responsable de bashfr :

# Position sur l'écran
alignment bottom_left

# Nombre d'échantillons à prendre en compte pour le monitoring du CPU
cpu_avg_samples 5

# Afficher les contours
draw_outline no

# Afficher des bordures autour des graphes
draw_graph_borders no

# Couleur par défaut (texte et bordure)
default_color white
color1 e2ae41

# Écart avec le bord gauche ou droit de l'écran
gap_x 10

# Écart avec le bord haut ou bas de l'écran
gap_y 40

# Soustraire les mémoires tampons de la mémoire utiliser
no_buffer no

# Taille minimale de la fenêtre
minimum_size 300 30
# maximum_width 385

# Nombre d'échantillons pour faire la moyenne de l'utilisation réseau
net_avg_samples 5

# utiliser la pseudo-transparence 
own_window_transparent yes

# créer sa propre fenêtre
own_window yes

# Intervalle de rafraîchessement (en seconde)
update_interval 1

# Nombre total de rafraîchissement de Conky avant de quitter. 0 fait tourner Conky tout le temps.
total_run_times 0

# Utiliser Xft (polices lissées etc)
use_xft yes

# Police Xft à utiliser
xftfont Zekton:size=8:bold

# Utiliser l'extension Xdbe 
double_buffer yes

# Bordure en pointillés (en pixel)
stippled_borders 1

# Si own_window est vrai, vous pouvez utiliser les 'conseils' du gestionnaire de fenêtres pour gérer l'affichage de Conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

top_cpu_separate yes

TEXT
${color1}Citations bashfr${color} $hr

${execi 180 ~/scripts/bashfr.pl -random2}
${stippled_hr }
${execi 180 ~/scripts/bashfr.pl -random2}

${color1}Météo${color} $hr

${execi 600 python /home/hamtaro/scripts/conkyForecast.py --locale=fr --location=FRXX0044 --template=/home/hamtaro/scripts/conkyActual.template}
${font weather:size=48}${execi 600 python /home/hamtaro/scripts/conkyForecast.py --location=FRXX0044 --startday=1 --endday=3 --datatype=WF --spaces=1}$font
${execi 600 python /home/hamtaro/scripts/conkyForecast.py --locale=fr --location=FRXX0044 --template=/home/hamtaro/scripts/conky3Days.template}
$color$hr

Et le script bashfr.pl :

#!/usr/bin/env perl

       #*********************************************#
       #              quote-from-bashfr              #
       #              écrit par tOkeshu              #
       #                02 août. 2006                #
       #                   bashfr.pl                    #
       #                 version 1.1                 #
       #                                             #
       #    Récupère les citations de votre site     #
       #              préféré: bashfr.org            #
       #*********************************************#
       

# ----------------------------------------------------------- #
# Ce script prépare et traite les citations du site Bashfr.org#
# Il accepte 6 arguments possible :                           #
# -latest | -random | -random2 | -top50                                  #
# Ils correspondent ou 4 pages de citation de bashfr :        #
#                                                             #
# http://www.bashfr.org/?sort=latest                          #
# http://www.bashfr.org/?sort=random                          #
# http://www.bashfr.org/?sort=random2                          #
# http://www.bashfr.org/?sort=top50                           #
#                                                             #
# -quote x (avec x>0)                                         #
# Correspond à la page : http://www.bashfr.org/?x             #
#                                                             #
# -n est un argument qui est utilisé avec les 3 premiers:     #
# Il permet de selectionner une quote parmis les 3 différentes#
# pages énoncées. (ex: -latest -n 2 )                         #
#                                                             #
# Le choix par défaut est random.                             #
# ----------------------------------------------------------- #

# Variable qui permet de décompter le nombre de citations parcourues.
$quote_number=1;

$caracterebizarre=0;

# On vérifie les arguments.
# Cas génériques : top50, aléatoire, et dernier ajout.
if ( $ARGV[0] eq "-latest" || $ARGV[0] eq "-random" || $ARGV[0] eq "-top50" || $ARGV[0] eq "-random2" )
{
    $choix=substr ($ARGV[0],1,8);
    $choix="sort="."$choix";
    
# Argument qui permet d'afficher une citation en particulier.
}elsif ( $ARGV[0] eq "-quote" )
{
    $choix="$ARGV[1]";
    
# Argument par défaut.
}else{
    $choix="sort=random2";
    
}

# Argument qui permet de selectionner une citation en particulier avec 
# les arguments précédents. (ex : quote.pl -latest -n 2 )
if ( $ARGV[1] eq "-n" )
{
    $quote_number=$ARGV[2];
}

# Variable d'état (somme-nous dans une citation ? : vrai(>0) ou non(0)).
$in_the_quote=0;

# On récupère directement la page HTML.
use LWP::Simple;
$url="http://www.bashfr.org/?"."$choix";
$source = get($url);
# On récupère chaque ligne dans un tableau.
@tab = split(/\n/,$source);

# On parcours tout le tableau.
# A chaque tour de boucle on ne considère qu'une seule ligne ( $_ ).
 foreach $_ (@tab) {
    # Condition d'arret (somme nous sortis de la citation ?).
    # SI oui alors on arrete la boucle.
    # Si non on continue à parcourir le fichier.
    if ( ("$_" =~ m!div!) && $in_the_quote!=0 )
    {
    last;
    }

    # Somme nous dans la citation ?
    # Si index trouve quote1 ou quote-1 (!=-1) nous venons de trouver une citation.
    $i=index($_,'quote1');
    $j=index($_,'quote-1');
    if ( $i!=-1 || $j!=-1 )
    {
        if ( $quote_number == 1 )
        {
            # Changement d'état (dans la citation).
            $in_the_quote=1;
        }else 
        {
            $quote_number--;
        }
    }

    # Si nous avons changé d'état nous traitons la citation.
    if ( $in_the_quote!=0 )
    {
        # Enlève les balises superflues de début de citation.
        if ( $in_the_quote==1 )
        {
            $_ =~ m/\?([0-9]+)/g;
            # Repère le tout début de la citation dans la ligne (après <br />).
            $pos_debut=index($_,'<br />');
            $pos_debut+=6;
            $pos_fin=length($_);
            # Modifie la ligne actuellement considérée en récupérant
            # uniquement ce qui nous intéresse.
            $_=substr ($_,$pos_debut,$pos_fin);
            # Changement d'état (corps et fin de la citation, rien à enlever).
            $in_the_quote=2;
        }
            # Toute la partie suivante vise à enlever le formatage HTML.
            # ( certaines méthodes existent déjà mais ici rien de compliqué ).
            # Comme substituer une chaine longue à une chaine + courte est 
            # fastidieuse, on remplace l'espace des caractère en trop par un
            # marqueur ( ici % ).
            s/&quot;/%%%%%%\"/g;
            s/&amp;/%%%%%&/g;
            s/&lt;/%%%</g;
            s/&gt;/%%%>/g;
            s/&oelig;/%%%%%%Œ/g;
            s/&nbsp;/%%%%% /g;
            s/&copy;/%%%%%©/g;
            s/&not;/%%%%¬/g;
            s/&ordf;/%%%%%ª/g;
            s/&deg;/%%%%°/g;
            s/&sup2;/%%%%%²/g;
            s/&Agrave;/%%%%%%%%À/g;
            s/&Atilde;/%%%%%%%%à/g;
            s/&Ccedil;/%%%%%%%%Ç/g;
            s/&Egrave;/%%%%%%%%È/g;
            s/&Eacute;/%%%%%%%%É/g;
            s/&Ecirc;/%%%%%%%Ê/g;
            s/&iuml;/%%%%%%ï/g;
            s/&\#039;/%%%%%\'/g;
            s/&eacute;/%%%%%%%é/g;
            s/&agrave;/%%%%%%%à/g;
            s/&acirc;/%%%%%%â/g;
            s/&ccedil;/%%%%%%%ç/g;
            s/&egrave;/%%%%%%%è/g;
            s/&eacute;/%%%%%%%é/g;
            s/&ecirc;/%%%%%%ê/g;
            s/&euml;/%%%%%ë/g;
            s/&icirc;/%%%%%%î/g;
            s/&ocirc;/%%%%%%ô/g;
            s/&ugrave;/%%%%%%%ù/g;
            s/&ucirc;/%%%%%%û/g;    
            s/<br \/>/%%%%%/g;            

        $caracterebizarre+=1;
        if ($caracterebizarre>=1)  {$_=substr ($_,0,-1);}
            # Pour conclure on supprime les marqueurs.
            s/%+//g;
            # On affiche enfin la ligne de citation traitée.
            print "$_ \n";
        
    }
}
print "\n";

Merci pour votre aide wink

TCho, Hamtaro.

Hors ligne

#1473 Le 15/06/2008, à 00:32

trajan

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

Hello,

si tu pouvais mettre tes differents fichiers de conf ce serait super.

@++

Dernière modification par trajan (Le 15/06/2008, à 00:33)

Hors ligne

#1474 Le 15/06/2008, à 07:31

terato

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

@Hamtaro: Sa me rapel la conky de quelqu'un page 50...Meme les couleurs et tout wink


Mon bureau v1//v2//v3//v4

Hors ligne

#1475 Le 15/06/2008, à 09:38

Hamtaro

Re : Conky : Postez vos conkyrc ou certaines parties intéressantes

@ terato : exact, il s'agit du tien. wink
Beau boulot, je suis en train de l'adapter à mes besoins. smile

@ trajan : dès que j'ai un peu de temps, je mets tout ça. Mais en attendant, tu peux regarder page 50, je m'en suis largement inspiré. big_smile

En ce qui concerne les citations bashfr, le script marche nickel dans le terminal, même avec des citations extrêmement longue en caractères...

Serait-ce Conky qui limite l'affichage, est-ce réglable ?
Est-ce la fonction execi qui fait des siennes ?

Bref, plein de pistes mais pas de solutions...

Tcho, Hamtaro.

Dernière modification par Hamtaro (Le 15/06/2008, à 09:40)

Hors ligne