Conky, la mia sistemazione

Fecfactor mi ha chiesto ieri di pubblicare la configurazione del conky che mostro nello screenshot qui sotto

Come puoi vedere, si tratta di circa 3 conkys, che vengono eseguiti tramite uno script, su cui si basa la sua configurazione questo post pubblicato dall'utente Bruce M. nei forum di Ubuntu-Ar con alcune modifiche nella posta conky, che nel mio caso è per Gmail.

Nel post di riferimento è spiegato molto bene da Bruce, ma anche come aiuto per la memoria per me, copierò i passaggi da seguire e il codice dei miei conkys per chi ce l'ha.

Bene, ovviamente dobbiamo avere conky, curl e python installati, quindi digitiamo una console:

sudo apt-get installa conky curl python

La fonte di weather.ttf e arrows.ttf è qui. La fonte di moon.ttf è qui una volta scaricati devi copiarli in / usr / share / fonts

Creiamo ora il nostro script chiamato ~. / Startconky

gksudo gedit ~ / .startconky

all'interno del file vuoto incolliamo quanto segue

#! / Bin / bash
sleep 0 & # 0 buono per Xfce - usa da 20 a 30 per Gnome
conky -c ~ / Conky / conkymain &
#sleep 0 & # 0 buono per Xfce - usa 1 per Gnome
conky -c ~ / Conky / conkyforecast &
#sleep 0 & # 0 buono per Xfce - usa 1 per Gnome
conky -c ~ / Conky / conkymail &

Ora creiamo il file conkymain nella cartella ~ / Conky, se non abbiamo la cartella Conky, dovremo crearla.

gedit ~ / Conky / conkymain

Uso il carattere Calibri, se non ce l'hai, sostituiscilo con quello che vuoi.

Restiamo in ciò che segue

sfondo n
own_window sì
own_window_transparent sì
own_window_hints non decorato, sotto, appiccicoso, skip_taskbar, skip_pager
proprio_colore_finestra nero
double_buffer sì
use_spacer a sinistra
use_xft sì
font calibri: dimensione = 9
xftfont calibri: dimensione = 9
xftalfa 0.5
intervallo_aggiornamento 5.0
maiuscolo no # impostare a sì se si desidera che tutto il testo sia in maiuscolo
stippled_border 3
margine_bordo 9
larghezza_bordo 10
default_color bianco
default_outline_color nero
default_shade_color nero
color0 ciano
color1 azzurro
color2 arancione
color3 giallo
color4 grano
color5 bianco
color6 bianco
color7 bianco
color8 bianco
color9 bianco
allineamento top_right # o top_left, bottom_left, bottom_right
spazio_x 10
gap_y 35
text_buffer_size 128 # usa 1024 per la previsione
no_buffer si # Sottrai i buffer del file system dalla memoria usata?
draw_borders n
draw_outline yes # amplifica il testo se si
draw_shades yes # shadecolor black

TESTO
$ {font calibri: size = 12} $ {alignc} $ {color1} $ sysname $ kernel su $ machine} $ color $ font
$ {font calibri: size = 12} $ {alignc} $ {color2} $ {exec whoami} @ $ nodename $ color $ font
$ {color0} $ {hr 1} $ color
$ {font calibri: size = 20} $ {alignc} $ {time% H:% M} $ font
$ {font calibri: size = 12} $ {color1} $ {alignc} $ {time% A,% d% b. % Y} $ color $ font
$ {color3} UpTime: $ {alignr 2} $ uptime $ color
$ {color0} $ {hr 1} $ color
$ {voffset 5} $ {color2} CPU: $ {alignc} $ color $ running_processes $ {color1} / $ color $ processi $ {alignr 2} $ {color2} $ {cpubar cpu0 14,80} $ color
$ {color1} $ {voffset -16} $ {alignr 5} $ cpu% $ color
$ {voffset 2} $ {color1} Media caricamento ($ {color3} Min $ {color1}): $ {alignr 2} $ {color3} 1: $ color $ {loadavg 1} $ {color3} 5: $ color $ {loadavg 2} $ {color3} 15: $ color $ {loadavg 3}
$ {voffset 5} $ {color2} RAM: $ color $ mem $ {color2} / $ color $ memmax $ {alignr 2} $ {color2} $ {membar 14,80} $ color
$ {color1} $ {voffset -16} $ {alignr 5} $ memperc% $ color
$ {voffset 2} $ {color1} Buffer: $ color $ {buffers} $ {alignr 2} $ {color1} Memorizzato nella cache: $ color $ {cached}
$ {voffset 5} $ {color2} SWAP: $ color $ swap $ {color2} / $ color $ {swapmax} $ {alignr 2} $ {color2} $ {swapbar 14,80} $ color
$ {color1} $ {voffset -16} $ {alignr 5} $ swapperc%
$ {color0} $ {hr 1} $ color
$ {voffset 5} $ {color2} HD Info $ {color1} - $ color Gratis $ {color1} - Usato - $ {color2} Totale
$ {voffset 5} $ {color1} Radice: $ color $ {fs_free_perc /}% $ {alignr 2} $ {fs_free /} $ {color2} / $ {color1} $ {fs_used /} $ color / $ {color2} $ {fs_size /} $ color
$ {color1} Home: $ color $ {fs_free_perc / home / user}% $ {alignr 2} $ {fs_free / home / user} $ {color2} / $ {color1} $ {fs_used / home / user} $ color / $ {color2} $ {fs_size / home / user} $ color
$ {color0} $ {hr 1} $ color
$ {color1} Da: $ color Buenos Aires, Argentina
$ {color1} Lat: $ {color2} 34 ° 35'S $ {color1} Long: $ {color2} 58 ° 21'W $ {color1} Alt: $ {color2} 25 m $ color
$ {voffset 5} $ {color2} $ {font calibri: size = 12} oggi: $ font $ {color3} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = CC} $ color $ {alignr 2} $ {color1} ST: $ {color2} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = LT}
$ {color3} $ {font Weather: size = 50} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = WF} $ font $ color
$ {alignr 50} $ {voffset -55} $ {font calibri: size = 25} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = HT} $ font
$ {alignc 20} $ {voffset -30} $ {font Arrows: size = 20} $ {color4} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = BF} $ color $ font
$ {alignc 10} $ {voffset 5} $ {color4} Wind: $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = WS} $ color
$ {color1} Umidità: $ {color3} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = HM} $ {alignr 2} $ {color1} Precipitazioni: $ {color3} $ { execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = PC} $ color
$ {alignc} $ {color1} Pressione: $ {color3} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = BR} - $ {color3} $ {execi 3600 python ~ / Conky /scripts/conkyForecast.py –location = ARBA0009 –datatype = BD} $ color
$ {color4} $ {hr} $ color
$ {color1} Alba: $ {color3} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = SR} $ {alignr 2} $ {color1} Tramonto: $ {color3} $ { execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = SS} $ color
$ {voffset 15} $ {color1} Moon: $ {color4} $ {alignr 2} $ {color3} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = MP} $ color
$ {voffset -20} $ {offset 80} $ {color4} $ {font fasi lunari: size = 20} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –datatype = MF} $ font $ color
$ {color0} $ {hr} $ color
$ {voffset 5} $ {color2} IP: $ {alignc} $ color $ {addr eth0}
$ {color1} Giù: $ color $ {downspeed eth0} k / s $ {alignr 2} $ {color1} Su: $ color $ {upspeed eth0} k / s
$ {color1} Totale: $ color $ {totaldown eth0} $ {alignr 2} $ {color1} Totale: $ color $ {totalup eth0}
$ {color1} In entrata: $ color $ {tcp_portmon 1 32767 count} $ {color1} In uscita: $ color $ {tcp_portmon 32768 61000 count} $ {alignr 2} $ {color1} Totale: $ color $ {tcp_portmon 1 65535 count}
$ {voffset 5} $ {color2} Connessioni: $ color $ {tcp_portmon 32768 61000 count} $ {alignr 2} $ {color2} Servizio / Porta $ color
$ {voffset 5} $ {tcp_portmon 32768 61000 rhost 0} $ {alignr 2} $ {tcp_portmon 32768 61000 rservice 0}
$ {tcp_portmon 32768 61000 rhost 1} $ {alignr 2} $ {tcp_portmon 32768 61000 rservice 1}
$ {tcp_portmon 32768 61000 rhost 2} $ {alignr 2} $ {tcp_portmon 32768 61000 rservice 2}
$ {tcp_portmon 32768 61000 rhost 3} $ {alignr 2} $ {tcp_portmon 32768 61000 rservice 3}
$ {tcp_portmon 32768 61000 rhost 4} $ {alignr 2} $ {tcp_portmon 32768 61000 rservice 4}
$ {tcp_portmon 32768 61000 rhost 5} $ {alignr 2} $ {tcp_portmon 32768 61000 rservice 5} $ color

creiamo il file ~ / Conky / conkyforecast

gedit ~ / Conky / conkyforecast

e incolliamo quanto segue all'interno

sfondo n
own_window sì
own_window_transparent sì
own_window_hints non decorato, sotto, appiccicoso, skip_taskbar, skip_pager
proprio_colore_finestra nero
double_buffer sì
use_spacer a sinistra
use_xft sì
font calibri: dimensione = 8
xftfont calibri: dimensione = 8
xftalfa 0.5
intervallo_aggiornamento 5.0
maiuscolo no # impostare a sì se si desidera che tutto il testo sia in maiuscolo
stippled_border 3
margine_bordo 9
larghezza_bordo 10
default_color bianco
default_outline_color nero
default_shade_color nero
color0 ciano
color1 azzurro
color2 arancione
color3 giallo
color4 grano
color5 bianco
color6 bianco
color7 bianco
color8 bianco
color9 bianco
allineamento bottom_left # o top_left, bottom_left, bottom_left
spazio_x 10
gap_y 35
text_buffer_size 1024 # usa 1024 per la previsione
no_buffer si # Sottrai i buffer del file system dalla memoria usata?
draw_borders n
draw_outline yes # amplifica il testo se si
draw_shades yes # shadecolor black

TESTO
$ {color4} $ {font calibri: size = 11} Previsione estesa $ font $ color
$ {color0} $ {hr} $ color
$ {color4} $ {font calibri: size = 9} $ {execi 3600 python ~ / Conky / scripts / conkyForecast.py –location = ARBA0009 –template = / home / user / Conky / scripts / myweather.template} $ font $ colore

creiamo il file ~ / Conky / conkymail

gedit ~ / Conky / conkymail

incolliamo quanto segue nel file

sfondo n
own_window sì
own_window_transparent sì
own_window_hints non decorato, sotto, appiccicoso, skip_taskbar, skip_pager
proprio_colore_finestra nero
double_buffer sì
use_spacer a sinistra
use_xft sì
font calibri: dimensione = 8
xftfont calibri: dimensione = 8
xftalfa 0.5
intervallo_aggiornamento 5.0
maiuscolo no # impostare a sì se si desidera che tutto il testo sia in maiuscolo
stippled_border 3
margine_bordo 9
larghezza_bordo 10
default_color bianco
default_outline_color nero
default_shade_color nero
color0 ciano
color1 azzurro
color2 arancione
color3 giallo
color4 grano
color5 bianco
color6 bianco
color7 bianco
color8 bianco
color9 bianco
allineamento bottom_left # o top_left, bottom_left, bottom_left
spazio_x 565
gap_y 35
text_buffer_size 128 # usa 1024 per la previsione
no_buffer si # Sottrai i buffer del file system dalla memoria usata?
draw_borders n
draw_outline yes # amplifica il testo se si
draw_shades yes # shadecolor black

TESTO
$ {font calibri: size = 11} $ {alignc} $ {color4} Gmail
$ {color0} $ {hr} $ color
$ {font calibri: size = 11} $ {color4} Abbiamo $ {color3} $ {execi 300 python ~ / Conky / scripts / mail / conkyEmail.py} $ {color4} email $ font

Creiamo un file in ~ / Conky / scripts / conkyForecast.py (dobbiamo creare la cartella scripts)

gedit ~ / Conky / scripts / conkyForecast.py

#! / usr / bin / python
# - * - codifica: utf-8 - * -
################################################ ##############################
# conkyForecast.py è uno (non così) semplice (più) script Python da raccogliere
# dettagli del tempo corrente da utilizzare in conky.
#
# Autore: Kaivalagi
# Creato: 13/04/2008
# Modifiche:
# 14/04/2008 Consenti intervalli di giorni per i dati di previsione
# 14/04/2008 Verifica la connettività al servizio xoap
# 18/04/2008 Consenti l'impostazione degli spazi per l'uscita con intervallo
# 18/04/2008 Consenti l'output delle previsioni diurne e notturne
# 18/04/2008 Supporto locale per il testo del codice di condizione con l'opzione «CC», in attesa della traduzione in spagnolo
# 18/04/2008 Usa il pickling per i dati di classe piuttosto che aprire xml, questo evita la necessità di interrogare i dati memorizzati nella cache
# 19/04/2008 Aggiunto testo in spagnolo - Grazie Bruce M
# 19/04/2008 Aggiunto controllo non numerico su tutti gli output numerici con suffisso di unità
# 19/04/2008 Denominazione dei file pickle modificata per includere il codice di posizione
# 19/04/2008 Aggiunta la conversione dei giorni feriali in spagnolo tramite locale
# 20/04/2008 Aggiunto un decente parser degli argomenti del comando
# 20/04/2008 Aggiunta l'opzione –shortweekday, se viene fornito il tipo di dati del giorno della settimana ridotto a 3 caratteri
# 21/04/2008 Corrette le opzioni locali per l'output di previsione
# 21/04/2008 Aggiunta l'opzione –template per consentire l'output personalizzato utilizzando una singola chiamata exec 🙂
# 21/04/2008 Aggiunta l'opzione –hideunits per rimuovere, ad esempio, mph e C dall'output
# 23/04/2008 Rimossa l'opzione –imperial dal modello, DEVE essere impostata come opzione standard nella chiamata allo script e non utilizzata nel file del modello.
# 23/04/2008 Aggiunta l'opzione –imperial al modello, che abilita i valori metrici o imperiali per tipo di dati. Nota quando si utilizzano i modelli, l'opzione della riga di comando non funzionerà.
# 23/04/2008 Aggiunto output che notifica all'utente se la posizione fornita è errata
# 24/04/2008 Aggiunta la gestione per nessuna connettività, ora verranno ripristinati i dati memorizzati nella cache (errore se non esiste alcuna cache). Prova cercando di aprire xoap.weather.com
# 24/04/2008 Corretta la conversione da Celsius a Fahrenheit
# 06/05/2008 URL aggiornato utilizzato dopo l'aggiornamento del servizio web
# 09/05/2008 Stato corrente consolidato e dati previsionali recuperati in un'unica chiamata
# 09/05/2008 Aggiunti alba e tramonto ai tipi di dati, questi sono specifici sia per le condizioni attuali che per i dati di previsione
# 09/05/2008 Aggiunte fasi lunari, lettura del barometro e descrizione del barometro ai tipi di dati, questi sono specifici solo per le condizioni attuali e quindi sono N / D nell'output previsto
# 09/05/2008 Aggiunte conversioni di unità per il barometro da mb a pollici (imperiale)
# 09/05/2008 Testo aggiornato delle condizioni in spagnolo - Grazie Bruce M
# 10/05/2008 Aggiunti dati locali francesi - Grazie benpaka
# 12/05/2008 Aggiunto nuovo tipo di dati BF (carattere di rilevamento) per fornire un carattere freccia (da utilizzare con il carattere Arrow.ttf) invece dell'output NSEW da WD (direzione del vento)
# 12/05/2008 L'output di WD aggiornato per essere specifico della locale, attualmente supporta inglese e spagnolo predefiniti - Grazie Bruce M
# 18/05/2008 Aggiunto nuovo tipo di dati MF (carattere luna) per fornire un carattere carattere luna (caratteri non corretti e nessun carattere dedicato ancora).
# 21/05/2008 Per le condizioni attuali l'opzione –datatype = LT ora mostra la temperatura «sembra» invece della temperatura corrente
#
# QUALUNQUE COSA:
# Consolida i file pkl in un file / classe
# Aggiungi un font meteo basato sull'output della fase lunare in base ai dati dell'icona della luna
# ??? Altri requisiti là fuori?

importa sys, os, socket, urllib2, datetime, time
da xml.dom importa minidom
dall'importazione delle statistiche *
da optparse import OptionParser
importazione locale
importa gettext
sottaceto di importazione
dall'importazione matematica *

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

classe CommandLineParser:

parser = Nessuno

def __init __ (self):

self.parser = OptionParser ()
self.parser.add_option («- l», »- location», dest = »location», default = »UKXX0103 ″, type =» string », metavar =» CODE », help = u» codice località per dati meteo [ default:% default], Utilizza il seguente URL per determinare il codice della tua posizione in base al nome della città: 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] Le opzioni del tipo di dati sono: DW (Day Of Week), WF (Weather Font Output), LT (Forecast: Low Temp, Current: Feels Like Temp), HT (Previsione: High Temp, Current: Current Condizioni), CT (testo delle condizioni), PC (probabilità di precipitazioni), HM (umidità), WD (direzione del vento), WS (velocità del vento), WG (raffiche di vento), CN (nome della città), SR (alba), SS (tramonto), MP (fasi lunari), MF (carattere lunare), BR (lettura barometro), BD (descrizione barometro). Non applicabile alla riga di comando quando si utilizzano modelli. »)
self.parser.add_option («- s», »- startday», dest = »startday», type = »int», metavar = »NUMBER», help = u »definisce il numero del giorno di inizio, se vengono emesse le condizioni correnti omesse Non applicabile alla riga di comando quando si utilizzano modelli. »)
self.parser.add_option ("- e", "- endday", dest = "endday", type = "int", metavar = "NUMBER", help = u "definisce il numero del giorno finale, se omesso solo i dati del giorno iniziale viene visualizzato. Non applicabile alla riga di comando quando si utilizzano modelli. »)
self.parser.add_option («- S», »- spaces», dest = »spaces», type = »int», default = 1, metavar = »NUMBER», help = u »[default:% default] Definisce il numero di spazi tra l'output con intervallo. Non applicabile alla riga di comando quando si utilizzano modelli. »)
self.parser.add_option («- t», »- template», dest = »template», type = »string», metavar = »FILE», help = u »definisce un file template per generare output in una chiamata. A l'elemento visualizzabile nel file è nel formato {–datatype = HT –startday = 1}. Le seguenti sono possibili opzioni all'interno di ogni elemento: –datatype, –startday, –endday, –night, –shortweekday, –imperial, –hideunits, –Spazi. Nota che le forme brevi delle opzioni non sono attualmente supportate! Nessuna di queste opzioni è applicabile dalla riga di comando quando si utilizzano i modelli.
self.parser.add_option («- L», »- locale», dest = »locale», type = »string», help = u »sovrascrive le impostazioni internazionali di sistema per l'output della lingua (en = inglese, es = spagnolo, fr = francese, altri in arrivo) »)
self.parser.add_option ("- i", "- imperial", dest = "imperial", default = False, action = "store_true", help = u "richiede unità imperiali, se l'output omesso è in formato metrico. Non applicabile a riga di comando quando si utilizzano modelli. »)
self.parser.add_option («- n», »- night», dest = »night», default = False, action = »store_true», help = u »cambia l'output sui dati notturni, se omesso verrà emesso l'output diurno. Non applicabile alla riga di comando quando si utilizzano modelli. »)
self.parser.add_option («- w», »- shortweekday», dest = »shortweekday», default = False, action = »store_true», help = u »Abbrevia il tipo di dati del giorno della settimana a 3 caratteri. Non applicabile a riga di comando quando si utilizzano modelli. »)
self.parser.add_option («- u», »- hideunits», dest = »hideunits», default = False, action = »store_true», help = u »Nascondi unità come mph o C, i simboli dei gradi (°) sono ancora visualizzato. Non applicabile alla riga di comando quando si utilizzano modelli. »)
self.parser.add_option ("- v", "- verbose", dest = "verbose", default = False, action = "store_true", help = u "richiede un output dettagliato, non è una buona idea quando si esegue conky!" )
self.parser.add_option ("- r", "- refetch", dest = "refetch", default = False, action = "store_true", help = u "recupera i dati indipendentemente dalla scadenza dei dati")

def parse_args (self):
(opzioni, argomenti) = self.parser.parse_args ()
return (opzioni, argomenti)

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

classe WeatherData:
def __init __ (self, day_of_week, low, high, condition_code, condition_text, precip, umidità, 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 »» + umidità
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

classe WeatherText:

condition_text = {
«0»: _ (u »Tornado»),
«1»: _ (u »Tempesta tropicale»),
«2»: _ (u »Hurricane»),
«3»: _ (u »Temporali violenti»),
«4»: _ (u »Temporali»),
«5»: _ (u »Misto di pioggia e neve»),
«6»: _ (u »Pioggia mista e nevischio»),
«7»: _ (u »Precipitazioni miste»),
«8»: _ (u »Pioggia gelata»),
«9»: _ (u »Pioggerella»),
«10»: _ (u »Pioggia gelata»),
«11»: _ (u »Docce»),
«12»: _ (u »Docce»),
«13»: _ (u »Raffiche di neve»),
«14»: _ (u »Rovesci di neve leggera»),
«15»: _ (u »Blowing Snow»),
«16»: _ (u »Neve»),
«17»: _ (u »Salve»),
«18»: _ (u »Nevischio»),
«19»: _ (u »Polvere»),
«20»: _ (u »Nebbia»),
«21»: _ (u »Haze»),
«22»: _ (u »Fumo»),
«23»: _ (u »Blustery»),
«24»: _ (u »Ventoso»),
«25»: _ (u »Freddo»),
«26»: _ (u »Nuvoloso»),
«27»: _ (u »Prevalentemente nuvoloso»),
«28»: _ (u »Prevalentemente nuvoloso»),
«29»: _ (u »Parzialmente nuvoloso»),
«30»: _ (u »Parzialmente nuvoloso»),
«31»: _ (u »Cancella»),
«32»: _ (u »Cancella»),
«33»: _ (u »Discreto»),
«34»: _ (u »Discreto»),
«35»: _ (u »Pioggia mista e grandine»),
«36»: _ (u »Hot»),
«37»: _ (u »Temporali isolati»),
«38»: _ (u »Temporali sparsi»),
«39»: _ (u »Temporali sparsi»),
«40»: _ (u »Docce sparse»),
«41»: _ (u »Neve intensa»),
«42»: _ (u »Rovesci di neve sparsa»),
«43»: _ (u »Neve intensa»),
«44»: _ (u »Parzialmente nuvoloso»),
«45»: _ (u »Rovesci temporaleschi»),
«46»: _ (u »Rovesci di neve»),
«47»: _ (u »Temporali isolati»),
«Na»: _ (u »N / A»),
"-": _ (a ")
}

condition_text_es = {
«0»: _ (u »Tornado»),
«1»: _ (u »Tempesta tropicale»),
«2»: _ (u »Huracá¡n»),
«3»: _ (u »Forti tempeste»),
«4»: _ (u »Tempeste»),
«5»: _ (u »Misto di pioggia e neve»),
«6»: _ (u »Pioggia mista e nevischio»),
«7»: _ (u »Nevischio»),
«8»: _ (u »Pioggia gelata»),
«9»: _ (u »Pioggerella»),
«10»: _ (u »Pioggia gelata»), # o pioggia gelata
«11»: _ (u »Docce»),
«12»: _ (u »Docce»),
«13»: _ (u »Neve leggera»),
«14»: _ (u »Neve leggera»),
«15»: _ (u »Bufera di neve»),
«16»: _ (u »Neve»),
«17»: _ (u »Salve»),
«18»: _ (u »Nevischio»),
«19»: _ (u »Polvere»),
«20»: _ (u »Nebbia»),
«21»: _ (u »Haze»),
«22»: _ (u »Fumo»),
«23»: _ (u »Tempesta»),
«24»: _ (u »Ventoso»),
«25»: _ (u »Fráo»),
«26»: _ (u »Molto nuvoloso»),
«27»: _ (u »Prevalentemente nuvoloso»),
«28»: _ (u »Prevalentemente nuvoloso»),
«29»: _ (u »Parzialmente nuvoloso»),
«30»: _ (u »Parzialmente nuvoloso»),
«31»: _ (u »Cancella»),
«32»: _ (u »Cancella»),
«33»: _ (u »Qualcosa di nuvoloso»),
«34»: _ (u »Qualcosa di nuvoloso»),
«35»: _ (u »Pioggia con grandine»),
«36»: _ (u »Heat»),
«37»: _ (u »Tempeste isolate»),
«38»: _ (u »Tempeste sparse»),
«39»: _ (u »Tempeste sparse»),
«40»: _ (u »Docce sparse»),
«41»: _ (u »Neve intensa»),
«42»: _ (u »Nevicate deboli e sparse»),
«43»: _ (u »Nevada intenso»),
«44»: _ (u »Nubi sparse»),
«45»: _ (u »Tempeste»),
«46»: _ (o »Nevicate sparse»),
«47»: _ (u »Tempeste isolate»),
«Na»: _ (u »N / A»),
"-": _ (a ")
}

condition_text_fr = {
«0»: _ (u »Tornade»),
«1»: _ (u »Tempête Tropicale»),
«2»: _ (o »Ouragan»),
«3»: _ (o »Orages Violents»),
«4»: _ (o »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 »Avversi»),
«12»: _ (u »Avversi»),
«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»: _ (o »Orages Isolés»),
«38»: _ (o »Orages Localisés»),
«39»: _ (o »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»: _ (o »Orages»),
«46»: _ (u »Tempête de Neige»),
«47»: _ (o »Orages Isolés»),
«Na»: _ (u »N / A»),
"-": _ (a ")
}

condition_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 »»),
"-": _(o"")
}

condition_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 »»),
"-": _(o"")
}

giorno_della_settimana = {
"Oggi": _ (o "Oggi"),
«Lunedì»: _ (u »lunedì»),
«Martedì»: _ (u »martedì»),
«Mercoledì»: _ (u »mercoledì»),
«Giovedì»: _ (u »giovedì»),
"Friday": _ (u "Friday"),
"Sabato": _ (u "Sabato"),
"Domenica": _ (u "Domenica")
}

giorno_della_settimana_breve = {
"Oggi": _ (u "Adesso"),
«Lunedì»: _ (u »lunedì»),
«Martedì»: _ (u »Mar»),
«Mercoledì»: _ (u »Mer»),
«Giovedì»: _ (u »gio»),
«Venerdì»: _ (u »ven»),
"Sabato": _ (u "Sab"),
"Domenica": _ (u "Sole")
}

giorno_della_settimana_es = {
"Oggi": _ (u "oggi"),
«Lunedì»: _ (u »lunedì»),
«Martedì»: _ (u »martedì»),
«Mercoledì»: _ (u »mercoledì»),
«Giovedì»: _ (u »giovedì»),
«Venerdì»: _ (u »venerdì»),
"Sabato": _ (u "Sabato"),
"Domenica": _ (u "Domenica")
}

giorno_della_settimana_breve_es = {
"Oggi": _ (u "oggi"),
"Lunedì": _ (u "lun"),
«Martedì»: _ (u »mare»),
«Mercoledì»: _ (u »mer»),
«Giovedì»: _ (u »gio»),
«Venerdì»: _ (u »ven»),
"Sabato": _ (u "sab"),
"Domenica": _ (u "dom")
}

giorno_della_settimana_fr = {
«Oggi»: _ (u »Aujourd'hui»),
«Lunedì»: _ (u »Lundi»),
«Martedì»: _ (u »Mardi»),
«Mercoledì»: _ (u »Mercredi»),
«Giovedì»: _ (u »Jeudi»),
«Venerdì»: _ (u »Vendredi»),
"Sabato": _ (u "Samedi"),
"Domenica": _ (u "Dimanche")
}

giorno_della_settimana_breve_fr = {
«Oggi»: _ (u »Auj»),
"Lunedì": _ (u "Lun"),
«Martedì»: _ (u »Mar»),
"Mercoledì": _ (u "Mer"),
«Giovedì»: _ (u »Jeu»),
«Venerdì»: _ (u »Vieni»),
"Sabato": _ (u "Sam"),
"Domenica": _ (u "Dim")
}

cuscinetto_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 »«)
}

cuscinetto_testo_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"),
"Loro"),
"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»)
}

cuscinetto_testo_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"),
"Loro"),
"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»)
}

classe GlobalWeather:

condizioni_correnti = []
giorno_previsione = []
notte_previsione = []

locale = "in"

opzioni = Nessuno
meteoxmldoc = «»

TEMP_FILEPATH_CURRENT = "/tmp/conkyForecast-c-LOCATION.pkl"
TEMP_FILEPATH_DAYFORECAST = "/tmp/conkyForecast-df-LOCATION.pkl"
TEMP_FILEPATH_NIGHTFORECAST = "/tmp/conkyForecast-nf-LOCATION.pkl"
SCADENZA_MINUTES = 30
DEFAULT_SPACING = u »«

def __init __ (self, opzioni):

self.options = opzioni

se self.options.locale == Nessuno:
provare:
# self.locale = locale.getdefaultlocale () [0] [0: 2]
self.locale = «es» #non commentare questa riga per forzare la localizzazione spagnola
# self.locale = "fr" # non commentare questa riga per forzare la localizzazione francese
ad eccezione di:
print "locale non impostato"
altro:
# self.locale = self.options.locale
self.locale = «es» #non commentare questa riga per forzare la localizzazione spagnola
# self.locale = "fr" # non commentare questa riga per forzare la localizzazione francese

se self.options.verbose == True:
print >> sys.stdout, "locale impostato su", self.locale

def getText (self, nodelist):
rc = ""
per nodo in nodelist:
se node.nodeType == node.TEXT_NODE:
rc = rc + nodo.dati
ritorno rc

def getSpaces (self, spaces):
stringa = u »»
se spazi == Nessuno:
stringa = self.DEFAULT_SPACING
altro:
per i nell'intervallo (0, spazi + 1):
stringa = stringa + u »«
stringa di ritorno

def isNumeric (self, string):
provare:
dummy = float (stringa)
restituire True
ad eccezione di:
ritorno Falso

def isConnectionAvailable (self):
# assicurati di poter accedere al server di weather.com aprendo l'URL
provare:
Usock = urllib2.urlopen ('http://xoap.weather.com')
Usock.close ()
restituire True
ad eccezione di:
ritorno Falso

def getBearingText (self, cuscinetto):
cuscinetto = galleggiante (cuscinetto)
se cuscinetto <11.25:
return u »N»
cuscinetto elif <33.75:
return u »NNE»
cuscinetto elif <56.25:
ritorno u »NE»
cuscinetto elif <78.75:
ritorno »GEN»
cuscinetto elif <101.25:
ritorno u »E»
cuscinetto elif <123.75:
ritorno u »ESE»
cuscinetto elif <146.25:
ritorno u »SE»
cuscinetto elif <168.75:
return u »SSE»
cuscinetto elif <191.25:
ritorno u »S»
cuscinetto elif <213.75:
return u »SSW»
cuscinetto elif <236.25:
ritorno u »SW»
cuscinetto elif <258.75:
return u »WSW»
cuscinetto elif <281.25:
return u »W»
cuscinetto elif <303.75:
return u »WNW»
cuscinetto elif <326.25:
return u »NW»
cuscinetto elif <348.75:
return u »NNW»
altro:
ritorno «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):

listamodelli = []

per template_part in template.split («{«):
if template_part! = «»:
per template_part in template_part.split ("}"):
if template_part! = «»:
templatelist.append (u »» + template_part)

ritorna l'elenco dei modelli

def getOutputText (self, datatype, startday, endday, night, shortweekday, imperial, hideunits, spaces):
#provare:
output = u »»

# definisce le unità correnti per l'output
se hideunits == False:
se imperiale == Falso:
tempunit = u »° C»
speedunit = u »kph»
unità di pressione = u »mb»
altro:
tempunit = u »° F»
speedunit = u »mph»
unità di pressione = u »in»
altro:
tempunit = u »°»
speedunit = u »»
unità di pressione = u »»

if startday == Nessuno: # condizioni attuali

se tipo di dati == "DW":
se self.locale == "è":
if shortweekday == Vero:
output = WeatherText.day_of_week_short_es [self.current_conditions [0] .day_of_week]
altro:
output = WeatherText.day_of_week_es [self.current_conditions [0] .day_of_week]
elif self.locale == "fr":
if shortweekday == Vero:
output = WeatherText.day_of_week_short_fr [self.current_conditions [0] .day_of_week]
altro:
output = WeatherText.day_of_week_fr [self.current_conditions [0] .day_of_week]
altro:
if shortweekday == Vero:
output = WeatherText.day_of_week_short [self.current_conditions [0] .day_of_week]
altro:
output = WeatherText.day_of_week [self.current_conditions [0] .day_of_week]
elif datatype == "WF": # font meteo
output = WeatherText.conditions_weather_font [self.current_conditions [0] .condition_code]
elif datatype == "LT":
stringa = self.current_conditions [0] .low
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertCelsiusToFahrenheit (stringa)
stringa = stringa + tempunit
output = stringa
tipo di dati elif == "HT":
stringa = self.current_conditions [0] .high
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertCelsiusToFahrenheit (stringa)
stringa = stringa + tempunit
output = stringa
tipo di dati elif == "CC":
se self.locale == "è":
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]
altro:
output = WeatherText.conditions_text [self.current_conditions [0] .condition_code]
elif datatype == "CT":
output = self.current_conditions [0] .condition_text
elif datatype == "PC":
stringa = self.current_conditions [0] .precip
se self.isNumeric (stringa) == True:
stringa = stringa + u »%»
output = stringa
tipo di dati elif == "HM":
stringa = self.current_conditions [0] .humidity
se self.isNumeric (stringa) == True:
stringa = stringa + u »%»
output = stringa
tipo di dati elif == "WD":
stringa = self.current_conditions [0] .wind_dir
se self.isNumeric (stringa) == True:
stringa = self.getBearingText (stringa)

se self.locale == "è":
output = WeatherText.bearing_text_es [stringa]
elif self.locale == "fr":
output = WeatherText.bearing_text_fr [stringa]
altro:
output = stringa

tipo di dati elif == "BF":
stringa = self.current_conditions [0] .wind_dir
se self.isNumeric (stringa) == True:
string = WeatherText.bearing_arrow_font [self.getBearingText (string)]
output = stringa
tipo di dati elif == "WS":
stringa = self.current_conditions [0] .wind_speed
se self.isNumeric (stringa) == True:
se imperiale == Vero:
string = self.convertKilometresToMiles (stringa)
stringa = stringa + speedunit
output = stringa
elif datatype == "WG":
stringa = self.current_conditions [0] .wind_gusts
se self.isNumeric (stringa) == True:
se imperiale == Vero:
string = self.convertKilometresToMiles (stringa)
stringa = stringa + speedunit
output = stringa
tipo di dati elif == "CN":
output = self.current_conditions [0] .city
tipo di dati elif == "SR":
output = self.current_conditions [0] .sunrise
tipo di dati elif == "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
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertMillibarsToInches (stringa)
stringa = stringa + unità di pressione
output = stringa
tipo di dati elif == "BD":
output = self.current_conditions [0] .bar_desc
altro:
output = "\ nERRORE: richiesto tipo di dati sconosciuto"

altro: # dati di previsione

if endday == None: # se non è stato impostato alcun endday, utilizzare startday
giorno di fine = giorno di inizio

if night == True: # previsione notturna richiesta

per day_number nell'intervallo (startday, endday + 1):

se tipo di dati == "DW":
se self.locale == "è":
if shortweekday == Vero:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_short_es [self.night_forecast [day_number] .day_of_week]
altro:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_es [self.night_forecast [day_number] .day_of_week]
elif self.locale == "fr":
if shortweekday == Vero:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_short_fr [self.night_forecast [day_number] .day_of_week]
altro:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_fr [self.night_forecast [day_number] .day_of_week]
altro:
if shortweekday == Vero:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_short [self.night_forecast [day_number] .day_of_week]
altro:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week [self.night_forecast [day_number] .day_of_week]
elif datatype == "WF": # font meteo
output = output + self.getSpaces (spazi) + WeatherText.conditions_weather_font [self.night_forecast [day_number] .condition_code]
elif datatype == "LT":
stringa = self.night_forecast [numero_giorno] .low
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertCelsiusToFahrenheit (stringa)
stringa = stringa + tempunit
output = output + self.getSpaces (spazi) + stringa

tipo di dati elif == "HT":
string = self.night_forecast [day_number] .high
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertCelsiusToFahrenheit (stringa)
stringa = stringa + tempunit
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "CC":
se self.locale == "è":
output = output + self.getSpaces (spazi) + WeatherText.conditions_text_es [self.night_forecast [day_number] .condition_code]
elif self.locale == "fr":
output = output + self.getSpaces (spazi) + WeatherText.conditions_text_fr [self.night_forecast [day_number] .condition_code]
altro:
output = output + self.getSpaces (spazi) + WeatherText.conditions_text [self.night_forecast [day_number] .condition_code]
elif datatype == "CT":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .condition_text
elif datatype == "PC":
stringa = self.night_forecast [day_number] .precip
se self.isNumeric (stringa) == True:
stringa = stringa + u »%»
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "HM":
stringa = self.night_forecast [day_number] .humidity
se self.isNumeric (stringa) == True:
stringa = stringa + u »%»
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "WD":
stringa = self.night_forecast [numero_giorno] .wind_dir
se self.locale == "è":
output = output + self.getSpaces (spazi) + WeatherText.bearing_text_es [stringa]
elif self.locale == "fr":
output = output + self.getSpaces (spazi) + WeatherText.bearing_text_fr [stringa]
altro:
output = output + self.getSpaces (spazi) + stringa

tipo di dati elif == "BF":
output = output + self.getSpaces (spazi) + WeatherText.bearing_arrow_font [self.night_forecast [day_number] .wind_dir]
tipo di dati elif == "WS":
stringa = self.night_forecast [numero_giorno] .wind_speed
se self.isNumeric (stringa) == True:
se imperiale == Vero:
string = self.convertKilometresToMiles (stringa)
stringa = stringa + speedunit
output = output + self.getSpaces (spazi) + stringa
elif datatype == "WG":
string = self.night_forecast [day_number] .wind_gusts
se self.isNumeric (stringa) == True:
se imperiale == Vero:
string = self.convertKilometresToMiles (stringa)
stringa = stringa + speedunit
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "CN":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .city
tipo di dati elif == "SR":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .sunrise
tipo di dati elif == "SS":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .sunset
elif datatype == "MP":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .moon_phase
elif datatype == "MF":
output = output + self.getSpaces (spazi) + WeatherText.conditions_moon_font [self.night_forecast [day_number] .moon_icon]
elif datatype == "BR":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .bar_read
tipo di dati elif == "BD":
output = output + self.getSpaces (spazi) + self.night_forecast [day_number] .bar_desc
altro:
output = "\ nERRORE: richiesto tipo di dati sconosciuto"
rompere

altro: # previsione giornaliera desiderata

per day_number nell'intervallo (startday, endday + 1):

se tipo di dati == "DW":
se self.locale == "è":
if shortweekday == Vero:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_short_es [self.day_forecast [day_number] .day_of_week]
altro:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_es [self.day_forecast [day_number] .day_of_week]
elif self.locale == "fr":
if shortweekday == Vero:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_short_fr [self.day_forecast [day_number] .day_of_week]
altro:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_fr [self.day_forecast [day_number] .day_of_week]
altro:
if shortweekday == Vero:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week_short [self.day_forecast [day_number] .day_of_week]
altro:
output = output + self.getSpaces (spazi) + WeatherText.day_of_week [self.day_forecast [day_number] .day_of_week]
elif datatype == "WF": # font meteo
output = output + self.getSpaces (spazi) + WeatherText.conditions_weather_font [self.day_forecast [day_number] .condition_code]
elif datatype == "LT":
stringa = self.day_forecast [day_number] .low
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertCelsiusToFahrenheit (stringa)
stringa = stringa + tempunit
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "HT":
string = self.day_forecast [day_number] .high
se self.isNumeric (stringa) == True:
se imperiale == Vero:
stringa = self.convertCelsiusToFahrenheit (stringa)
stringa = stringa + tempunit
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "CC":
se self.locale == "è":
output = output + self.getSpaces (spazi) + WeatherText.conditions_text_es [self.day_forecast [day_number] .condition_code]
elif self.locale == "fr":
output = output + self.getSpaces (spazi) + WeatherText.conditions_text_fr [self.day_forecast [day_number] .condition_code]
altro:
output = output + self.getSpaces (spazi) + WeatherText.conditions_text [self.day_forecast [day_number] .condition_code]
elif datatype == "CT":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .condition_text
elif datatype == "PC":
stringa = self.day_forecast [day_number] .precip
se self.isNumeric (stringa) == True:
stringa = stringa + u »%»
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "HM":
stringa = self.day_forecast [day_number] .humidity
se self.isNumeric (stringa) == True:
stringa = stringa + u »%»
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "WD":
stringa = self.day_forecast [day_number] .wind_dir

se self.locale == "è":
output = output + self.getSpaces (spazi) + WeatherText.bearing_text_es [stringa]
elif self.locale == "fr":
output = output + self.getSpaces (spazi) + WeatherText.bearing_text_fr [stringa]
altro:
output = output + self.getSpaces (spazi) + stringa

tipo di dati elif == "BF":
output = output + self.getSpaces (spazi) + WeatherText.bearing_arrow_font [self.day_forecast [day_number] .wind_dir]
tipo di dati elif == "WS":
stringa = self.day_forecast [day_number] .wind_speed
se self.isNumeric (stringa) == True:
se imperiale == Vero:
string = self.convertKilometresToMiles (stringa)
stringa = stringa + speedunit
output = output + self.getSpaces (spazi) + stringa
elif datatype == "WG":
string = self.day_forecast [day_number] .wind_gusts
se self.isNumeric (stringa) == True:
se imperiale == Vero:
string = self.convertKilometresToMiles (stringa)
stringa = stringa + speedunit
output = output + self.getSpaces (spazi) + stringa
tipo di dati elif == "CN":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .city
tipo di dati elif == "SR":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .sunrise
tipo di dati elif == "SS":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .sunset
elif datatype == "MP":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .moon_phase
elif datatype == "MF":
output = output + self.getSpaces (spazi) + WeatherText.conditions_moon_font [self.day_forecast [day_number] .moon_icon]
elif datatype == "BR":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .bar_read
tipo di dati elif == "BD":
output = output + self.getSpaces (spazi) + self.day_forecast [day_number] .bar_desc
altro:
output = u »\ nERRORE: richiesto tipo di dati sconosciuto»
rompere

output = u »» + output.strip (u »«) # perde spazi iniziali / finali
restituire l'output

#tranne:
#print "getOutputText: errore imprevisto:", sys.exc_info () [0]

def getOutputTextFromTemplate (self, template):
#provare:

# chiavi per i dati del modello
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 »»

opzionetrovata = Falso

# carica il file
provare:
fileinput = open (self.options.template)
template = fileinput.read ()
fileinput.close ()
ad eccezione di:
output = u »File modello non trovato!»

templatelist = self.getTemplateList (modello)

# Esaminiamo l'elenco dei modelli e determiniamo l'output per ogni elemento trovato
for i in range (0, len (templatelist) -1):

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

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

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

pos = templatelist [i] .find (NIGHT_KEY)
se pos! = -1:
optionfound = True =
notte = vero
altro:
notte = Falso

pos = templatelist [i] .find (SHORTWEEKDAY_KEY)
se pos! = -1:
optionfound = True =
shortweekday = Vero
altro:
shortweekday = Falso

pos = templatelist [i] .find (IMPERIAL_KEY)
se pos! = -1:
optionfound = True =
imperiale = vero
altro:
imperial = Falso

pos = templatelist [i] .find (HIDEUNITS_KEY)
se pos! = -1:
optionfound = True =
unità nascoste = Vero
altro:
hideunits = Falso

pos = templatelist [i] .find (SPACES_KEY)
se pos! = -1:
optionfound = True =
pos = pos + len (SPACES_KEY)
spazi = int (templatelist [i] [pos: pos + 4] .strip («}»). strip («{«). strip («-«). strip (»«))
altro:
spazi = 1

se opzione trovata == Vero:
templatelist [i] = self.getOutputText (datatype, startday, endday, night, shortweekday, imperial, hideunits, spaces)
opzionetrovata = Falso

# passa in rassegna l'elenco concatenando l'output ora che è stato popolato
per l'elemento nell'elenco dei modelli:
output = output + articolo

restituire l'output

#tranne:
#print "getOutputTextFromTemplate: errore imprevisto:", sys.exc_info () [0]

def fetchData (self):

# recupera sempre i dati metrici, usa le funzioni di conversazione su questi dati
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)

se self.isConnectionAvailable () == False:
se os.path.exists (file_path_current):
Recupero dati = falso
altro: # nessuna connessione, nessuna cache, bang!
print "Nessuna connessione Internet disponibile e nessun dato meteo memorizzato nella cache."
elif self.options.refetch == Vero:
Recupero dati = Vero
altro:
# i dati devono essere recuperati di nuovo?
se 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)). timinguple ()

se expiryDate> lastmodDate:
Recupero dati = Vero
altro:
Recupero dati = falso
altro:
Recupero dati = Vero

# recupera i dati sulle condizioni correnti, dal sito Web o "deselezionando"
se RefetchData == True:

# ottenere i dati sulle condizioni attuali dal servizio xoap
provare:

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

url = 'http://xoap.weather.com/weather/local/' + self.options.location + '? cc = * & dayf = 8 & link = xoap∏ = xoap & par = 1061785028 & key = e374effbfd74930b & unità = m '
se self.options.verbose == True:
print >> sys.stdout, «recupero dati meteo da«, url

Usock = urllib2.urlopen (url)
xml = usock.read ()
Usock.close ()
self.weatherxmldoc = minidom.parseString (xml)
ad eccezione di:
print "fetchData: errore imprevisto:", sys.exc_info () [0]
print "Impossibile contattare la fonte meteo per le condizioni attuali"

# dì all'utente se la posizione è cattiva ...
trovato = xml.find ("Posizione fornita non valida")
se trovato! = -1:
print "Posizione fornita non valida"

# interrogare i dati meteorologici, caricarli nella struttura della classe e metterli in risalto
provare:

# preparare elenchi di dati meteorologici
self.condizioni_correnti = []
self.previsione_giorno = []
self.previsione_notte = []

# raccogliere dati generali
meteo_n = self.weatherxmldoc.documentElement
location_n = weather_n.getElementsByTagName ('loc') [0]
city_n = location_n.getElementsByTagName ('dnam') [0]
city ​​= self.getText (city_n.childNodes)

# raccoglie i dati sulle condizioni attuali
day_of_week = u »Oggi»
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)
umidità_n = current_condition_n.getElementsByTagName ('hmid') [0]
umidità = self.getText (umidità_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, umidità, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
self.current_conditions.append (current_conditions_data)

# raccogli dati di previsione
bar_read = u »N / A»
bar_desc = u »N / A»
moon_phase = u »N / D»
moon_icon = u »na»
forecast_n = weather_n.getElementsByTagName ('dayf') [0]
day_nodes = forecast_n.getElementsByTagName ('giorno')

per 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)

# dati specifici delle previsioni giornaliere
daytime_n = day.getElementsByTagName ('part') [0] # giorno
condition_code_n = daytime_n.getElementsByTagName ('icon') [0]
condition_code = self.getText (condition_code_n.childNodes)
condition_n = daytime_n.getElementsByTagName ('t') [0]
condizione = self.getText (condition_n.childNodes)
precip_n = daytime_n.getElementsByTagName ('ppcp') [0]
precip = self.getText (precip_n.childNodes)
umidità_n = daytime_n.getElementsByTagName ('hmid') [0]
umidità = self.getText (umidità_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, umidità, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
self.day_forecast.append (day_forecast_data)

# dati specifici sulle previsioni notturne
daytime_n = day.getElementsByTagName ('part') [1] # notte
condition_code_n = daytime_n.getElementsByTagName ('icon') [0]
condition_code = self.getText (condition_code_n.childNodes)
condition_n = daytime_n.getElementsByTagName ('t') [0]
condizione = self.getText (condition_n.childNodes)
precip_n = daytime_n.getElementsByTagName ('ppcp') [0]
precip = self.getText (precip_n.childNodes)
umidità_n = daytime_n.getElementsByTagName ('hmid') [0]
umidità = self.getText (umidità_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, umidità, wind_direction, wind_speed, wind_gusts, city, sunrise, sunset, moon_phase, moon_icon, bar_read, bar_desc)
self.night_forecast.append (night_forecast_data)

# raccogli i dati per la prossima volta!
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 ()

ad eccezione di:
print "fetchData: errore imprevisto:", sys.exc_info () [0]
print "Impossibile interrogare i dati meteo"

else: # recupera i dati meteorologici dai file di classe pickled
se self.options.verbose == True:
print >> sys.stdout, «recupero dei dati meteo dal file:«, file_path_current

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

se self.options.verbose == True:
print >> sys.stdout, "recupero dei dati di previsione del giorno dai file:", file_path_dayforecast, file_path_nightforecast

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

se self.options.verbose == True:
print >> sys.stdout, «recupero dei dati sulle previsioni del giorno dai file:«, file_path_nightforecast, file_path_nightforecast

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

def outputData (self):
#provare:

if self.options.template! = Nessuno:

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

altro:

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")

#tranne:
#print «outputData: errore imprevisto:«, sys.exc_info () [0]

se __name__ == "__main__":

parser = CommandLineParser ()
(opzioni, argomenti) = parser.parse_args ()

se 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

# crea un nuovo oggetto meteo globale
weather = GlobalWeather (opzioni)
weather.fetchData ()
weather.outputData ()

Creiamo il file ~ / Conky / scripts / myweather.template

gedit ~ / Conky / scripts / myweather.template

incolliamo quanto segue all'interno:

{–Datatype = DW –startday = 1}: {–datatype = CC –startday = 1}
{–Datatype = HT –startday = 1} / {–datatype = LT –startday = 1} Vento da {–datatype = WD –startday = 1} a {–datatype = WS –startday = 1}
Umidità: {–datatype = HM –startday = 1} Precipitazioni: {–datatype = PC –startday = 1}
Alba: {–datatype = SR –startday = 1} Tramonto: {–datatype = SS –startday = 1}
----------------
{–Datatype = DW –startday = 2}: {–datatype = CC –startday = 2}
{–Datatype = HT –startday = 2} / {–datatype = LT –startday = 2} Vento da {–datatype = WD –startday = 2} a {–datatype = WS –startday = 2}
Umidità: {–datatype = HM –startday = 2} Precipitazioni: {–datatype = PC –startday = 2}
Alba: {–datatype = SR –startday = 2} Tramonto: {–datatype = SS –startday = 2}
----------------
{–Datatype = DW –startday = 3}: {–datatype = CC –startday = 3}
{–Datatype = HT –startday = 3} / {–datatype = LT –startday = 3} Vento da {–datatype = WD –startday = 3} a {–datatype = WS –startday = 3}
Umidità: {–datatype = HM –startday = 3} Precipitazioni: {–datatype = PC –startday = 3}
Alba: {–datatype = SR –startday = 3} Tramonto: {–datatype = SS –startday = 3}
----------------
{–Datatype = DW –startday = 4}: {–datatype = CC –startday = 4}
{–Datatype = HT –startday = 4} / {–datatype = LT –startday = 4} Vento da {–datatype = WD –startday = 4} a {–datatype = WS –startday = 4}
Umidità: {–datatype = HM –startday = 4} Precipitazioni: {–datatype = PC –startday = 4}
Alba: {–datatype = SR –startday = 4} Tramonto: {–datatype = SS –startday = 4}

Creiamo il file ~ / Conky / scripts / mail / conkyEmail.py (dobbiamo creare la cartella di posta)

gedit ~ / Conky / scripts / mail / conkyEmail.py

e incolla quanto segue all'interno:

import os
stringa di importazione

#Inserisci il tuo nome utente e la password sotto tra virgolette
# per esempio. nome utente = »nome utente» e password = »password»
nomeutente = »YOUR_USUARIO_SINARROBA«
password = »LA TUA CHIAVE«

com = »wget -O - https: //» + nome utente + »:» + password + »@ mail.google.com / mail / feed / atom –no-check-certificate»

temp = os.popen (com)
msg = temp.read ()
index = string.find (msg, » »)
index2 = string.find (msg, » »)
fc = int (msg [index + 11: index2])

se fc == 0:
stampa "0 nuovi"
altro:
print str (fc) + »nuovo»

Quindi ora hai 7 file:

Nella cartella: ~
-> .startconky << - rende eseguibile

Nella cartella: ~ / Conky
-> conkymain
-> conkyforecast
-> conkymail

e nella cartella: ~ / Conky / scripts
-> conkyForecast.py << - rende eseguibile
-> myweather.template

e nella cartella: ~ / Conky / scripts / mail
conkyEmail.py << - rende eseguibile

Ed è tutto, precisazioni, dove c'è scritto / home / utente / ... va il tuo nome utente e nella parte dove vanno i dati di Gmail, ho evidenziato a colori dove devi mettere i tuoi dati.

per terminare il processo conky scrivi su una console

ammazza tutto conky

per eseguire conky write su una console

./.startconky

una volta che hai sistemato tutto, se vuoi che conky inizi ogni sessione

Sistema—> Preferenze—> Sessioni e nei programmi di avvio lo aggiungiamo

In Name possiamo scrivere Conky, in Order ./.startconky con che partirà ogni volta che accendi il pc.

Questo è tutto, spero che ti aiuti.


Puoi essere il primo a lasciare un commento

Lascia un tuo commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati con *

*

*

  1. Responsabile dei dati: Miguel Ángel Gatón
  2. Scopo dei dati: controllo SPAM, gestione commenti.
  3. Legittimazione: il tuo consenso
  4. Comunicazione dei dati: I dati non saranno oggetto di comunicazione a terzi se non per obbligo di legge.
  5. Archiviazione dati: database ospitato da Occentus Networks (UE)
  6. Diritti: in qualsiasi momento puoi limitare, recuperare ed eliminare le tue informazioni.