Posta il tuo .conkyrc & png ""Leggete in 1°Pagina conkyForecast""

Il ritrovo della comunità dove confrontarsi e discutere sulle notizie dal mondo dell'informatica, di Ubuntu e di tutto quello che la riguarda, novità, pettegolezzi e quant'altro.
Nickname.
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 611
Iscrizione: sabato 4 luglio 2009, 18:34

Re: Posta il tuo .conkyrc & png

Messaggio da Nickname. » sabato 24 aprile 2010, 18:28

Come si rende più veloce lo scroll?

Ho provato con step ma non funziona, perchè lo stampa nel conky. .  .

Avatar utente
alecive
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1886
Iscrizione: venerdì 12 dicembre 2008, 14:09
Desktop: gnome-shell o unity
Distribuzione: Ubuntu 12.04
Località: Sestri Levante
Contatti:

Re: Posta il tuo .conkyrc & png

Messaggio da alecive » sabato 24 aprile 2010, 19:06

credo che l'unica possibilità sia diminuire l'update_interval (settandolo per esempio a 0.5).. perchè lo scroll sposta il testo di una lettera ad ogni refresh di conky mi pare.. quindi se aumenti la frequenza di refresh, si velocizza!
Però consuma di più.. :(
La follia è come la gravità. Basta una piccola spinta.                              AwOken Iconset - Rilasciata la  2.4!! (c'è anche il ppa [lucid-maverick-natty-oneiric-precise]!)

Nickname.
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 611
Iscrizione: sabato 4 luglio 2009, 18:34

Re: Posta il tuo .conkyrc & png

Messaggio da Nickname. » sabato 24 aprile 2010, 19:20

Mmh . .
Scroll 'text' by 'step' characters showing 'length' number of characters at the same time. The text may also contain variables. 'step' is optional and defaults to 1 if not set. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. If you change the textcolor inside $scroll it will automatically have it's old value back at the end of $scroll. The end and the start of text will be separated by 'length' number of spaces. 
Come dici tu in effetti funziona, non ci avevo pensato..

Avatar utente
alecive
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1886
Iscrizione: venerdì 12 dicembre 2008, 14:09
Desktop: gnome-shell o unity
Distribuzione: Ubuntu 12.04
Località: Sestri Levante
Contatti:

Re: Posta il tuo .conkyrc & png

Messaggio da alecive » sabato 24 aprile 2010, 19:34

Ma se c'è l'opzione step vuol dire che avrai fatto male a metterla.. come l'hai scritta tu?
La follia è come la gravità. Basta una piccola spinta.                              AwOken Iconset - Rilasciata la  2.4!! (c'è anche il ppa [lucid-maverick-natty-oneiric-precise]!)

Nickname.
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 611
Iscrizione: sabato 4 luglio 2009, 18:34

Re: Posta il tuo .conkyrc & png

Messaggio da Nickname. » sabato 24 aprile 2010, 19:47

allora, questa è la riga di partenza,
${scroll 100 ${rss  http://rss.feedsportal.com/c/32604/f/493129/index.rss 1 item_titles 1}}

ho provato:
${scroll 100 ${step 123 ${rss  http://rss.feedsportal.com/c/32604/f/493129/index.rss 1 item_titles 1}}}
${scroll 100 step 123 ${rss  http://rss.feedsportal.com/c/32604/f/493129/index.rss 1 item_titles 1}}
${scroll 100 ${rss  http://rss.feedsportal.com/c/32604/f/493129/index.rss 1 item_titles 1 step 123}}

Avatar utente
Artaserse
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 872
Iscrizione: giovedì 29 novembre 2007, 14:57
Desktop: Compiz Standalone
Distribuzione: ArchLinux x86_64

Re: Posta il tuo .conkyrc & png

Messaggio da Artaserse » domenica 25 aprile 2010, 20:20

Immagine

Codice: Seleziona tutto

# — Conky settings — #
background no
update_interval 1

cpu_avg_samples 2
net_avg_samples 2

override_utf8_locale yes

double_buffer yes
no_buffers yes

text_buffer_size 2048
imlib_cache_size 0

# — Window specifications — #

own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below

border_inner_margin 0
border_outer_margin 0

minimum_size 600 400
maximum_width 600

alignment tl
gap_x 5
gap_y 25

# — Graphics settings — #
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders no

# — Text settings — #
use_xft yes
xftfont mintsmild:size=8
xftalpha 0.8

uppercase no

default_color 555
default_shade_color bbbbbb

# — Artaserse's Settings — #

# — Lua Load — #
lua_load /home/artaserse/Conky/new_rings/arp-rings.lua
lua_draw_hook_pre ring_stats

TEXT
${goto 19}${voffset 25}CPU
${goto 19}${voffset 50}RAM
${goto 18}${voffset 108}dati
${goto 16}${voffset 52}root
${goto 16}${voffset 48}home

Codice: Seleziona tutto

--[[
Ring Meters by londonali1010 (2009) mod by arpinux

This script draws percentage meters as rings. It is fully customisable; all options are described in the script.

IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 129 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num>5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num>3; conversely if you update Conky every 0.5s, you should use update_num>10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.

To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
	lua_load ~/scripts/rings.lua
	lua_draw_hook_pre ring_stats
]]

settings_table = {
	{
		-- Edit this table to customise your rings.
		-- You can create more rings simply by adding more elements to settings_table.
		-- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
		name='cpu',
		-- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
		arg='cpu0',
		-- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
		max=100,
		-- "bg_colour" is the colour of the base ring.
		bg_colour=0xffffff,
		-- "bg_alpha" is the alpha value of the base ring.
		bg_alpha=0.2,
		-- "fg_colour" is the colour of the indicator part of the ring.
		fg_colour=0x555555,
		-- "fg_alpha" is the alpha value of the indicator part of the ring.
		fg_alpha=0.9,
		-- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
		x=30, y=30,
		-- "radius" is the radius of the ring.
		radius=20,
		-- "thickness" is the thickness of the ring, centred around the radius.
		thickness=10,
		-- "angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
		angle=-90
	},
	{
		name='memperc',
		arg='',
		max=100,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=90,
		radius=20,
		thickness=10,
		angle=-90
	},
	{
		name='time %I',
		arg='',
		max=12,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=150,
		radius=19,
		thickness=7,
		angle=0
	},
	{
		name='time %M',
		arg='',
		max=60,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=150,
		radius=12,
		thickness=4,
		angle=0
	},
	{
		name='time %S',
		arg='',
		max=60,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=150,
		radius=7,
		thickness=2,
		angle=0
	},
	{
		name='fs_used_perc',
		arg='/media/dati',
		max=100,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=210,
		radius=20,
		thickness=10,
		angle=-90
	},
	{
		name='fs_used_perc',
		arg='/',
		max=100,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=270,
		radius=20,
		thickness=10,
		angle=-90
	},
	{
		name='fs_used_perc',
		arg='/home',
		max=100,
		bg_colour=0xffffff,
		bg_alpha=0.2,
		fg_colour=0x555555,
		fg_alpha=0.9,
		x=30, y=330,
		radius=20,
		thickness=10,
		angle=-90
	}
	
	
}

require 'cairo'

function rgb_to_r_g_b(colour,alpha)
	return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function draw_ring(t, pt)
	if conky_window==nil then return end
	local w,h=conky_window.width,conky_window.height
	local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual,w,h)
	
	cr=cairo_create(cs)
	
	local xc,yc,ring_r,ring_w,angle=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['angle']
	local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']

	local angle_0=angle*(2*math.pi/360)-math.pi/2
	local t_arc=t*2*math.pi

	-- Draw background ring

	cairo_arc(cr,xc,yc,ring_r,0,2*math.pi)
	cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
	cairo_set_line_width(cr,ring_w)
	cairo_stroke(cr)
	
	-- Draw indicator ring

	cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
	cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
	cairo_stroke(cr)		
	
	cairo_destroy(cr)
	cr = nil
end

function conky_cairo_cleanup()
	cairo_surface_destroy(cs)
	cs = nil
end

function conky_ring_stats()
	local function setup_rings(pt)
		local str=''
		local value=0
		
		str=string.format('${%s %s}',pt['name'],pt['arg'])
		str=conky_parse(str)
		
		value=tonumber(str)
		pct=value/pt['max']
		
		draw_ring(pct,pt)
	end
	
	-- Check that Conky has been running for at least 5s
	
	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)
	
	if update_num>5 then
		for i in pairs(settings_table) do
			setup_rings(settings_table[i])
		end
	end
end
Jabber: artaserse@jabber.org | Cosa Ascolto | dotfiles | Felicemente passato ad Archlinux!
artaserse@deviantart

Avatar utente
Bigre
Prode Principiante
Messaggi: 175
Iscrizione: giovedì 10 settembre 2009, 22:03

Re: Posta il tuo .conkyrc & png

Messaggio da Bigre » domenica 25 aprile 2010, 21:47

ciao a tutti.. scusate se vi chiederò delle cose a cui probabilmente avete già risposto.. ma le pagine sono tante.. e alcune cose non le ho trovate.. magari anche solo per una svista :D

ho installato conky.. dando il comando da terminale mi esce questo:

Codice: Seleziona tutto

root@marco:~# conky
Conky: /home/marco/.conkyrc: 40: no such configuration: 'border_margin'
Conky: one or more $endif's are missing
Conky: desktop window (140009c) is subwindow of root window (110)
Conky: window type - override
Conky: drawing to created window (0x3400001)
Conky: drawing to double buffer
Conky: can't open /sys/class/power_supply/8,60/uevent: No such file or directory
Conky: can't open /proc/acpi/battery/8,60/state: No such file or directory
sh: nmap: not found
sh: /home/marco/Conky/scripts/ip.sh: not found
Conky: received SIGINT or SIGTERM to terminate. bye!
funzionare funziona, e a me piace!.. ma non penso sia normale..
in più, c'è una cosa che non mi piace.. le lettere al posto dei disegni.. sulle vostre immagini vedo dei disegnini per il monitor per la ram.. ecc.. io invece avevo solo delle lettere (che ho tolto) e non capisco perchè..
nella mia immagine si vedono quelle del meteo, al posto dei disegni :(

mi sapreste dire cosa dovrei fare per sistemare il tutto?

Grazie

http://yfrog.com/e8conkyp

deegan
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 2636
Iscrizione: lunedì 28 aprile 2008, 12:42
Desktop: gnome-session-fallback
Distribuzione: Trusty Tahr 14.04/Manjaro
Località: Oulu

Re: Posta il tuo .conkyrc & png

Messaggio da deegan » martedì 27 aprile 2010, 23:17

Chi mi aiuta con questo errore?  ;D

Codice: Seleziona tutto

deegan@lucid-lynx:~$ conky
Conky: desktop window (18000b8) is subwindow of root window (a5)
Conky: window type - override
Conky: drawing to created window (0x3800001)
Conky: drawing to double buffer
^CConky: received SIGINT or SIGTERM to terminate. bye!
Traceback (most recent call last):
  File "/home/deegan/impulse.py", line 14, in <module>
    print impulse.getSnapshot( fft )
KeyboardInterrupt
deegan@lucid-lynx:~$ 

impulse.py

Codice: Seleziona tutto

#!/usr/bin/env python

import sys,os

if __name__ == "__main__":

	if len(sys.argv)!=3:
		print -1
	else:
		os.chdir(sys.argv[2])
		import  impulse
		fft=(sys.argv[1]=="1")
		while True:
			print impulse.getSnapshot( fft )
-MB* AsRock Z77 Extreme4-M Soket 1155 DDR3 - SV* Asus Strix - GeForce GTX 970, OC, 4 GB- CPU* Intel i5-3570k 3,4GHz - RAM* Corsair Dominator Platinum C9 1600MHz DRAM DDR3 (8x4GB) - SSD* Corsair Force LX 512GB -

Avatar utente
MrMars
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1860
Iscrizione: giovedì 29 ottobre 2009, 14:15
Contatti:

Re: Posta il tuo .conkyrc & png

Messaggio da MrMars » martedì 27 aprile 2010, 23:19

deegan ha scritto: Chi mi aiuta con questo errore?  ;D
Che dovrebbe fare?

deegan
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 2636
Iscrizione: lunedì 28 aprile 2008, 12:42
Desktop: gnome-session-fallback
Distribuzione: Trusty Tahr 14.04/Manjaro
Località: Oulu

Re: Posta il tuo .conkyrc & png

Messaggio da deegan » martedì 27 aprile 2010, 23:21

MrMars ha scritto:
deegan ha scritto: Chi mi aiuta con questo errore?  ;D
Che dovrebbe fare?
......... ;D

http://ubuntuforums.org/attachment.php? ... 1268255688
-MB* AsRock Z77 Extreme4-M Soket 1155 DDR3 - SV* Asus Strix - GeForce GTX 970, OC, 4 GB- CPU* Intel i5-3570k 3,4GHz - RAM* Corsair Dominator Platinum C9 1600MHz DRAM DDR3 (8x4GB) - SSD* Corsair Force LX 512GB -

Avatar utente
Diabolik62
Tenace Tecnocrate
Tenace Tecnocrate
Messaggi: 16046
Iscrizione: domenica 20 dicembre 2009, 16:29
Distribuzione: wind 10049 archfce4.12

Re: Posta il tuo .conkyrc & png

Messaggio da Diabolik62 » mercoledì 28 aprile 2010, 11:18

Codice: Seleziona tutto

sh: nmap: not found
sh: /home/marco/Conky/scripts/ip.sh: not found
mancano questi scripts
e conkyForecast e alcuni font
@ deegan  ma ti funziona il test
io l'ho provato di fretta ieri
ma non mi vai nemmeno quello mi da errore il lua
a 468-478 non ricordo di preciso
Ultima modifica di Anonymous il giovedì 29 aprile 2010, 14:49, modificato 1 volta in totale.

Avatar utente
Diabolik62
Tenace Tecnocrate
Tenace Tecnocrate
Messaggi: 16046
Iscrizione: domenica 20 dicembre 2009, 16:29
Distribuzione: wind 10049 archfce4.12

Re: Posta il tuo .conkyrc & png

Messaggio da Diabolik62 » mercoledì 28 aprile 2010, 11:39

deegan
dove trovo questo

capture.png 

deegan
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 2636
Iscrizione: lunedì 28 aprile 2008, 12:42
Desktop: gnome-session-fallback
Distribuzione: Trusty Tahr 14.04/Manjaro
Località: Oulu

Re: Posta il tuo .conkyrc & png

Messaggio da deegan » mercoledì 28 aprile 2010, 14:07

Diabolik62 ha scritto: deegan
dove trovo questo

capture.png   
Non lo sò nemmeno io..... :-\
-MB* AsRock Z77 Extreme4-M Soket 1155 DDR3 - SV* Asus Strix - GeForce GTX 970, OC, 4 GB- CPU* Intel i5-3570k 3,4GHz - RAM* Corsair Dominator Platinum C9 1600MHz DRAM DDR3 (8x4GB) - SSD* Corsair Force LX 512GB -

Avatar utente
Jaguaro
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 299
Iscrizione: martedì 9 febbraio 2010, 10:25
Località: Prealpi
Contatti:

Re: Posta il tuo .conkyrc & png

Messaggio da Jaguaro » giovedì 29 aprile 2010, 10:56

ciao,

mi date qualche instradamento "infarinatura" per LUA


sono in alto mare

dove scarico
cosa devo installare
che file modificare o smanettare


grazie

ciao

J.
http://mountaincafe.altervista.org/ ---- www.verticalmente.net

Fin al quaranta de masc bisogna minga mùla i strasc...:-D

Avatar utente
Bigre
Prode Principiante
Messaggi: 175
Iscrizione: giovedì 10 settembre 2009, 22:03

Re: Posta il tuo .conkyrc & png

Messaggio da Bigre » giovedì 29 aprile 2010, 14:36

dando il comando: conky
da terminale ecco cosa mi esce:

Codice: Seleziona tutto

marco@marco:~$ conky
Conky: /home/marco/.conkyrc: 40: no such configuration: 'border_margin'
Conky: one or more $endif's are missing
Conky: desktop window (16000a2) is subwindow of root window (110)
Conky: window type - override
Conky: drawing to created window (0x4a00001)
Conky: drawing to double buffer
Conky: can't open /sys/class/power_supply/8,60/uevent: No such file or directory
Conky: can't open /proc/acpi/battery/8,60/state: No such file or directory
sh: sensors: not found
sh: nmap: not found
sh: /home/marco/Conky/scripts/ip.sh: not found
vi incollo qua il mio conkyrc:

Codice: Seleziona tutto

# Use Xft?
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_transparent yes
own_window_type override
#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 180 0
#maximum_width 200

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 1

# border margins
border_margin 0

# border width
border_width 2

# graph_border
draw_graph_borders no

# Default colors and also border colors
default_color white
#default_shade_color black
#default_outline_color white
own_window_colour white

# Text alignment, other possible values are commented
alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 20
gap_y 27

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer none

TEXT

${font Webdings:size=16}~${font}  Battery: ${battery_percent BAT0}% ${alignr}${battery_bar 8,60}
${if_running rhythmbox}
${font j.d.:size=8}${color3}${execi 5 lyricsdownloader -t 35 | fold -sw25}
${else}
${font DejaVu Sans:size=8:bold}System${font} ${hr 2}
#${font Webdings:size=15}i${font}   ${exec whoami}@$nodename ${alignr}Ubuntu Jaunty
 ${font StyleBats:size=16}${font}   Frequency (in MHz)${alignr} $freq
#${font StyleBats:size=16}${font}   Users:${alignr} ${user_number}
 ${font StyleBats:size=16}${font}   System Updates:${alignr} ${execi 3600 aptitude search "~U" | wc -l | tail}
#${font Webdings:size=14}Ã${font}   File System Type $alignr${fs_type}
 ${voffset 1}${font OpenLogos:size=16}${font}  ${voffset -4} Kernel:  ${alignr}${kernel}
 ${font StyleBats:size=16}${font}   CPU1: ${cpu cpu1}% ${alignr}${cpugraph cpu1 8,60}
 ${font StyleBats:size=16}${font}   CPU2: ${cpu cpu2}% ${alignr}${cpugraph cpu2 8,60}
 ${font StyleBats:size=16}${font}   RAM: $memperc% ${alignr}${memgraph 8,60}
# ${font StyleBats:size=16}j${font}   SWAP: $swapperc% ${alignr}${swapbar 8,60}
 ${font StyleBats:size=16}${font}   Uptime: ${alignr}${uptime}
# ${font StyleBats:size=16}k${font}   Processes: ${alignr}$processes ($running_processes running)
#1. ${top_mem name 1} ${alignr}${top_mem mem 1} ${top_mem cpu 1}
#2. ${top_mem name 2} ${alignr}${top_mem mem 2} ${top_mem cpu 2}
#3. ${top_mem name 3} ${alignr}${top_mem mem 3} ${top_mem cpu 3}

${font DejaVu Sans:size=8:bold}Hardisk${font} ${hr 2}
${font Pie charts for maps:size=14}${font}   ${voffset -5}Home:
${voffset 4}${fs_free /home}/${fs_size /home} ${alignr}${fs_bar 8,60 /home}
#${font DejaVu Sans:size=8:bold}Graphics${font} ${hr 2}

#Model ${alignr}Intel GMA X3100
#RAM ${alignr}358 MB
#Intel Driver Version:$alignr ${exec intel-settings -q intelDriverVersion | grep Attribute | cut -d ' ' -f 6}
${font DejaVu Sans:size=8:bold}Temp${font} ${hr 2}
${font StyleBats:size=13}${font}   MB ${alignr}${execi 300 sensors | grep temp1 | cut -c15-16 ;}°C
 #${font Pie charts for maps:size=14}7${font}   HD ${alignr}${execi 1 ~/Conky/scripts/hddmonit.sh}°C
#${font StyleBats:size=13}  ${font}   CASE:  ${alignr}${execi 5 sensors | grep temp1 | cut -c15-16 ;}°C
# ${font StyleBats:size=16}A${font}   CPU1 ${alignr}${execi 300 sensors | grep Core\ 0 | cut -c15-16 ;}°C
# ${font StyleBats:size=16}A${font}   CPU2 ${alignr}${execi 300 sensors | grep Core\ 1 | cut -c15-16 ;}°C
#${font Webdings:size=18}æ${font}  GPU ${alignr}${execi 30 intel-settings -q GPUCoreTemp -t }°C
${font DejaVu Sans:size=8:bold}Network${font} ${hr 2}
#${font Martin Vogel's Symbols:size=16}m${font}   Google.it (ping) ${alignr}${execi 180 ping -c6 google.it | tail -n1 | cut -d"/" -f5 | head -c-3}ms
${exec nmap -sP 192.168.0.0/24 | grep '192' | cut -b 6-37}
${if_existing /proc/net/route wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Up:      ${upspeed wlan0} kb/s ${voffset 4}${alignr}${upspeedgraph wlan0 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Down:      ${downspeed wlan0} kb/s ${voffset 4}${alignr}${downspeedgraph wlan0 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Upload: ${alignr}${totalup wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Download: ${alignr}${totaldown wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Signal: ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 8,60 wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Local Ip: ${alignr}${addr wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Public Ip: ${alignr}${execi 1 ~/Conky/scripts/ip.sh}
${else}${if_existing /proc/net/route eth0}
${voffset -6}${font PizzaDude Bullets:size=14}${font}   Up:      ${upspeed eth0} kb/s ${voffset 4}${alignr}${upspeedgraph eth0 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Down:      ${downspeed eth0} kb/s ${voffset 4}${alignr}${downspeedgraph eth0 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Upload: ${alignr}${totalup eth0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Download: ${alignr}${totaldown eth0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Local Ip: ${alignr}${addr eth0}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Public Ip: ${alignr}${execi 1 ~/Conky/scripts/ip.sh}${endif}${else}${if_existing /proc/net/route eth1}
${voffset -6}${font PizzaDude Bullets:size=14}${font}   Up:      ${upspeed eth1} kb/s ${voffset 4}${alignr}${upspeedgraph eth1 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Down:      ${downspeed eth1} kb/s ${voffset 4}${alignr}${downspeedgraph eth1 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Upload: ${alignr}${totalup eth1}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Download: ${alignr}${totaldown eth1}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Local Ip: ${alignr}${addr eth1}
${voffset 4}${font PizzaDude Bullets:size=14}${font}   Public Ip: ${alignr}${execi 1 ~/Conky/scripts/ip.sh}
In ${tcp_portmon 1 32767 count} Out ${tcp_portmon 32768 61000 count}${alignr}Tot ${tcp_portmon 1 65535 count}
${endif}${else}
${font PizzaDude Bullets:size=14}4${font}   Network Unavailable
${endif}

METEO ${hr 2}
${if_existing /proc/net/route wlan0}
${voffset -10}${alignr 56}${font ConkyWeather:style=Bold:size=40}${execi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=WF}${font}
${voffset -50}${font Weather:size=40}${font}  ${voffset -38}${font Arial Black:size=26}${execi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT}${font}

${voffset 0}${alignc 43}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=1 --shortweekday} ${alignc 8}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=2 --shortweekday} ${alignc -29}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=3 --shortweekday} ${alignc -64}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=4 --shortweekday}
${voffset 0}${alignc 75}${font ConkyWeather:size=28}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=WF --startday=1 --endday=4 --spaces=1}${font}
${voffset 0}${font DejaVu Sans:size=7}${alignc 48}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=1 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=1 --hideunits} ${alignc -14}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=2 --hideunit}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=2 --hideunits} ${alignc -40}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=3 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=3 --hideunits} ${alignr 6}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=4 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=4 --hideunits}${font}
${else}${if_existing /proc/net/route eth0}
${voffset -10}${alignr 56}${font ConkyWeather:style=Bold:size=40}${execi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=WF}${font}
${voffset -50}${font Weather:size=40}${font}  ${voffset -38}${font Arial Black:size=26}${execi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT}${font}

${voffset 0}${alignc 43}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=1 --shortweekday} ${alignc 8}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=2 --shortweekday} ${alignc -29}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=3 --shortweekday} ${alignc -64}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=4 --shortweekday}
${voffset 0}${alignc 75}${font ConkyWeather:size=28}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=WF --startday=1 --endday=4 --spaces=1}${font}
${voffset 0}${font DejaVu Sans:size=7}${alignc 48}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=1 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=1 --hideunits} ${alignc -14}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=2 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=2 --hideunits} ${alignc -40}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=3 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=3 --hideunits} ${alignr 6}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=4 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=4 --hideunits}${font}
${endif}${else}${if_existing /proc/net/route eth1}
${voffset -10}${alignr 56}${font ConkyWeather:style=Bold:size=40}${execi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=WF}${font}
${voffset -50}${font Weather:size=40}${font}  ${voffset -38}${font Arial Black:size=26}${execi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT}${font}

${voffset 0}${alignc 43}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=1 --shortweekday} ${alignc 8}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=2 --shortweekday} ${alignc -29}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=3 --shortweekday} ${alignc -64}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=DW --startday=4 --shortweekday}
${voffset 0}${alignc 75}${font ConkyWeather:size=28}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=WF --startday=1 --endday=4 --spaces=1}${font}
${voffset 0}${font DejaVu Sans:size=7}${alignc 48}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=1 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=1 --hideunits} ${alignc -14}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=2 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=2 --hideunits} ${alignc -40}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=3 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=3 --hideunits} ${alignr 6}${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=HT --startday=4 --hideunits}/${execpi 600 /home/marco/conkyForecast.py --location=ITXX0042 --datatype=LT --startday=4 --hideunits}${font}
${endif}${else}
${font ConkyWeather:size=14}4${font}   Weather Unavailable
${endif}
Qualcuno saprebbe dirmi cosa dovrei modificare?
grazie :D

Avatar utente
Diabolik62
Tenace Tecnocrate
Tenace Tecnocrate
Messaggi: 16046
Iscrizione: domenica 20 dicembre 2009, 16:29
Distribuzione: wind 10049 archfce4.12

Re: Posta il tuo .conkyrc & png

Messaggio da Diabolik62 » giovedì 29 aprile 2010, 14:49

Jaguaro ha scritto: ciao,

mi date qualche instradamento "infarinatura" per LUA


sono in alto mare

dove scarico
cosa devo installare
che file modificare o smanettare


grazie

ciao

J.
devi solo inserire il percorso del lua prima di TEXT

Avatar utente
Diabolik62
Tenace Tecnocrate
Tenace Tecnocrate
Messaggi: 16046
Iscrizione: domenica 20 dicembre 2009, 16:29
Distribuzione: wind 10049 archfce4.12

Re: Posta il tuo .conkyrc & png

Messaggio da Diabolik62 » giovedì 29 aprile 2010, 15:04

@Bigre
manca il conkyForecast py

Avatar utente
Diabolik62
Tenace Tecnocrate
Tenace Tecnocrate
Messaggi: 16046
Iscrizione: domenica 20 dicembre 2009, 16:29
Distribuzione: wind 10049 archfce4.12

Re: Posta il tuo .conkyrc & png

Messaggio da Diabolik62 » giovedì 29 aprile 2010, 15:08

guarda qui
che trovi il conkyForecastpy

http://www.deviantdark.altervista.org/?paged=

Avatar utente
Bigre
Prode Principiante
Messaggi: 175
Iscrizione: giovedì 10 settembre 2009, 22:03

Re: Posta il tuo .conkyrc & png

Messaggio da Bigre » giovedì 29 aprile 2010, 15:20

eccolo

Codice: Seleziona tutto

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="ITXX0042", 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 (Low Temp), HT (High 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"),eccolo:
(avevo iniziato a tradurlo in italiano.. ma vedendo che c'erano altri problemi ho smesso)
[code]#!/usr/bin/python
# -*- coding: utf-8 -*-
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="ITXX0042", 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 (Low Temp), HT (High 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_it = {
        "0": _(u"Tornado"),
        "1": _(u"Tempesta Tropicale"),
        "2": _(u"Uragano"),
        "3": _(u" Tormenta Violento"),
        "4": _(u"Tormenta"),
        "5": _(u"Pioggia con neve"),
        "6": _(u"Pioggia con Neve"),
        "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"0"),
		"1": _(u"1"),
		"2": _(u"2"),
		"3": _(u"3"),
		"4": _(u"4"),
		"5": _(u"5"),
		"6": _(u"6"),
		"7": _(u"7"),
		"8": _(u"8"),
		"9": _(u"9"),
		"10": _(u"10"),
		"11": _(u"11"),
		"12": _(u"12"),
		"13": _(u"13"),
		"14": _(u"14"),
		"15": _(u"15"),
		"16": _(u"16"),
		"17": _(u"17"),
		"18": _(u"18"),
		"19": _(u"19"),
		"20": _(u"20"),
		"21": _(u"21"),
		"22": _(u"22"),
		"23": _(u"23"), 
		"24": _(u"24"),
		"25": _(u"25"),
		"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"a"),
		"NNE": _(u"b"),
		"NE": _(u"c"),
		"ENE": _(u"d"),
		"E": _(u"e"),
		"ESE": _(u"f"),
		"SE": _(u"g"),
		"SSE": _(u"h"),
		"S": _(u"i"),
		"SSW": _(u"j"),
		"SW": _(u"k"),
		"WSW": _(u"l"),
		"W": _(u"m"),
		"WNW": _(u"n"),
		"NW": _(u"o"),
		"NNW": _(u"p"),
		"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 = "it"

	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 = 30
	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 = "it" #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 = "it" #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):

		
non me lo faceva inserire tutto.. quindi l'ho diviso in due parti.. questa è la prima.. la seconda nel prossimo messaggio :D[/code]

Avatar utente
Bigre
Prode Principiante
Messaggi: 175
Iscrizione: giovedì 10 settembre 2009, 22:03

Re: Posta il tuo .conkyrc & png

Messaggio da Bigre » giovedì 29 aprile 2010, 15:21

Codice: Seleziona tutto

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"kp/h"
					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 == "it":
						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 == "it":
								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 == "it":
								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 == "it":
								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 == "it":
								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 == "it":
								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 == "it":
								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, 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()
..avevo iniziato a tradurre qualcosa dal francese all'italiano.. ma vedendo poi che avevo altri problemi ho lasciato perdere :D

Chiusa

Ritorna a “Bar Ubuntu”

Chi c’è in linea

Visualizzano questa sezione: 0 utenti iscritti e 4 ospiti