Hello,
suivant le bon exemple de Didier-T je me suis mis au python ainsi qu'un bout de lua. je voulais apprendre donc j'ai refait les scripts à ma manière - elle n'est ni meilleure ni moins bonne, c'est juste ma manière 😉. Je ne voulais pas les poster mais finalement je me suis dit que cela pouvait aussi toujours servir d’exemple pour d'autres si vous vouliez vous mettre aussi au python. J'étais bien content de trouver de l'aide dans tous les scripts présentés ici 😉
===============================================================================================
Attention mes scripts sont beaucoup moins complets que ceux de Didier-T au niveau des données à rapatrier. D'autre part au lieu d'avoir une seule fonction de rapatriement, j'en ai 4 : une pour les conditions actuelles, une pour les forecasts des jours à venir, une pour les huit heures et un dernière pour la lune.
qu'est ce qu'ils ont de différents:
1) ils sont peut être un peu plus résistants aux changements des formats des pages web sur ces points:
- N/A est renvoyé en cas de non rapatriement de la données ou de l'icone - j'ai d’ailleurs crée une icône "na.png"
- si la page web n'est pas correctement downloadée
- si l'on arrive pas à trouver la donnée voulue dans la page web.
2) ils placent les données rapatriées dans un fichier XML (appelé data_file) qui est lu ensuite par le script lua. Je n'ai donc que 2 fonctions qui retourne soit la valeur soit l’icône (au lieu de toutes les fonctions
function conky_Meteo_balblabla(j)
return (balbalbla)
end
Ce fichier est reutilisé en cas d'erreur ou en cas de non connection internet
3) DEBIAN SQUEEZE l'oblige il ne fait ni appel a python3 ni bs4 mais simplement python et beautifulsoup (ATTTENTION SOUS DEBIAN SQUEEZE il faut prendre la version de beautifulsoup fournie par les backports v 3.2.0-2~bpo60+1). les scripts ont été testés sous debian squeeze, sous debian wheezy et le live CD ubuntu 12.4
les packets à installer sont
conky
python-beautifulsoup
lua5.2 (uniquement pour du debug)
===============================================================================================
- les données pouvant être affichées sont celles contenues dans le fichier XML data_file. il y a :
1) les données courantes ou 8heures ou lune - c'est tout ce qu'il a entre les balises <day_0> et <\day_0>
2) les prévisions pour les jours suivants. c'est tout ce qu'il a entre les balises <day_1> et <\day_1>, <day_2> et <\day_2>...
3) les données à afficher sont identifiées par les balises <name> et leur valeurs par les balises <value>
suivant l’exemple de conkyrc de Didier-T cela peut être fait de la manière suivante
lua display_meteo \1 \2 } # \1=nom dans la balise dans le fichier XML data_file \2=jour dans le fichier XML data_file>
pour la température actuelle:
lua display_meteo cur_temp 0
pour la température prevues dans 3 jours:
lua display_meteo Temp_max_d 3
et pour les icones il suffit d'appeler la fonction
lua_parse display_icon \1 \2 \3 \4 # \1=nom de l'icones \2=position \3=taille \4=jour
===============================================================================================
En ce qui concerne les scripts les voila:
pour le fichier de configuration a appeler: mymeteo.cfg
#working directory
work_dir=~/conky/
#work_dir=/DIVERS/tmp/python/
# Web address
web=http://www.accuweather.com/fr/ca/toronto/m5g/weather-forecast/55488
#max number of day
nb_day=5
#update_time (secondes)
update=600
#update=30
#update=600
#update=1800
#debug traces
DEBUG=yes
pour le fichier lua: A APPELER mymeteo.lua
-- -- Magic charachters: ^ $ ( ) % . [ ] * + - ?
-- . --- (a dot) represents all characters.
-- %a --- all letters.
-- %c --- all control characters.
-- %d --- all digits.
-- %l --- all lowercase letters.
-- %p --- all punctuation characters.
-- %s --- all space characters.
-- %u --- all uppercase letters.
-- %w --- all alphanumeric characters.
-- %x --- all hexadecimal digits.
-- %z --- the character with hex representation 0x00 (null).
-- %% --- a single '%' character.
-- %1 --- captured pattern 1.
-- %2 --- captured pattern 2 (and so on).
-- %f[s] transition from not in set 's' to in set 's'.
-- %b() balanced pair ( ... )
require "io"
require "os"
--List of the accents and "strange" characters in the patterns
local pat="%é%è%à%ä%â%ê%ô%ç%É%È%À%Â%Ä%Ê%Ô%Ç"
-- Global variable used in different functions
local web, data_file, actual_time, tc, start, delay, save_dir, all_day, DEBUG
local forecast_daily_matrix={}
local forecast_daily_matrix_name={}
DEBUG="no"
--Formatage des pages web
function format_FR(var)
var = var:gsub("ô", "ô"):gsub("â", "â"):gsub("é", "é"):gsub("è", "è"):gsub("à", "à"):gsub("ç", "ç"):gsub("ê", "ê"):gsub("ö", "ö"):gsub("î", "î"):gsub("ï", "ï"):gsub("û", "û"):gsub("ü", "ü"):gsub("'", "'"):gsub("Poudreries", "Bourrasques de neige"):gsub("É", "É"):gsub("°",""):gsub("[\n\r]",""):gsub("é", "é")
return var
end
function print_msg (message)
if DEBUG ~= "no" then
print (message)
end
end
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
-- check the status of a variable. If the partern was not found it will retrun N/A instead of nill.
function check_status (varname, var)
if var == nil then
local file = io.open("Debug", "w")
var="N/A"
file:write ("\n Debug ", varname," ", var)
file:close()
end
return var
end
-- Intialisation of conky and reading parameter file
function conky_init_meteo (cfg)
local home = os.getenv("HOME")
if string.find(cfg, "~") ~= nil then
cfg = string.gsub(cfg, "~", home)
cfg = string.gsub(cfg, "$HOME", home)
print_msg ("replace ~ ==>", cfg)
end
local file = assert(io.open(cfg, "rb") )
local line = file:read()
for line in file:lines() do
pos1 = string.find(line, '#')
if pos1 ~= nil then
line = string.sub(line, 1, pos1-1)
end
pos1 = string.find(line, '=')
if string.find(line, 'work_dir=') ~= nil then
local save_dir1 = string.sub(line, pos1+1)
save_dir = string.gsub(save_dir1, "~", home)
print_msg ("working directory is : "..save_dir)
elseif string.find(line, 'web=') ~= nil then
web = string.sub(line, pos1+1)
print_msg ("web address is set to: "..web)
elseif string.find(line, 'update=') ~= nil then
delay = string.sub(line, pos1+1)
print_msg ("delay is set to : "..delay)
elseif string.find(line, 'DEBUG=') ~= nil then
DEBUG = string.sub(line, pos1+1)
if DEBUG == "no" or DEBUG == "NO" then
print ("===================")
print ("No debug traces set")
end
end
end
io.close(file)
-- variable initialization
all_day = { 1,2,3,4,5 }
-- timer initialization
actual_time = os.difftime(os.time(), delay)
tc = actual_time
start = 0
end
-- Update : get and save internet page
function conky_update()
local file, web_file, web_file_name
if tonumber(delay) <= os.difftime(os.time(), actual_time) then
print_msg ("Diff os time - actual time : "..os.difftime(os.time(), actual_time) )
print_msg ("Delay set up to : "..delay)
actual_time = os.time()
start = 1
print_msg ("Fetch update from web pages -- BEGIN")
python_is_OK = os.execute("python "..save_dir.."/mymeteo.py "..save_dir.." "..web.." ")
if python_is_OK == true or python_is_OK == 0
then
print_msg ("Fetch update from web pages -- END")
conky_update_table ()
else
print_msg ("FAILED to launch python script")
conky_update_table ()
end
end
return " "
end
--
function conky_update_table ()
local val, name, detail_day
data_file_name=save_dir.."/data_file"
data_file = io.open(data_file_name, "r" )
local file = string.gsub(data_file:read("*a")," ","\\sPaCe\\")
forecast_daily_matrix[0]={}
forecast_daily_matrix_name[0]={}
day = 0
for line in io.lines(data_file_name) do
--print(i ,line)
new_day=string.match(line, "<\\day_")
new_line = string.gsub(line," ","\\sPaCe\\")
s,f,index_str,name,value=string.find(new_line,"<index>([%d]*)<name>([%a%p%d]*)<value>([%a%p%d"..pat.."]*)<\\index>")
--print (line)
--print (day , new_day, index, name, value)
index=tonumber(index_str)
if index ~= nil and name ~= nil and new_day == nil then
-- forecast_daily_matrix_name[day][index]=tostring(name)
forecast_daily_matrix_name[day][index]=tostring(string.gsub(name,"\\sPaCe\\"," "))
forecast_daily_matrix[day][index]=tostring(string.gsub(value,"\\sPaCe\\"," "))
--print (index, forecast_daily_matrix_name[day][index], forecast_daily_matrix[day][index])
end
if new_day ~= nil then
day = day +1
forecast_daily_matrix[day]={}
forecast_daily_matrix_name[day]={}
end
end
all_day=day
data_file:close()
return " "
end
-- function to look for a variable into a table and return its value
function inTable(tbl, item, day)
local key, value
for key, value in ipairs(tbl) do
--print (key,value)
if value == item then return key, value, day end
end
return false
end
-- return a value in the "forecast_daily_matrix" table for being displayed in conky
function conky_display_meteo (var, day_ref)
local index, key, value, Aday, day_found, var_value
var_value=tostring(var)
Aday=tonumber(day_ref)
--print (var, Aday)
if Aday == nil then
Aday=tonumber(0)
end
--print ("var to find:", var, "day", Aday, "matrix: ", forecast_daily_matrix_name [Aday])
index,value,day=inTable(forecast_daily_matrix_name [Aday], var, Aday)
--print (index,value,day)
if index ~= false then
--print (forecast_daily_matrix [Aday] [index])
var_value=forecast_daily_matrix [Aday] [index]
return var_value
else
return var_value
end
end
-- return an icon in the "forecast_daily_matrix" table for being displayed in conky
function conky_display_icon (var, position, size, day_ref)
local index, key, value, Aday, day_found, image, day_night, sunset, sunrise, actual_hour, var_value, moon_stat, moon_visi, moon_icon_dir
--print (var, position, size, day_ref)
day_night="jour"
var_value=tostring(var)
if string.find(var, "moon") ~= nil then
day_night="lune"
--eg : moon_icon_dir=save_dir.."/meteo/icones/lune/"..<moon_status>.."/"..<moon_visibility>.."_t.png"
moon_stat=tostring(conky_display_meteo("moon_status", 0))
moon_visi=tostring(conky_display_meteo("moon_visibility", 0))
--print (moon_stat,moon_visi)
moon_icon_dir=save_dir.."/meteo/icones/lune/"..moon_stat.."/"..moon_visi.."_t.png"
--print (moon_icon_dir, position, size)
if file_exists (moon_icon_dir) == true then
return "${image "..moon_icon_dir.." -p "..position.." -s "..size.." -f 60}"
else
return "${image "..save_dir.."/meteo/icones/na.png -p "..position.." -s "..size.." -f 60}"
end
else
if string.find(var, "_n") ~= nil then
day_night="nuit"
end
if string.find(var, "_d") ~= nil then
day_night="jour"
end
if string.find(var, "cur_") ~= nil or string.find(var, "Icon_8") ~= nil then
sunrise=tonumber(conky_display_meteo("sunrise_HH", 1)..conky_display_meteo("sunrise_MM", 1))
sunset=tonumber(conky_display_meteo("sunrise_HH", 1)..conky_display_meteo("sunrise_MM", 1))
actual_hour=tonumber(os.date("%H%M", os.time()))
--print (sunrise, actual_hour, sunset)
if sunrise ~= nil and sunset ~= nil then
if actual_hour <= sunset and actual_hour >= sunrise then
--print ("jour")
day_night="jour"
else
--print ("nuit")
day_night="nuit"
end
else
day_night="jour"
end
end
directory=save_dir.."/meteo/icones/"..day_night
Aday=tonumber(day_ref)
--print (var, Aday, directory)
if Aday == nil then
Aday=tonumber(0)
end
--print ( var, "day", Aday, "matrix: ", forecast_daily_matrix_name [Aday])
index,value,day=inTable(forecast_daily_matrix_name [Aday], var, Aday)
--print (index,value,day)
if index ~= false then
--print (forecast_daily_matrix [Aday] [index])
image=(forecast_daily_matrix [Aday] [index])
if file_exists (directory.."/"..image..".png") == true then
return "${image "..directory.."/"..image..".png -p "..position.." -s "..size.." -f 60}"
else
return "${image "..directory.."/na.png -p "..position.." -s "..size.." -f 60}"
end
else
return "${image "..directory.."/na.png -p "..position.." -s "..size.." -f 60}"
end
--return "${image "..r.."/jour/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
end
-- following fonction for debugging with LUA it is not used by conky
function stand_alone_no_conky ()
conky_init_meteo("~/conky/mymeteo.cfg")
--conky_init_meteo("~/conky/example/mymeteo.cfg")
--conky_init_meteo("/home/debian1/conky/python/mymeteo.cfg")
conky_update()
--
-- samples for test:
value=conky_display_meteo("cur_day", 0)
print (value)
value=conky_display_meteo("day_name", 1)
print (value)
value=conky_display_meteo("cur_status")
print ("OK", value)
value=conky_display_meteo("ttt",0)
print ("NOK:", value)
value=conky_display_icon ("cur_icon", "100x100", "60" , 0)
print (value)
value=conky_display_icon ("Icon_8_3", "100x100", "60" , 0)
print (value)
value=conky_display_icon ("daily_icon_n", "100x100", "60" , 3)
print (value)
value=conky_display_meteo ("cur_ppp", "100x100", "60" , 3)
print ("NOK:",value)
end
-- ########################################
-- #### MAIN
-- ########################################
--
--
-- Comment out following line for debugging with LUA : lua mymeteo.lua
-- stand_alone_no_conky()
-- Comment following line for using conky : lua mymeteo.lua
conky_init_meteo()
et pour le fichier python: A APPELER mymeteo.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#from urllib import urlretrieve
import urllib
import urllib2
from os import path, makedirs, system
from time import time, strftime, localtime, sleep
from datetime import datetime
from re import search, compile, findall
# for Squeeze and Wheezy
from BeautifulSoup import BeautifulSoup
import sys
allday=[ '1', '2', '3', '4', '5']
# Initialise table
# the name shown below are the name to be called in the conkyrc file
# first index (which is 0 in python) must be empty because lua will start a index 1.
# for day_0:
current_condition_name = ['','cur_day', 'cur_month', 'cur_year', 'cur_hour', 'cur_min', 'cur_icon', 'cur_temp', 'cur_tempfeel', 'cur_status', 'cur_wind_dir', 'cur_wind_speed', 'cur_Humidity', 'cur_Pressure', 'cur_UV_max', 'cur_cloud_cover', 'cur_ceiling', 'cur_dew_point', 'cur_visibility' ]
eight_condition_name = ['','Icon_8_1', 'Icon_8_2', 'Icon_8_3', 'Icon_8_4', 'Icon_8_5', 'Icon_8_6', 'Icon_8_7', 'Icon_8_8', 'HH_1', 'HH_2', 'HH_3', 'HH_4', 'HH_5', 'HH_6', 'HH_7', 'HH_8' ]
moon_condition_name = ['','moon_status', 'moon_visibility', 'moon_phase' ]
# for day_xx:
daily_condition_name = ['','daily_icon_d', 'daily_icon_n', 'Temp_max_d', 'Temp_RealF_d', 'Temp_min_n', 'Temp_RealF_n', 'daily_condition_d', 'daily_condition_n', 'sunrise_HH', 'sunrise_MM', 'sunset_HH', 'sunset_MM', 'year_date', 'month_date', 'day_date', 'day_name' ]
#other variables or tables:
current_condition_len=(len(current_condition_name))
current_condition = [""] * current_condition_len
index_to_follow=None
condition_daily_len=(len(daily_condition_name))
daily_condition = [""] * condition_daily_len
daily_condition[1] = [""] * condition_daily_len
daily_condition[2] = [""] * condition_daily_len
daily_condition[3] = [""] * condition_daily_len
daily_condition[4] = [""] * condition_daily_len
daily_condition[5] = [""] * condition_daily_len
eight_condition_len=(len(eight_condition_name))
eight_condition = [""] * eight_condition_len
moon_condition_len=(len(moon_condition_name))
moon_condition = [""] * moon_condition_len
################# Function to download the web page and report error if any
def get_url_to_var (web_add):
user_agent = 'Mozilla/5.0 (X11; Linux x86_64)'
headers = { 'User-Agent' : user_agent }
req = urllib2.Request(web_add, headers)
try:
response = urllib2.urlopen(web_add)
except urllib2.URLError, e:
response = 0
return response
################# function to print data when debugging - it is only useful when debugging and if DEBUG_tr is set to "TRUE" (see end of this file)
def print_debug (var_name, var):
if DEBUG_tr == "TRUE":
print (var_name, var)
################# function to look for an item in the saved web page. return the value or N/A if an error occurs
def try_compile (pattern_to_find, string_to_find, group_1=1):
#print(group_1, pattern_to_find, string_to_find)
if int(group_1) == 1 or int(group_1) == 2 or int(group_1) == 3:
try:
value1 = compile(pattern_to_find).search(str(string_to_find)).group(1)
except AttributeError as detail:
print_debug ("Handling run-time error:", detail)
print_debug (" pattern :", pattern_to_find)
print_debug (" with string :", string_to_find)
value1="N/A"
if int(group_1) == 1:
return value1
if int(group_1) == 2 or int(group_1) == 3:
try:
value2 = compile(pattern_to_find).search(str(string_to_find)).group(2)
except AttributeError as detail:
print_debug ("Handling run-time error:", detail)
print_debug (" pattern :", pattern_to_find)
print_debug (" with string :", string_to_find)
value2="N/A"
if int(group_1) == 2:
return [value1, value2]
if int(group_1) == 3:
try:
value3 = compile(pattern_to_find).search(str(string_to_find)).group(3)
except AttributeError as detail:
print_debug ("Handling run-time error:", detail)
print_debug (" pattern :", pattern_to_find)
print_debug (" with string :", string_to_find)
value3="N/A"
return [value1, value2, value3]
################# update current conditions for DAY 0
def update_cur_cond(html_page, page_type):
"""update current conditions"""
current_tag=None
if page_type is "page_is_var":
currentCondUTF8=html_page.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(currentCondUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
else :
currentCond = open(html_page, "r")
currentCondUTF8=currentCond.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(currentCondUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
currentCond.close()
current_tag=soup.find(id="details")
#search for icon
#icon=current_tag.find("[class~=icon]")
icon=current_tag.findAll("div", {"class": "forecast"})
#cur_icon=compile("(.*)-").search(str(icon_tmp)).group(1)
cur_icon=try_compile("icon i-(.*)-",icon,1)
print_debug ("icon c: ",cur_icon)
#search for temperature
cur_temp = try_compile("temp\">(-?\d*)<" , str(icon))
cur_tempfeel = try_compile("realfeel.*® (-?\d*)<", str(icon))
cur_status = try_compile("cond\">(.*)<" , str(icon)).split("<")[0]
print_debug("Cur Cond: ", cur_temp + " " + cur_tempfeel + " " + cur_status)
#search for date
histo=soup.find(id="feature-history")
cur_complete_date = try_compile("Historique.* - (.*)/(.*)/(.*)<",str(histo),3)
cur_day=str(cur_complete_date[0])
cur_month=str(cur_complete_date[1])
cur_year=str(cur_complete_date[2])
print_debug("date:", cur_day + " " + cur_month + " " + cur_year)
#search for time
#time_info=soup.find(id="panel-body-content")
time_info1=soup.findAll("div", {"class": "feature-stats"})
time_info = try_compile("Summary - (.*):(.*) <",str(time_info1),2)
cur_hour=str(time_info[0])
cur_min=str(time_info[0])
print_debug("time", cur_hour + " " + cur_min)
#search for Wind details
wind_info = current_tag.findAll("div", {"class": "wind-box-lg"})
if len(wind_info) == 0:
wind_info=current_tag.findAll("div", {"class": "wind-box-lg"})
for div in wind_info:
cur_wind_dir = try_compile("var d = '(.*)';", str(wind_info)).replace("W", "O")
cur_wind_speed= try_compile("var s = '(.*)km", str(wind_info))
print_debug("Wind: ", cur_wind_dir + " " + cur_wind_speed)
stat_info=current_tag.findAll("ul", {"class": "stats"})
#print ("All stat", stat_info)
#cur_Humidity=str(findall("Humidit.*>(\d*)%", str(stat_info)))
cur_Humidity = try_compile("Humidit.*>(\d*)%" , str(stat_info))
cur_Pressure = try_compile("Pression.*>(.*) mbar" , str(stat_info))
cur_UV_max = try_compile("Indice.*>(\d)<" , str(stat_info))
cur_cloud_cover= try_compile("Couverture.*>(\d*)%" , str(stat_info))
cur_ceiling = try_compile("Ceiling.*>(.*) m" , str(stat_info))
cur_dew_point = try_compile("Point de.*>(-?\d*).*C<", str(stat_info))
cur_visibility = try_compile("Visibilit.*>(\d*) km" , str(stat_info))
print_debug("Stat: " , cur_Humidity + " " + cur_Pressure + " " + cur_UV_max + " " + cur_cloud_cover + " " + cur_ceiling + " " + cur_dew_point + " " + cur_visibility)
current_condition [1] = cur_day
current_condition [2] = cur_month
current_condition [3] = cur_year
current_condition [4] = cur_hour
current_condition [5] = cur_min
current_condition [6] = cur_icon
current_condition [7] = cur_temp
current_condition [8] = cur_tempfeel
current_condition [9] = cur_status
current_condition [10] = cur_wind_dir
current_condition [11] = cur_wind_speed
current_condition [12] = cur_Humidity
current_condition [13] = cur_Pressure
current_condition [14] = cur_UV_max
current_condition [15] = cur_cloud_cover
current_condition [16] = cur_ceiling
current_condition [17] = cur_dew_point
current_condition [18] = cur_visibility
index_to_follow=19
################# Udpate data for the folling days
def update_daily_weather_forecast(html_page, day_to_retrive, page_type):
"""update 5 following days conditions"""
daily_tag=None
day=int(day_to_retrive)
if page_type is "page_is_var":
#dailyCondUTF8=html_page.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
#soup = BeautifulSoup(dailyCondUTF8)
soup = BeautifulSoup(html_page, convertEntities=BeautifulSoup.HTML_ENTITIES)
else :
my_file=html_page+day_to_retrive
print_debug("FILE", my_file)
dailyCond = open(my_file, "r")
dailyCondUTF8=dailyCond.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(dailyCondUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
dailyCond.close()
daily_tag=soup.find(id="details")
#search for DAY icon
daily_icon_d=daily_tag.findAll("div", {"class": "day"})
i=1
daily_icon_val_d = try_compile("icon i-(.*)-", str(daily_icon_d))
daily_condition[day][i]=daily_icon_val_d
print_debug ("icon d: ",daily_condition[day][i])
i=i+1
#search for NIGHT icon
daily_icon_n=daily_tag.findAll("div", {"class": "night"})
daily_icon_val_n = try_compile("icon i-(.*)-", str(daily_icon_n))
daily_condition[day][i]=daily_icon_val_n
print_debug ("icon n: ",daily_condition[day][i])
i=i+1
#search for temperature
i = 3
info_daily=daily_tag.findAll("div", {"class": "info"})
#print (info_daily)
for info_d in info_daily:
cur_temp = try_compile( "temp\">(-?\d*)<", str(info_d))
cur_tempfeel = try_compile( "RealFeel.*® (-?\d*)°<", str(info_d))
# Save values
daily_condition[day][i]=cur_temp
print_debug("Temp : ", daily_condition[day][i]+" index "+str(i))
i=i+1
daily_condition[day][i]=cur_tempfeel
print_debug("RealF: ", daily_condition[day][i]+" index "+str(i))
i=i+1
#search for Conditions
i = 7
p=daily_tag.findAll('p')
j=0
for pv in p:
j=j+1
val=pv.getText()
if len(val) >= 4: # Assumed that if leng is more than 4 charachter it s the goood thing
daily_condition[day][i]=val.encode(sys.stdout.encoding,'replace')
print_debug("Cond: ", daily_condition[day][i])
i=i+1
#print daily_condition[day][5].encode(sys.stdout.encoding,'replace')
#print daily_condition[day][6].encode(sys.stdout.encoding,'replace')
#cur_status=compile("cond\">(.*)<").search(str(cur_info)).group(1).split("<")[0]
#search for Sunrise Sunset
i = 9
sun_tag=soup.find(id="feature-sun")
#print (sun_tag)
sunrise = try_compile("start.*>(\d*):(\d*)<", str(sun_tag), 2)
sunset = try_compile("finish.*>(\d*):(\d*)<", str(sun_tag), 2)
sunrise_HH=str(sunrise[0])
sunrise_MM=str(sunrise[1])
sunset_HH=str(sunset[0])
sunset_MM=str(sunset[1])
daily_condition[day][i]=sunrise_HH
i=i+1
daily_condition[day][i]=sunrise_MM
i=i+1
daily_condition[day][i]=sunset_HH
i=i+1
daily_condition[day][i]=sunset_MM
i=i+1
print_debug ("Sunrise:",sunrise_HH+sunrise_MM)
print_debug ("Sunset :",sunset_HH+sunset_MM)
#search for date
i = 13
date_tag=soup.find(id="feature-history")
#print (date_tag)
daily_complete_date = try_compile("Historique.* - (.*)/(.*)/(.*)<",str(date_tag),3)
daily_day=str(daily_complete_date[0])
daily_month=str(daily_complete_date[1])
daily_year=str(daily_complete_date[2])
daily_condition[day][i]=daily_day
i=i+1
daily_condition[day][i]=daily_month
i=i+1
daily_condition[day][i]=daily_year
i=i+1
print_debug("date:", daily_day + " " + daily_month + " " + daily_year)
if ( 2000 < int(daily_year) < 2099 ) and ( 1 <= int(daily_month) <= 12 ) and ( 1 <= int(daily_day) <= 31 ):
#print strftime('Nous sommes %A ', localtime())
daily_date_epo=datetime(int(daily_year), int(daily_month), int(daily_day))
#daily_date_epo.strftime("%A")
days_fr = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi' ]
days_en = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]
#day_name_en=daily_date_epo.strftime("%A")
#day_name_fr=days_fr[days_en.index(str(day_name_en))]
day_name_fr=days_fr[days_en.index(daily_date_epo.strftime("%A"))]
daily_condition[day][i]=day_name_fr
print_debug("day :", daily_condition[day][i])
else:
daily_condition[day][i]="N/A"
print_debug("day :", daily_condition[day][i])
################# Udpate data for the next 8 hours for DAY 0
def update_8hours(html_page, page_type):
"""update 8 hours conditions"""
eight_tag=None
if page_type is "page_is_var":
eighthoursUTF8=html_page.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(eighthoursUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
else :
eighthours=open(html_page, "r")
eighthoursUTF8=eighthours.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(eighthoursUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
eighthours.close()
eight_tag=soup.find(id="detail-hourly")
#search for icon
icon_tag=eight_tag.findAll("tr", {"class": "forecast"})
soup2 = BeautifulSoup( str(icon_tag) )
icon=soup2.findAll("div")
#print ("icon", icon)
i=1
for info_eight in icon:
cur_eight_icon = try_compile("icon i-(\d*)-",str(info_eight))
eight_condition[i]=cur_eight_icon
print_debug("Icon: ", eight_condition[i])
i=i+1
#search real hours for 8 following hours
allhours_tag=eight_tag.findAll("tr", {"class": "realfeel"})
soup2 = BeautifulSoup( str(allhours_tag) )
eighthours=soup2.findAll("td")
#print ("all", eighthours)
i=1
for info_hh in eighthours:
cur_eight_hours = try_compile(">(.*)</td", str(info_hh))
print_debug("i : ", i)
if i > 8 and i <= 16 :
eight_condition[i]=cur_eight_hours
print_debug("hour: ", eight_condition[i])
i=i+1
################# Udpate Moon data for DAY 0
def update_moon(html_page, page_type):
moonfile_tag=None
if page_type is "page_is_var":
moonfileUTF8=html_page.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(moonfileUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
else :
moonfile=open(html_page, "r")
moonfileUTF8=moonfile.read().decode('utf-8').encode(sys.stdout.encoding,'replace')
soup = BeautifulSoup(moonfileUTF8, convertEntities=BeautifulSoup.HTML_ENTITIES)
moonfile.close()
#search for data
moonfile_tag=soup.findAll("table", {"class": "ephemerides"})
moon_status_all= try_compile("img src=\"imgs/(.*)/(.*).png", str(moonfile_tag), 2)
moon_phase = try_compile("Phases:.*\">(.*)</s" , str(moonfile_tag), 1)
moon_status=str(moon_status_all[0])
moon_visibility=str(moon_status_all[1])
# write into table
moon_condition[1]=moon_status
moon_condition[2]=moon_visibility
moon_condition[3]=moon_phase
print_debug("status : ", moon_condition[1])
print_debug("visibil: ", moon_condition[2])
print_debug("phase : ", moon_condition[3])
################# Fill file with data
def data_fill (data_file):
data_file_to_w = open(data_file, "w")
#Save data to file for ==> current_condition
t = 1
index = 1
data_file_to_w.write("<day_0>\n")
while t < current_condition_len:
print_debug(current_condition_name[t], current_condition[t])
data_to_write="<index>"+str(index)+"<name>"+str(current_condition_name[t])+"<value>"+str(current_condition[t])+"<\\index><\\name><\\value>\n"
data_file_to_w.write(data_to_write)
#print ("curent",t , current_condition_name[t], current_condition[t])
t +=1
index +=1
#Save data to file for ==> 8hours
t =1
while t < eight_condition_len:
print_debug(eight_condition_name[t],eight_condition[t])
data_to_write="<index>"+str(index)+"<name>"+str(eight_condition_name[t])+"<value>"+str(eight_condition[t])+"<\\index><\\name><\\value>\n"
data_file_to_w.write(data_to_write)
t +=1
index +=1
#Save data to file for ==> MOON
t =1
while t < moon_condition_len:
print_debug(moon_condition_name[t],moon_condition[t])
data_to_write="<index>"+str(index)+"<name>"+str(moon_condition_name[t])+"<value>"+str(moon_condition[t])+"<\\index><\\name><\\value>\n"
data_file_to_w.write(data_to_write)
t +=1
index +=1
data_file_to_w.write("<\\day_0>\n")
#Save data to file for ==> DAYS
for day_to_write in allday:
t =1
data_file_to_w.write("<day_"+str(day_to_write)+">\n")
day=int(day_to_write)
while t<condition_daily_len:
print_debug(daily_condition_name[t],daily_condition[day][t])
data_to_write="<index>"+str(t)+"<name>"+str(daily_condition_name[t])+"<value>"+str(daily_condition[day][t])+"<\\index><\\name><\\value>\n"
data_file_to_w.write(data_to_write)
t +=1
data_file_to_w.write("<\\day_"+str(day_to_write)+">\n")
#clase file where data are written
data_file_to_w.close()
def get_addresses (web_add,save_dir):
all_addr_retrived=None
x=1
if TEST_OFL == "TRUE":
current_weather_address = str(save_dir+"/current-weather")
daily_weather_address=str(save_dir+"/daily-weather-forecastday")
moon_address=str(save_dir+"/moon_file")
eight_hours_address=str(save_dir+"8hours")
update_cur_cond (current_weather_address, "page_is_file")
update_8hours(eight_hours_address, "page_is_file")
update_moon(moon_address, "page_is_file")
for day in allday:
update_daily_weather_forecast(daily_weather_address, day, "page_is_file")
## retrun 1 to continue script
return 1
else:
while all_addr_retrived is None:
#setup all web addresses from the ORG one
current_weather_address=web_add.replace("weather-forecast","current-weather")
daily_weather_address=str(web_add.replace("weather-forecast","daily-weather-forecast"))+"?day="
moon_address=str("http://www.calendrier-lunaire.net/")
eight_hours_address=web_add.replace("weather-forecast","hourly-weather-forecast")
print_debug ("CURRENT ADDRESS :", current_weather_address)
print_debug ("DAILY ADDRESS :", daily_weather_address)
print_debug ("MOON ADDRESS :", moon_address)
print_debug ("8HOURS ADDRESS :", eight_hours_address)
# Get web page and store it
current_web_WEB = get_url_to_var (current_weather_address)
current_daily_WEB= [""] * ( len(allday) + 1 )
for day in allday:
current_daily_WEB[int(day)] = get_url_to_var (daily_weather_address+day)
current_moon_WEB = get_url_to_var (moon_address)
current_eight_WEB = get_url_to_var (eight_hours_address)
# Check if file where correctly retrived in case of pb
if current_web_WEB == 0 or current_daily_WEB[1] == 0 or current_moon_WEB == 0 or current_eight_WEB == 0:
print_debug ("Files Not retrived", "NOK")
all_addr_retrived=None
else:
print_debug ("Files retrived", "OK")
all_addr_retrived="TRUE"
if DEBUG_write_to_file is "TRUE":
current_weather_address = str(save_dir+"/current-weather")
daily_weather_address=str(save_dir+"/daily-weather-forecastday")
moon_address=str(save_dir+"/moon_file")
eight_hours_address=str(save_dir+"8hours")
data_file_to_w = open(current_weather_address, "w")
data_file_to_w.write(current_web_WEB.read())
data_file_to_w.close()
for day in allday:
data_file_to_w = open(daily_weather_address+day, "w")
data_file_to_w.write(current_daily_WEB[int(day)].read())
data_file_to_w.close()
data_file_to_w = open(moon_address, "w")
data_file_to_w.write(current_moon_WEB.read())
data_file_to_w.close()
data_file_to_w = open(eight_hours_address, "w")
data_file_to_w.write(current_eight_WEB.read())
data_file_to_w.close()
update_cur_cond (current_weather_address, "page_is_file")
update_8hours(eight_hours_address, "page_is_file")
update_moon(moon_address, "page_is_file")
for day in allday:
update_daily_weather_forecast(daily_weather_address, day, "page_is_file")
current_daily_WEB[int(day)]=None
current_web_WEB=None
current_eight_WEB=None
current_moon_WEB=None
print_debug ("File saved", "OK")
else: # Just write things in variable
update_cur_cond (current_web_WEB, "page_is_var")
update_8hours(current_eight_WEB, "page_is_var")
update_moon(current_moon_WEB, "page_is_var")
for day in allday:
update_daily_weather_forecast(current_daily_WEB[int(day)], day, "page_is_var")
current_daily_WEB[int(day)]=None
current_web_WEB=None
current_eight_WEB=None
current_moon_WEB=None
print_debug ("File saved", "OK")
if all_addr_retrived is None:
x=x+1
print("problème de récupération de données\n essais n°"+str(x))
if x == 3 :
all_addr_retrived="NOK"
sleep(10)
if all_addr_retrived is "TRUE":
return 1
if all_addr_retrived is "NOK":
return 0
def main():
"""entry point"""
if len(sys.argv) != 3:
save_dir="~/conky/"
#save_dir="/home/debian1/conky/"
meteo_url="http://www.accuweather.com/fr/ca/toronto/m5g/weather-forecast/55488"
print_debug ("Default path will be", save_dir)
print_debug ("Default url will be", meteo_url)
else:
save_dir=sys.argv[1]+"/"
meteo_url=sys.argv[2]
print_debug ("", sys.argv[1]) #Display arg1
print_debug ("", sys.argv[2]) #Display arg1
print_debug ("path is", save_dir)
is_tables_filled=get_addresses(meteo_url,save_dir)
if is_tables_filled == 1 :
print_debug ("Tables filled", "OK")
data_fill (save_dir+"/data_file")
#return "false"
else :
print_debug ("nothing done", "NOK")
#return 0
########## MAIN
#TEST_OFL="TRUE" # set TEST_OFL in order to test things offline (no fetch of info over internet)
TEST_OFL="FALSE" # BECARFULL OFFLINE following FILES must be present:
# current-weather
# daily-weather-forecastday<xxx>
# moon_file
# 8hours
DEBUG_tr="TRUE"
#DEBUG_tr="FALSE"
#DEBUG_write_to_file="TRUE"
DEBUG_write_to_file="FALSE"
if __name__ == '__main__':
main()
==================
enfin voici mes conkyrc pour example
conky 1
# conky configuration
# set to yes if you want Conky to be forked in the background
# set to no fore test
background yes
# Use Xft?
use_xft yes
xftfont Vera:size=6 # police et taille a utiliser
xftalpha 0.8
# Print everything to console?
out_to_console no
# mail spool
#mail_spool $MAIL
# Update interval in seconds
update_interval 1.0
# 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_type conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Draw shades?
draw_shades no
# Draw outlines?
draw_outline no
# Draw borders around text
draw_borders no
draw_graph_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
# border width
border_width 0
# Default colors and also border colors
default_color F8A65C #Orange
default_shade_color black
default_outline_color black
# Minimum size of text area
minimum_size 690 85 # taille mini (px) ; largeur / hauteur
maximum_width 690 # largeur maxi
# Text alignment, other possible values are commented
#alignment top_right
alignment top_left
#alignment bottom_left
#alignment bottom_right
# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 530
gap_y 328
#gap_y 448
# 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 1
# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 1
# 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
# Colors
#color1 000000 #BLACK
color1 444444 #Gris fonce
color2 CCCCCC #Gris 1
color3 555555 #Gris 2
#color4 333333 #Gris 3
color4 444444 #Gris 3
color5 FFFFFF #WHITE
text_buffer_size 4096
max_specials 1024
#Rafraichissement images
imlib_cache_size 0
# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument
#
# stuff after 'TEXT' will be formatted on screen
# 180x108 150x90 120x72 80x48 60x36
# ${font Vera:size=10:style=bold}
# ${texeci 500 bash /home/antoine1/.conky/acc_int_images}
# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument
# -- Declaration template -- #
template0 ${lua display_meteo \1 } # -- meteo for current status --#
template1 ${lua display_meteo \1 \2 } # -- gestion météo --#
template2 ${lua_parse display_icon \1 \2 \3 \4} # -- icones météo -- \1=icones \2=position \3=taille \4=jour (pour les prévisions) #\
template3 ${font Vera:size=6}
template4 ${font Vera:size=8}
template5 ${font Vera:size=10}${color1}\1
template6 ${font Vera:size=10}${color1}${lua display_meteo \1 \2 }
template7 ${font Vera:size=8:style=bold}${color4}${lua display_meteo \1 \2 }
template8 ${font Vera:size=8}${color4}${lua display_meteo \1 \2 }
# script lua à charger ###############################
#lua_load /DIVERS/tmp/python/mymeteo.lua # éventuellement changer la référence à votre répertoire
#lua_startup_hook init_meteo /DIVERS/tmp/python/mymeteo.cfg
lua_load ~/conky/mymeteo.lua # éventuellement changer la référence à votre répertoire
lua_startup_hook init_meteo ~/conky/mymeteo.cfg
#
#
TEXT
${voffset 0}${lua conky_update}${font}${font Vera:size=11}${color1} ${goto 120}${template5 Aujourd'hui}${goto 245}${template6 day_name 2}${goto 330}${template6 day_name 3}${goto 420}${template6 day_name 4}${goto 510}${template6 day_name 5}${goto 610}${font Vera:size=11}${color1}Lune
${template2 cur_icon -15,10 150x90 0}${template2 daily_icon_d 100,10 80x48 1}${template2 daily_icon_n 160,10 80x48 1}${template2 daily_icon_d 225,10 80x48 2}${template2 daily_icon_n 265,10 80x48 2}${template2 daily_icon_d 310,10 80x48 3}${template2 daily_icon_n 350,10 80x48 3}${template2 daily_icon_d 400,10 80x48 4}${template2 daily_icon_n 440,10 80x48 4}${template2 daily_icon_d 490,10 80x48 5}${template2 daily_icon_n 530,10 80x48 5}${template2 moon_icon 610,17 60x60 }
${voffset 15}${goto 120}${font Vera:size=8}${color1}Max: ${template7 Temp_max_d 1}°C${goto 180}${font Vera:size=8}${color1}Min: ${template7 Temp_min_n 1}°C${goto 245}${template8 Temp_max_d 2}°C${goto 285}${template8 Temp_min_n 2}°C${goto 330}${template8 Temp_max_d 3}°C${goto 370}${template8 Temp_min_n 3}°C${goto 420}${template8 Temp_max_d 4}°C${goto 460}${template8 Temp_min_n 4}°C${goto 510}${template8 Temp_max_d 5}°C${goto 550}${template8 Temp_min_n 5}°C${font}
${voffset 1} ${goto 120}${font Vera:size=8}${color1}${template1 sunrise_HH 1}:${template1 sunrise_MM 1}${goto 180}${font Vera:size=8}${color1}${template1 sunset_HH 1}:${template1 sunset_MM 1}${goto 245}${template1 sunrise_HH 2}:${template1 sunrise_MM 2}${goto 285}${template1 sunset_HH 2}:${template1 sunset_MM 2}${goto 330}${template1 sunrise_HH 3}:${template1 sunrise_MM 3}${goto 370}${template1 sunset_HH 3}:${template1 sunset_MM 3}${goto 420}${template1 sunrise_HH 4}:${template1 sunrise_MM 4}${goto 460}${template1 sunset_HH 4}:${template1 sunset_MM 4}${goto 510}${template1 sunrise_HH 5}:${template1 sunrise_MM 5}${goto 550}${template1 sunset_HH 5}:${template1 sunset_MM 5}${font}
${voffset 1} ${goto 5}${font Vera:size=10}${color1}${template0 cur_status } : ${font Vera:size=10}${template0 cur_temp }°C / FL : ${template0 cur_tempfeel}°C${font}
conky 2
# conky configuration
# set to yes if you want Conky to be forked in the background
# set to no fore test
background yes
# Use Xft?
use_xft yes
xftfont Vera:size=6 # police et taille a utiliser
xftalpha 0.8
# Print everything to console?
out_to_console no
# mail spool
#mail_spool $MAIL
# Update interval in seconds
update_interval 1.0
# 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_type conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Draw shades?
draw_shades no
# Draw outlines?
draw_outline no
# Draw borders around text
draw_borders no
draw_graph_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
# border width
border_width 0
# Default colors and also border colors
default_color F8A65C #Orange
default_shade_color black
default_outline_color black
# Minimum size of text area
minimum_size 400 50 # taille mini (px) ; largeur / hauteur
maximum_width 400 # largeur maxi
# Text alignment, other possible values are commented
#alignment top_right
alignment top_left
#alignment bottom_left
#alignment bottom_right
# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 530
gap_y 500
#gap_y 448
# 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 1
# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 1
# 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
# Colors
#color1 000000 #BLACK
color1 444444 #Gris fonce
color2 CCCCCC #Gris 1
color3 555555 #Gris 2
#color4 333333 #Gris 3
color4 444444 #Gris 3
color5 FFFFFF #WHITE
text_buffer_size 4096
max_specials 1024
#Rafraichissement images
imlib_cache_size 0
# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument
#
# stuff after 'TEXT' will be formatted on screen
# 180x108 150x90 120x72 80x48 60x36
# ${font Vera:size=10:style=bold}
# ${texeci 500 bash /home/antoine1/.conky/acc_int_images}
# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument
# -- Declaration template -- #
template0 ${lua display_meteo \1 } # -- meteo for current status --#
template1 ${lua display_meteo \1 \2 } # -- gestion météo --#
template2 ${lua_parse display_icon \1 \2 \3 0} # -- icones météo -- \1=icones \2=position \3=taille \4=jour (pour les prévisions) #\
template3 ${font Vera:size=6}
template4 ${font Vera:size=8}
template5 ${font Vera:size=10}${color1}
template6 ${font Vera:size=10}${color1}${lua display_meteo \1 }
template7 ${font Vera:size=8:style=bold}${color4}${lua display_meteo \1 \2 }
template8 ${font Vera:size=8}${color4}${lua display_meteo \1 \2 }
# script lua à charger ###############################
#lua_load /DIVERS/tmp/python/mymeteo.lua # éventuellement changer la référence à votre répertoire
#lua_startup_hook init_meteo /DIVERS/tmp/python/mymeteo.cfg
lua_load ~/conky/mymeteo.lua # éventuellement changer la référence à votre répertoire
lua_startup_hook init_meteo ~/conky/mymeteo.cfg
#
#
TEXT
${lua conky_update_table }${voffset 0}${template5}Prévision et évolution pour les 8 prochaines heures:
${template2 Icon_8_1 0,10 50x30 }${template2 Icon_8_2 50,10 50x30 }${template2 Icon_8_3 100,10 50x30 }${template2 Icon_8_4 150,10 50x30 }${template2 Icon_8_5 200,10 50x30 }${template2 Icon_8_6 250,10 50x30 }${template2 Icon_8_7 300,10 50x30 }${template2 Icon_8_8 350,10 50x30 }
${voffset 5}${goto 5}${template6 HH_1 }:00${goto 55}${template6 HH_2}:00${goto 105}${template6 HH_3}:00${goto 155}${template6 HH_4}:00${goto 205}${template6 HH_5}:00${goto 255}${template6 HH_6}:00${goto 305}${template6 HH_7}:00${goto 355}${template6 HH_8}:00
conky 3
# conky configuration
# set to yes if you want Conky to be forked in the background
# set to no fore test
background yes
# Use Xft?
use_xft yes
xftfont Comic Sans MS:size=8 # police et taille a utiliser
xftalpha 0.8
#xftfont HandelGotDLig:size=9 # police et taille a utiliser
# Print everything to console?
out_to_console no
# Update interval in seconds
update_interval 4.0
# 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_type conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Draw shades?
draw_shades no
# Draw outlines?
draw_outline no
# Draw borders around text
draw_borders no
draw_graph_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
# border width
border_width 1
# Default colors and also border colors
# apprently not used
default_color F8A65C #Orange
default_shade_color black
default_outline_color black
# Minimum size of text area
minimum_size 145 85 # taille mini (px) ; largeur / hauteur
maximum_width 155 120 # largeur maxi
# Text alignment, other possible values are commented
alignment top_right
#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 250
gap_y 435
# 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 1
# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 1
# 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
# Colors
#color1 CCCCCC #Gris
#color2 FFFFFF #White
#color3 BBBBBB #White
#color4 000000 #Black
color1 444444 #Black
color2 FFFFFF #White
color3 444444 #Black
color4 000000 #Black
text_buffer_size 4096
max_specials 1024
# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument
# -- Declaration template -- #
template0 ${lua display_meteo \1 } # -- meteo for current status --#
template1 ${lua display_meteo \1 \2 } # -- gestion météo --#
template2 ${lua_parse display_icon \1 \2 \3 \4} # -- icones météo -- \1=icones \2=position \3=taille \4=jour (pour les prévisions) #\
template3 ${lua Lune_\1} # -- recup info par sed -- #
template4 ${goto 12}${font}${color}\1${goto 87}:
template5 ${goto 0}${color3}\1
template6 ${color1}${alignr}${lua display_meteo \1 0}
template7 ${color1}${alignr}${lua display_meteo \1 \2 }
# script lua à charger ###############################
#lua_load /DIVERS/tmp/python/mymeteo.lua # éventuellement changer la référence à votre répertoire
#lua_startup_hook init_meteo /DIVERS/tmp/python/mymeteo.cfg
lua_load ~/conky/mymeteo.lua # éventuellement changer la référence à votre répertoire
lua_startup_hook init_meteo ~/conky/mymeteo.cfg
###
###
###
# stuff after 'TEXT' will be formatted on screen
TEXT
${lua conky_update_table }${voffset 0} ${template5 Température : }${template6 cur_temp }° / FL ${template6 cur_tempfeel }°
${voffset -4}${template5 Vent : }${template6 cur_wind_dir } ${template6 cur_wind_speed} km/h
${voffset -3}${template5 Humidité : }${template6 cur_Humidity} %
${voffset -3}${template5 Point} de rosée : ${template6 cur_dew_point}°C
${voffset -3}${template5 Pression : }${template6 cur_Pressure} kPa
${voffset -3}${template5 Visibilité : }${template6 cur_visibility} Km
${voffset -3}${template5 Nuage} : ${template6 cur_ceiling} m / ${template6 cur_cloud_cover}%
${voffset -3}${template5 Indice} UV : ${template6 cur_UV_max}.
${voffset -3}${template5 Levé} du soleil : ${template7 sunrise_HH 1}:${template7 sunrise_MM 1}
${voffset -3}${template5 Couché} du soleil : ${template7 sunset_HH 1 }:${template7 sunset_MM 1}
${voffset 1}${alignc}${template1 daily_condition_d 1} puis
${voffset -3}${alignc}${template1 daily_condition_n 1}
${voffset 0}${font Vera:size=6}${alignr}last update : ${template0 cur_hour}:${template0 cur_min}
Encore une fois ces scripts ne rentrent pas en concurrence avec ceux de Didier-T, ce fut un bon exemple pour moi pour apprendre. je les poste uniquement pour ceux qui aurait aussi le désire de se mette a "Pythoner" (ou si il y en a qui sont sur debian)
MimileVadrouille
PS1 Mille excuse pour ceux qui parlent mal l'anglais, ce fut plus facile pour moi de l'écrire en anglais.
PS2: j'ai aussi téléchargé toutes (les 200) les icônes pour la lune j'ai donc aussi un répertoire lune dans celui dédié aux icônes. je peux les mettre qq part si cela vous intéresse (et donc il n y a plus besoin de imagemagik)