#0 Re : -1 » [Conky] Alternative à weather.com (3) » Le 02/04/2013, à 16:57
- MimileVadrouille
- Réponses : 629
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)
endCe 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=yespour 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}:00conky 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)
#1 Re : -1 » [Conky] Alternative à weather.com (3) » Le 02/04/2013, à 17:01
- MimileVadrouille
- Réponses : 629
et juste pour le fond voila après téléchargement des données mon fichier xml avec le jour voulu, le nom a appeler dans le conkyrc et donc la valeur qui va être retournée
data_file
<day_0>
<index>1<name>cur_day<value>02<\index><\name><\value>
<index>2<name>cur_month<value>04<\index><\name><\value>
<index>3<name>cur_year<value>2013<\index><\name><\value>
<index>4<name>cur_hour<value>10<\index><\name><\value>
<index>5<name>cur_min<value>10<\index><\name><\value>
<index>6<name>cur_icon<value>7<\index><\name><\value>
<index>7<name>cur_temp<value>-3<\index><\name><\value>
<index>8<name>cur_tempfeel<value>-6<\index><\name><\value>
<index>9<name>cur_status<value>Nuageux<\index><\name><\value>
<index>10<name>cur_wind_dir<value>O<\index><\name><\value>
<index>11<name>cur_wind_speed<value>15<\index><\name><\value>
<index>12<name>cur_Humidity<value>68<\index><\name><\value>
<index>13<name>cur_Pressure<value>1017.80<\index><\name><\value>
<index>14<name>cur_UV_max<value>1<\index><\name><\value>
<index>15<name>cur_cloud_cover<value>95<\index><\name><\value>
<index>16<name>cur_ceiling<value>841<\index><\name><\value>
<index>17<name>cur_dew_point<value>-8<\index><\name><\value>
<index>18<name>cur_visibility<value>24<\index><\name><\value>
<index>19<name>Icon_8_1<value>6<\index><\name><\value>
<index>20<name>Icon_8_2<value>6<\index><\name><\value>
<index>21<name>Icon_8_3<value>6<\index><\name><\value>
<index>22<name>Icon_8_4<value>6<\index><\name><\value>
<index>23<name>Icon_8_5<value>6<\index><\name><\value>
<index>24<name>Icon_8_6<value>4<\index><\name><\value>
<index>25<name>Icon_8_7<value>6<\index><\name><\value>
<index>26<name>Icon_8_8<value>4<\index><\name><\value>
<index>27<name>HH_1<value>10<\index><\name><\value>
<index>28<name>HH_2<value>11<\index><\name><\value>
<index>29<name>HH_3<value>12<\index><\name><\value>
<index>30<name>HH_4<value>13<\index><\name><\value>
<index>31<name>HH_5<value>14<\index><\name><\value>
<index>32<name>HH_6<value>15<\index><\name><\value>
<index>33<name>HH_7<value>16<\index><\name><\value>
<index>34<name>HH_8<value>17<\index><\name><\value>
<index>35<name>moon_status<value>decroissante<\index><\name><\value>
<index>36<name>moon_visibility<value>56<\index><\name><\value>
<index>37<name>moon_phase<value>Ascendante, Décroissante<\index><\name><\value>
<\day_0>
<day_1>
<index>1<name>daily_icon_d<value>6<\index><\name><\value>
<index>2<name>daily_icon_n<value>38<\index><\name><\value>
<index>3<name>Temp_max_d<value>1<\index><\name><\value>
<index>4<name>Temp_RealF_d<value>-5<\index><\name><\value>
<index>5<name>Temp_min_n<value>-6<\index><\name><\value>
<index>6<name>Temp_RealF_n<value>-14<\index><\name><\value>
<index>7<name>daily_condition_d<value>Nuages épars; froid<\index><\name><\value>
<index>8<name>daily_condition_n<value>Plutôt nuageux et froid<\index><\name><\value>
<index>9<name>sunrise_HH<value>06<\index><\name><\value>
<index>10<name>sunrise_MM<value>59<\index><\name><\value>
<index>11<name>sunset_HH<value>19<\index><\name><\value>
<index>12<name>sunset_MM<value>46<\index><\name><\value>
<index>13<name>year_date<value>02<\index><\name><\value>
<index>14<name>month_date<value>04<\index><\name><\value>
<index>15<name>day_date<value>2013<\index><\name><\value>
<index>16<name>day_name<value>Mardi<\index><\name><\value>
<\day_1>
<day_2>
<index>1<name>daily_icon_d<value>4<\index><\name><\value>
<index>2<name>daily_icon_n<value>35<\index><\name><\value>
<index>3<name>Temp_max_d<value>1<\index><\name><\value>
<index>4<name>Temp_RealF_d<value>-5<\index><\name><\value>
<index>5<name>Temp_min_n<value>-3<\index><\name><\value>
<index>6<name>Temp_RealF_n<value>-8<\index><\name><\value>
<index>7<name>daily_condition_d<value>Nuages et soleil; froid<\index><\name><\value>
<index>8<name>daily_condition_n<value>En partie nuageux<\index><\name><\value>
<index>9<name>sunrise_HH<value>06<\index><\name><\value>
<index>10<name>sunrise_MM<value>57<\index><\name><\value>
<index>11<name>sunset_HH<value>19<\index><\name><\value>
<index>12<name>sunset_MM<value>47<\index><\name><\value>
<index>13<name>year_date<value>03<\index><\name><\value>
<index>14<name>month_date<value>04<\index><\name><\value>
<index>15<name>day_date<value>2013<\index><\name><\value>
<index>16<name>day_name<value>Mercredi<\index><\name><\value>
<\day_2>
<day_3>
<index>1<name>daily_icon_d<value>3<\index><\name><\value>
<index>2<name>daily_icon_n<value>35<\index><\name><\value>
<index>3<name>Temp_max_d<value>11<\index><\name><\value>
<index>4<name>Temp_RealF_d<value>8<\index><\name><\value>
<index>5<name>Temp_min_n<value>0<\index><\name><\value>
<index>6<name>Temp_RealF_n<value>-4<\index><\name><\value>
<index>7<name>daily_condition_d<value>Nuageux et ensoleillé, venteux et devenant plus chaud<\index><\name><\value>
<index>8<name>daily_condition_n<value>En partie couvert<\index><\name><\value>
<index>9<name>sunrise_HH<value>06<\index><\name><\value>
<index>10<name>sunrise_MM<value>55<\index><\name><\value>
<index>11<name>sunset_HH<value>19<\index><\name><\value>
<index>12<name>sunset_MM<value>49<\index><\name><\value>
<index>13<name>year_date<value>04<\index><\name><\value>
<index>14<name>month_date<value>04<\index><\name><\value>
<index>15<name>day_date<value>2013<\index><\name><\value>
<index>16<name>day_name<value>Jeudi<\index><\name><\value>
<\day_3>
<day_4>
<index>1<name>daily_icon_d<value>1<\index><\name><\value>
<index>2<name>daily_icon_n<value>33<\index><\name><\value>
<index>3<name>Temp_max_d<value>8<\index><\name><\value>
<index>4<name>Temp_RealF_d<value>8<\index><\name><\value>
<index>5<name>Temp_min_n<value>-2<\index><\name><\value>
<index>6<name>Temp_RealF_n<value>-8<\index><\name><\value>
<index>7<name>daily_condition_d<value>Soleil<\index><\name><\value>
<index>8<name>daily_condition_n<value>Clair<\index><\name><\value>
<index>9<name>sunrise_HH<value>06<\index><\name><\value>
<index>10<name>sunrise_MM<value>53<\index><\name><\value>
<index>11<name>sunset_HH<value>19<\index><\name><\value>
<index>12<name>sunset_MM<value>50<\index><\name><\value>
<index>13<name>year_date<value>05<\index><\name><\value>
<index>14<name>month_date<value>04<\index><\name><\value>
<index>15<name>day_date<value>2013<\index><\name><\value>
<index>16<name>day_name<value>Vendredi<\index><\name><\value>
<\day_4>
<day_5>
<index>1<name>daily_icon_d<value>6<\index><\name><\value>
<index>2<name>daily_icon_n<value>18<\index><\name><\value>
<index>3<name>Temp_max_d<value>7<\index><\name><\value>
<index>4<name>Temp_RealF_d<value>7<\index><\name><\value>
<index>5<name>Temp_min_n<value>2<\index><\name><\value>
<index>6<name>Temp_RealF_n<value>-1<\index><\name><\value>
<index>7<name>daily_condition_d<value>Plutôt nuageux, possibilité d'averses; frais<\index><\name><\value>
<index>8<name>daily_condition_n<value>Pluie<\index><\name><\value>
<index>9<name>sunrise_HH<value>06<\index><\name><\value>
<index>10<name>sunrise_MM<value>52<\index><\name><\value>
<index>11<name>sunset_HH<value>19<\index><\name><\value>
<index>12<name>sunset_MM<value>51<\index><\name><\value>
<index>13<name>year_date<value>06<\index><\name><\value>
<index>14<name>month_date<value>04<\index><\name><\value>
<index>15<name>day_date<value>2013<\index><\name><\value>
<index>16<name>day_name<value>Samedi<\index><\name><\value>
<\day_5>#2 Re : -1 » [Conky] Alternative à weather.com (3) » Le 02/04/2013, à 19:25
- MimileVadrouille
- Réponses : 629
Bonjour MimileVadrouille,
très bien tes scripts, je les regarderai plus en détails plus tard, mais sur une première lecture sa semble très intéressant.
merci beaucoup pour cela, mais tout l'honneur est aussi pour toi car je suis vraiment parti au départ de ton travail
Je suis tous de même surpris du choix que tu a fait d'utiliser pour extraire les données du site.
Je m'explique pour trouver les informations tu emploi leurs nom par exemple Pression qui deviendra Pressure dans une page anglaise.
Attention, j ai codé mes variables et autres en anglais mais mon conky je le veux en Français!!! donc il faut que je cherche dans les pages en FR ainsi que sur les mots clefs en Français. C est pourquoi il a y a des mots en Français qui ressortent
D'ailleurs le conky tel quel ne marche pas du tout en anglais. (l'anglais pour moi est juste un langue de travail)
par contre tu as été bien plus loin que moi dans le respect des règle de programmation en python, et sa c'est cool, sa vas me faire de bons exemples a suivre pour la suite.
Merci pour ce partage
P.S. : sa t’intéresserai de t'impliquer dans le projet, et de me donner un coups de main pour le script python ?
oui et non ! oui il n'y a pas de problème pour filer un coup de mains de temps en temps ! Par contre au niveau des disponibilités ca dépend du temps
Mais vas y si il a y a des petits trucs tu peux les balancer dans un message et que ce soit toi, moi ou un autre on peut s'aider.
#3 Re : -1 » [Conky] Alternative à weather.com (3) » Le 02/04/2013, à 20:15
- MimileVadrouille
- Réponses : 629
Bonjour MimileVadrouille,
très bien tes scripts, je les regarderai plus en détails plus tard, mais sur une première lecture sa semble très intéressant.
Si tu veux une petite explication sur une chose qui ne parait pas clair dans mon script, n'hésite pas à demander ![]()
#4 Re : -1 » Gimp: couleurs fades des RAW » Le 08/06/2013, à 21:29
- MimileVadrouille
- Réponses : 4
Hello,
je ne connais pas UFRAW, mais derawtise assez régulièrement mes photos.
Ton problème vient sûrement d'un profit de couleurs. Exporte tu en sRGB ou avec un autre profil ? Cherche de ce cote à mon avis.
#5 Re : -1 » Solution : Intègrer complètement google calendar sur gnome 3 » Le 08/06/2013, à 09:25
- MimileVadrouille
- Réponses : 1
Merci, c'est super utile et c'est exactement ce que je cherchais.
Note: avec un login automatique il est important que le trousseau de clefs "seahorse" ai le même mot de passe que celui de l'utilisateur de la session. Ainsi il pas besoin de rentrer un mot de passe lors de l'ouverture de la session.
#6 Re : -1 » Sortie de supertuxkart 0.8 (finale) » Le 09/02/2013, à 16:15
- MimileVadrouille
- Réponses : 50
Et bien je l'ai essayé, et suis conquis
:):)
Bravo c'est excellent
#7 Re : -1 » [Conky] Alternative à weather.com (2) » Le 28/01/2012, à 11:55
- MimileVadrouille
- Réponses : 2473
Salut,
merci encore pour ce super post !
y a t il un moyen d ajouter des traces de debug ? je suis en train de chercher pour quoi en plein jour ici le script essaye de trouver l icone su.png dans le dossier nuit :
Conky: Unable to load image '~/.conky/meteo+lune/icones/base/nuit/su.png'
cest pour le temps actuel:
${template2 IconeM ~/.conky/meteo+lune/icones/base -15,10 150x90}
donc j imagine pour l IconeM
#8 Re : -1 » [Conky] Alternative à weather.com (2) » Le 28/01/2012, à 12:06
- MimileVadrouille
- Réponses : 2473
et hop un autre petit truc:
il manque l icone co.png dans le repertoir nuit: je l ai copie et cela marche bien
#9 Re : -1 » [Conky] Alternative à weather.com (2) » Le 28/01/2012, à 14:32
- MimileVadrouille
- Réponses : 2473
MimileVadrouille a écrit :Salut,
merci encore pour ce super post !
y a t il un moyen d ajouter des traces de debug ? je suis en train de chercher pour quoi en plein jour ici le script essaye de trouver l icone su.png dans le dossier nuit :
Conky: Unable to load image '~/.conky/meteo+lune/icones/base/nuit/su.png'cest pour le temps actuel:
${template2 IconeM ~/.conky/meteo+lune/icones/base -15,10 150x90}donc j imagine pour l IconeM
Recopie la version collée sur le post 1 le problème est réglé, j’avais oublié d'en parler.
Super merci ca marche
sinon comme j ai 2 conky qui tourne a des endroits differents de mon bureau je suis en train de regarder si en calquant la fonction
function conky_Meteo_Maj(cmd, jours, delais, r, repsauv)
on ne peut pas faire une une fonction uniquement de lecture
function conky_Meteo_Read (cmd, jours, delais, r, repsauv)
#10 Re : -1 » [Conky] Alternative à weather.com (2) » Le 28/09/2012, à 11:37
- MimileVadrouille
- Réponses : 2473
Hello,
merci pour les évolutions de ce script !!!! Je viens de faire un grand bond car j'avais une très vieille version.
Voici qq remarques:
1) Il y a une boulette dans le coucher du soleil qui récupère le coucher de la lune
pour ici :
pour le soleil la page HTML donne
<span class="ac">of sunlight, then sets at</span>
<span class="finish">19:35</span>et il y a aussi une string "finish" pour la lune:
<span class="ac">of moolight, then sets at</span>
<span class="finish">07:05</span>
et dans le code il y a :
Sunrise[%a%p%s]*start\">((%d*):(%d*))</span>[%w%p%s]*finish\">((%d*):(%d*))</span>il faudrait grepper aussi la string "of sunlight, then sets at" sinon il va chercher le coucher de lune:
2) sinon pour mon info , (car j ai essayé en vain d'apporter ma correction ) qu'est ce que cela veulent dire ces petites choses :
[%a%p%s] ?
[%w%p%s] ?
et j imagine que (%d*) retourne la variable qui est définie un peut avant - ie pour le pb ci dessous elle retourne LeverSoleil,LeverSoleilH,LeverSoleilM,CoucherSoleil,CoucherSoleilH,CoucherSoleilM
LeverSoleil,LeverSoleilH,LeverSoleilM,CoucherSoleil,CoucherSoleilH,CoucherSoleilM=string.match(prevision, "Sunrise[%a%p%s]*start\">((%d*):(%d*))</span>[%w%p%s]*finish\">((%d*):(%d*))</span>")
3) est-il facile d'insérer une nouvelle variable d'environnement "debug" qui peut être mise a YES ou NO, et qui permettrai de dumper les valeurs retournées directement par le script lua, au lieu de passer par le conky? Ou alors y a t-il un autre moyen de debugger plus facilement ce que le script lorsqu'il y a des soucis comme ca ?
Je pensais pour le debug a un truc du style:
if DEBUG = YES then print variable
Voila et encore merci pour le script
#11 Re : -1 » [Conky] Alternative à weather.com (2) » Le 28/09/2012, à 19:08
- MimileVadrouille
- Réponses : 2473
@ MimileVadrouille,
pour ton information, ce sont des patterns :
%a texte (sauf accent)
%d nombre
%w texte+nombre
%p ponctuation
%c caractère de contrôle (je sais pas trop a quoi sa correspond)
%s espace
* plusieurs occurrencevoila pour ce que j'ai saisi du fonctionnement des patterns, il y a plein de subtilité que je ne maitrise pas encore.
la suggestion en 3 est intéressante, mais sans système de débogage, je m'y retrouve très vite, je crois que je vais tous de même l'intégré à la prochaine correction, sa aidera à identifier les prochains soucis du script.
Merci pour tes remarques
Merci
voila j ai trouvé pour le coucher de soleil il faut remplacer la ligne 129 par:
--##Lever coucher soleil & lune
LeverSoleil,LeverSoleilH,LeverSoleilM,CoucherSoleil,CoucherSoleilH,CoucherSoleilM=string.match(prevision, "Sunrise[%a%p%s]*start\">((%d*):(%d*))</span>[%w%p%s]*finish\">((%d*):(%d*))</span>[%w%p%s]*moon")#12 Re : -1 » [Conky] Alternative à weather.com (2) » Le 07/12/2012, à 20:18
- MimileVadrouille
- Réponses : 2473
Hello,
cest parce que la date est mal récupérée.
Je viens de regarder un peu le script et vient de trouver un petit bug. Lorsque tu passes dans la boucle de debug (comme en ce moment pour Point de Rose et Date )
local y = {"Icone", "Cond", "Temp", "Tempr", "VentDir", "VentForce", "Humidite", "Pression", "CouvNuage", "Uv", "PointRosee", "QPrec", "Visibilite", "Ville", "latitude","Date", "longitude"}
local donee = conditioncourante
for i = 1,17 do
if donee[y[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditioncourante ", y[i])
donee[y[i]]="N/A"
end
enda ce moment tu alloues la sting "N:A" , ce qui est bien mais il ne faut plus renvoyer de nombre :
function conky_Meteo_Rose()
return tonumber conditioncourante.PointRosee
endmais
function conky_Meteo_Rose()
return conditioncourante.PointRosee
enddans ce cas cela évite l erreur même si la variable n est pas trouvée. .
#13 Re : -1 » [Conky] Alternative à weather.com (2) » Le 07/12/2012, à 21:14
- MimileVadrouille
- Réponses : 2473
pour ce qui est du bug que MimileVadrouille a trouvé, en fait il ne s'agit pas d'un bug, mais d'une volonté de ma part de générer des erreurs, qui ne soit pas fatal au bon fonctionnement du script, de manière a ce que quand il y a un soucis, ont vienne le dire sur le forum, et que si je ne m'en suis pas aperçus avant quelqu’un d'autre, je puisse régler le soucis au plus vite.
Pfou... elle était longue cette phrase...
AH OK, mais on retrouve aussi ce qu il ne va pas dans le fichier de debug - et on voit aussi N/A pour la donnee. c est pour cela que je pensais qu il y avait erreur.
tu pourrais peut etre plutot faire un print dans la boucle de DEBUG, au lieu de laisser le script le faire :
print ("DEBUG erreur sur " , y[i] , "Ceci n est pas fatal ;)") Attention cest juste une suggestion elle n est pas obligatoire du tout!!!
#14 Re : -1 » [Conky] Alternative à weather.com (2) » Le 08/12/2012, à 20:18
- MimileVadrouille
- Réponses : 2473
Après tous, je me suis bien mis a lua suite a un échange du même type, alors que je trouvai sa lourd et compliqué par apport au bash, comme quoi rien n'est figé.
Une question sur la programmation: lorsque je vois cela dans la fonction prevision
f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'"))
line=f:read()
i=0
for line in f:lines() do
i=i+1
--jour
if i==5 then
iconej=line:match("icon i%p(%a*)\">")
blablabla
elseif i==133 then
jour,mois,annee=line:match("- (%d*)/(%d*)/(%d*)</")
.....quelle "print" faudrait-il inserser dans ton script pour dumper la ligne 133 ?
en fait si il y un un truc qui ne va pas alors je voudrais voir la ligne entiere pour pouvoir debuger directement
j aurais pense un un truc du syle:
print ("ligne orignale:", i) mais cela ne me renvois rien..
Sinon merci beaucoup pour l update.
#15 Re : -1 » [Conky] Alternative à weather.com (2) » Le 08/12/2012, à 20:29
- MimileVadrouille
- Réponses : 2473
Phyllinux a écrit :Je confirme. La V4.9 récupère toutes les données correctement.
Merci beaucoup Didier-T pour cet excellent travail, rapide et soigné !En fait, après mise à jour de mes différents conkys, je viens de m'apercevoir qu'il y a une donnée oubliée.
C'est celle de la quantité de précipitation pour les conditions courantes, qui correspond à la quantité de pluie ou de neige dans l'heure.
Dans ton script, elle n'est pas récupérée, bien que tu y fasses référence. Lignes 467 à 508 :--Infos condition courante function current(web) local f, i, line, ville, lat, lon, icone, cur, temp, tempres, directvent, vitessevent, Humidite, Pression, Couvnuageuse, UV, Pointderosee, Precipitations, Visibilite, jour, mois, annee, Date, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed -e 's/%//g' -e '/var apgWxInfoObj/,/\"detail-now\"/d' | grep -A190 'meta'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==2 then ville,lat,lon=line:match("city: '([%w%s%-]*)'[%s%w%p]*lat: '([%d%p]*)'[%s%w%p]*lon: '([%d%p]*)'") elseif i==5 then icone=line:match("icon i%p(%a*)\">") elseif i==6 then cur, temp, tempres=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</[%a%p%s]*temp\">([%p%d]*)<s[%w%p%s]*; ([%p%d]*)<s") elseif i==22 then directvent=line:gsub("W","O"):match("'(%a*)'") elseif i==23 then vitessevent=line:match("'(%d*)[%a%p]*'") elseif i==34 then Humidite=line:match("g>(%d*)</s") elseif i==35 then Pression=line:match("g>(%d*).") elseif i==36 then UV=line:match("g>(%d*)</s") elseif i==37 then Couvnuageuse=line:match("g>(%d*)</s") elseif i==39 then Pointderosee=line:match("g>([%p%d]*)°") elseif i==40 then Visibilite=line:match("g>(%d*) ") elseif i==181 then jour, mois, annee=line:match(">[%a%d%p%s]* (%d*)/(%d*)/(%d*)<") end end f:close() Date = os.time{year=annee, month=mois, day=jour, hour=0} return {Icone=icone, Cond=cur, Temp=temp, Tempr=tempres, VentDir=directvent, VentForce=vitessevent, Humidite=Humidite, Pression=Pression, CouvNuage=Couvnuageuse, Uv=UV, PointRosee=Pointderosee, Visibilite=Visibilite, Date=Date, Ville=ville, latitude=lat, longitude=lon} endLa déclaration de la valeur n'existe pas, et elle n'est pas non plus dans la ligne du 'return'.
Est ce parce qu'elle n'existe pas sur le site ou bien un oubli de ta part ?
Je pense qu elle se trouve dans la fonction prevision et non pas current.
d'ailleurs lorsque l on regarde pour le current:
http://www.accuweather.com/fr/fr/argent … her/133593
on ne vois pas les precipitation.
Ceci dit je ne suis pas sur ![]()
#16 Re : -1 » [Conky] Alternative à weather.com (2) » Le 09/12/2012, à 22:26
- MimileVadrouille
- Réponses : 2473
@ MimileVadrouille,
Tu ma fais peur avec ton dumper, dans mon travail, il s'agit d'engin de chantier utilisé dans les carrières a agrégats.
En fait, je ne suis pas certain de bien comprendre ce que tu souhaite faire.
Si il s'agit de récupérer la ligne du site qui est traité quand i=133, uniquement si il y a eut un soucis, sa risque d'être lourd, mais sa peut se faire.
tu ouvre un tableau pour le débogage, dans ce tableau tu insère le nom des valeur rechercher en nom, et les lignes de le page en valeur.
le soucis c'est qu'il faut le faire pour chaque valeur.local debug_prevision={} f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'")) line=f:read() i=0 for line in f:lines() do i=i+1 --jour if i==5 then iconej=line:match("icon i%p(%a*)\">") debug_prevision.iconej=line blablabla elseif i==133 then jour,mois,annee=line:match("- (%d*)/(%d*)/(%d*)</") debug_prevision.date=line .....voila en gros l'idée, mais tu vas augmenter de 1/3 la taille du script (si ce n'est plus).
Perso je préfère récupérer le nom de l'info qui manque, ouvrir un lua en terminal, et faire ceciweb="www.accuweather.com/fr/fr/argenteuil/133593/daily-weather-forecast/133593?day=1" f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'")) line=f:read() i=0 for line in f:lines() do i=i+1 print(i, line) endaprès je copie le résultat dans mon éditeur de texte préféré (gedit, pour ne pas le citer), j'y applique la coloration html et je regarde les ligne qui m'intéresses.
par exemple le soucis pour les huit heures était un décalage de deux lignes, au lieu de tous réécrire, je me suis contenté de définir l'origine de i a -2
merci beaucoup je comprends ce que tu fais maintenant et ton choix faire ligne par ligne et non pas de chercher une string dans le bloc de texte complet.
Pour le debug: rassure toi, en fait j avais essaye de comprendre ce qu il n'allait pas avant que tu mettes en ligne ta nouvelle version. Au lieu de faire comme tu me l as indique, javais mis des "print" un peu partout dans le script et essayais de dumper le contenu des variables, bref une autre methode completement differente de la tienne.
#17 -1 » [Resolu] Gnome 3 et fenetres "collantes" » Le 01/02/2013, à 22:32
- MimileVadrouille
- Réponses : 2
Hello,
je me mets tant bien que mal a gnome 3. Il a y a un truc assez énervant et je n'arrive pas a trouver la solution: J'ouvre
- synaptic et ensuite la petite fenêtre "recherche
=> la petite fenêtre recherche s ouvre mais je ne peux pas la déplacer ... ni voir ce qu'il a en dessous
c est la même chose avec plein d'applications:
un autre exemple en ouvrant
- le gestionnaire de d'archive et ensuite "ouvrir"
la fenêtre est collée on ne peux pas voir ce qu'il y a en dessous. Sur Gome 2 on pouvait la déplacer.
un bon screenshot vaut mieux qu'un long discours: la fenêtre "ouvrir" est ouverte mais si je la déplace il a tout le paquet di gestionnaire de d'archive qui se déplace.
Alors sous gnome 3 comment décoller ces fenêtres ?
#18 Re : -1 » [Resolu] Gnome 3 et fenetres "collantes" » Le 02/02/2013, à 10:53
- MimileVadrouille
- Réponses : 2
Salut
Tu installes dconf-editor (dans le paquet dconf-tools) ensuite tu le lances et tu vas dans org > gnome > shell > overrides et là tu décoches attach-modal-dialogs.
Bravo , c'est exactement ca !! merci beaucoup c'est tellement plus pratique maintenant .
#19 Re : -1 » [Conky] Alternative à weather.com ( icones conkyforecast ) » Le 10/11/2011, à 12:30
- MimileVadrouille
- Réponses : 658
un petit truc pas mal
si il n y a pas Internet le résultat de wget sera un fichier vide. Donc on peut garder les anciennes données tant que la connection n'est pas revenue.
il faut juste rajouter apres la ligne du dernier wget:
if [ -s ${DirShell}/curr_cond_raw ]
then
cp -p ${DirShell}/curr_cond_raw ${DirShell}/curr_cond_raw.cache
else
cp -p ${DirShell}/curr_cond_raw.cache ${DirShell}/curr_cond_raw
fi
if [ -s ${DirShell}/week_raw ]
then
cp -p ${DirShell}/week_raw ${DirShell}/week_raw.cache
else
cp -p ${DirShell}/week_raw.cache ${DirShell}/week_raw
fi#20 Re : -1 » [Conky] Alternative à weather.com ( icones conkyforecast ) » Le 17/11/2011, à 15:51
- MimileVadrouille
- Réponses : 658
hello,
toujours s'il y a des pb de connexion j aime bien récupérer l'heure de la dernière updat (CurrentTime)
il faut modifier les scripts de la manière suivante:
meteo:
ligne 100:
dvent=$(sed -n "6p" ${DirShell}/curr_cond)ligne 104:
fvent=$(sed -n "7p" ${DirShell}/curr_cond)ligne 238:
egrep -i 'CurrentTemp|CurrentText|CurrentTime|RealFeelValue|WindsValue|HumidityValue|DewPointValue|PressureValue|PressureTenValue|VisibilityValue|SunriseValue|SunsetValue|imgCurConCondition' ${DirShell}/curr_cond_raw > ${DirShell}/curr_condligne 246 et 147:
sed -i '6s/ /\n/' ${DirShell}/curr_cond
sed -i '7s/ .*$//' ${DirShell}/curr_condainsi que pour afmeteo (ATTENTION j ai supprimé les unités)
[Tt]emp) affichage=$(sed -n "2p" ${DirShell}/curr_cond) ;;
[Hh]eure) affichage=$(sed -n "3p" ${DirShell}/curr_cond) ;;
[Mm]eteo) affichage=$(sed -n "4p" ${DirShell}/curr_cond) ;;
[Tt]emp_res) affichage=$(sed -n "5p" ${DirShell}/curr_cond);;
[Dd]irection_[Vv]ent) affichage=$(sed -n "6p" ${DirShell}/curr_cond) ;;
[Vv]itesse_[Vv]ent) affichage=$(sed -n "7p" ${DirShell}/curr_cond) ;;
[Tt]aux_[Hh]umidite) affichage=$(sed -n "8p" ${DirShell}/curr_cond) ;;
[Pp]_[Rr]osee) affichage=$(sed -n "9p" ${DirShell}/curr_cond) ;;
[Pp]ression) affichage=$(sed -n "10p" ${DirShell}/curr_cond) ;;
[Tt]end_[Pp]ression) affichage=$(sed -n "11p" ${DirShell}/curr_cond) ;;
[Vv]isibilite) affichage=$(sed -n "12p" ${DirShell}/curr_cond) ;;
[Ll]ever_[Ss]oleil) affichage=$(sed -n "13p" ${DirShell}/curr_cond) ;;
[Cc]oucher_[Ss]oleil) affichage=$(sed -n "14p" ${DirShell}/curr_cond) ;;et pour que ce soit peut être plus facile voila les 2 fichiers en entier:
#!/bin/bash
#Repertoir de travail
DirShell="$HOME/conky/"
#Copier votre adresse Accuweather ici
address="http://www.accuweather.com/fr/hu/budapest/budapest/quick-look.aspx"
#Prévision sur n jour (de 1 à 15)
periode=5
#function: test_image
test_image () {
case $1 in
1) echo 1su ;;
2) echo 2msu ;;
3) echo 3psu ;;
4) echo 4ic ;;
5) echo 5h ;;
6) echo 6mc ;;
7) echo 7c ;;
8) echo 8d ;;
11) echo 9f ;;
12) echo 10s ;;
13) echo 11mcs ;;
14) echo 12psus ;;
15) echo 13t ;;
16) echo 14mct ;;
17) echo 15psut ;;
18) echo 16r ;;
19) echo 17fl ;;
20) echo 18mcfl ;;
21) echo 19psfl ;;
22) echo 20sn ;;
23) echo 21mcsn ;;
24) echo 22i ;;
25) echo 23sl ;;
26) echo 24fr ;;
29) echo 25rsn ;;
30) echo 27ho ;;
31) echo 28co ;;
32) echo 26w ;;
33) echo 29cl ;;
34) echo 31mcl ;;
35) echo 32pc ;;
36) echo 33ic ;;
37) echo 34h ;;
38) echo 35mc ;;
39) echo 36pcs ;;
40) echo 37mcs ;;
41) echo 38pct ;;
42) echo 39mct ;;
43) echo 40mcfl ;;
44) echo 41mcsn ;;
esac
}
meteo_a_n_jours() {
for (( x=1; x<=$1; x+=1 ))
do
wget --load-cookies ${DirShell}/cookie -O ${DirShell}/details$(($x-1)) ${addr_week}"details${x}.aspx"
done
#Formatage détails journaliers
for (( x=0; x<=$(($1-1)); x+=1 ))
do
egrep -i 'lblDetails|imgDayIcon|lblDayText|lblHigh|lblHighValue|lblRealFeel|lblRealFeelValue|lblWinds|lblWindsValue|lblTStormProb|lblTStormProbValue|lblPrecip|lblPrecipValue|lblRain|lblRainValue|lblSnow|lblSnowValue|lblHoursPrecip|lblHoursPrecipValue|lblHoursOfRain|lblHoursOfRainValue|lblHoursOfRainValue|imgNightIcon|lblNightText|lblLow|lblLowValue|lblRealFeelN|lblRealFeelNValue|lblWindsN|lblWindsNValue|lblTStormProbN|lblTStormProbNValue|lblPrecipN|lblPrecipNValue|lblRainN|lblRainNValue|lblSnowN|lblSnowNValue|lblHoursPrecipN|lblHoursPrecipNValue|lblHoursOfRainN|lblHoursOfRainNValue|lblSunrise|lblSunset|lblMoonrise|lblMoonset|lblDaylight|lblDarkness' ${DirShell}/details$x > ${DirShell}/jour$x
egrep -i 'lblMaxUV|lblMaxUVValue' ${DirShell}/details$x >> ${DirShell}/jour$x
sed -i 's/\(^.*blue\/\|^.*pour \|_int.jpg.*$\|^.*">\|<\/.*$\|°C\)//g' ${DirShell}/jour$x
sed -i -e 's/: /\n/g' -e 's/W/O/g' -e '1s/ .*$//' ${DirShell}/jour$x
sed -i -e '1s/^./\u&/' -e '1s/./\n/4' ${DirShell}/jour$x
sed -i '2d' ${DirShell}/jour$x
for (( i=2; i<=22; i+=20 ))
do
image_raw=$(sed -n "${i}"p ${DirShell}/jour$x)
sed -i ${i}s/$image_raw/$(test_image $image_raw)/ ${DirShell}/jour$x
done
cp ${DirShell}/icones/base/$(sed -n 2p ${DirShell}/jour$x).png ${DirShell}/icones/J${x}jour.png
cp ${DirShell}/icones/base/$(sed -n 22p ${DirShell}/jour$x).png ${DirShell}/icones/J${x}soir.png
for (( i=29; i>=9; i-=20 ))
do
sed -i $i's/ /\n/' ${DirShell}/jour$x
done
def_vent $x
sed -n 3p ${DirShell}/jour$x >> ${DirShell}/messages
sed -n 24p ${DirShell}/jour$x >> ${DirShell}/messages
done
rm ${DirShell}/details*
}
def_vent() {
case $1 in
curr)
dvent=$(sed -n "6p" ${DirShell}/curr_cond)
if [ $dvent == "Calme" ]; then
sed -i "6i\0" ${DirShell}/curr_cond
fi
fvent=$(sed -n "7p" ${DirShell}/curr_cond)
v=$(direction_vent $dvent)
cp $(icone_vent $v $fvent) ${DirShell}/icones/vcc.png
;;
*)
for (( i1=0; i1<=1; i1+=1 ))
do
n=$(($(($i1*21))+9))
dvent=$(sed -n "$(($n))p" ${DirShell}/jour$1)
if [ $dvent == "Calme" ]; then
sed -i "$(($n+1))i\0" ${DirShell}/jour$1
fi
fvent=$(sed -n "$(($n+1))p" ${DirShell}/jour$1)
v=$(direction_vent $dvent)
if (( $i1==0 )); then
moment="jour"
else
moment="soir"
fi
cp $(icone_vent $v $fvent) ${DirShell}/icones/v$1$moment.png
done
;;
esac
}
direction_vent() {
case $1 in
Calme) echo 0 ;;
N) echo 10 ;;
NNE) echo 11 ;;
NE) echo 12 ;;
ENE) echo 13 ;;
E) echo 14 ;;
ESE) echo 15 ;;
SE) echo 16 ;;
SSE) echo 17 ;;
S) echo 2 ;;
SSO) echo 3 ;;
SO) echo 4 ;;
OSO) echo 5 ;;
O) echo 6 ;;
ONO) echo 7 ;;
NO) echo 8 ;;
NNO) echo 9 ;;
*) echo 1 ;;
esac
}
icone_vent() {
if (( $2 <= 25 )); then
n=$1
elif (( $2 <= 50 )); then
n=$(($1+17))
elif (( $2 <= 75 )); then
n=$(($1+34))
elif (( $2 >= 76 )); then
n=$(($1+51))
fi
if (( $n <= 9 )); then
n="0$n"
fi
echo "${DirShell}/icones/base/vent/$n.png"
}
decoupage() {
for (( i=1; i<=$(($1*4)); i++))
do
no=$(sed -n ${i}p ${DirShell}/messages|wc -m)
if (( no<=21 )); then
sed -i $i"s/$/\n/" ${DirShell}/messages
elif (( no>21 )); then
nbesp=$(awk '{ x=0; x+=gsub("\\ ",""); print x }' ${DirShell}/messages | sed -n "$(($i))p")
pos=$(($(($nbesp/2))+1))
if (( $(sed $i"s/ /\n/$pos" ${DirShell}/messages | sed -n $i"p" | wc -m)<=21 )); then
sed -i $i"s/ /\n/$pos" ${DirShell}/messages
else
pos=$(($nbesp/2))
sed -i $i"s/ /\n/$pos" ${DirShell}/messages
fi
fi
nesp=""
no=$(sed -n ${i}p ${DirShell}/messages|wc -m)
for (( esp=1; esp<=$(($((21-$no))/2)); esp+=1 ))
do
nesp=$nesp" "
done
sed -i $i"s/^/$nesp/" ${DirShell}/messages
i=$((i+1))
nesp=""
no=$(sed -n ${i}p ${DirShell}/messages|wc -m)
for (( esp=1; esp<=$(($((21-$no))/2)); esp+=1 ))
do
nesp=$nesp" "
done
sed -i $i"s/^/$nesp/" ${DirShell}/messages
done
}
#Fin des fonctions début du script
ping -c 2 www.accuweather.com>>/dev/null
if [ $? -eq 0 ]
then
rm ${DirShell}/icones/*.png
rm ${DirShell}/jour*
rm ${DirShell}/messages
wget --save-cookies ${DirShell}/cookie -O ${DirShell}/curr_cond_raw $address
addr_week=$(echo $address|sed 's/quick.*$//')
cont=0
until [ -s ${DirShell}/curr_cond_raw ] || [ $cont -ge 10 ]
do
wget --save-cookies ${DirShell}/cookie -O ${DirShell}/curr_cond_raw $address
sleep 2
cont=$(($cont+1))
done
#Formatage condition acctuelle
egrep -i 'CurrentTemp|CurrentText|CurrentTime|RealFeelValue|WindsValue|HumidityValue|DewPointValue|PressureValue|PressureTenValue|VisibilityValue|SunriseValue|SunsetValue|imgCurConCondition' ${DirShell}/curr_cond_raw > ${DirShell}/curr_cond
rm ${DirShell}/curr_cond_raw
sed -i -e 's/\(^.*blue\/\|_int.*$\|^.*">\|<\/span>.*$\|°C\)//g' -e 's/W/O/g' ${DirShell}/curr_cond
curr_cond_raw_image=$(sed -n 1p ${DirShell}/curr_cond)
sed -i 1s/$curr_cond_raw_image/$(test_image $curr_cond_raw_image)/ ${DirShell}/curr_cond
cp ${DirShell}/icones/base/$(sed -n 1p ${DirShell}/curr_cond).png ${DirShell}/icones/cc.png
sed -i 's/Unavailable/N\/A/g' ${DirShell}/curr_cond
sed -i '6s/ /\n/' ${DirShell}/curr_cond
sed -i '7s/ .*$//' ${DirShell}/curr_cond
def_vent curr
#-----------------------------------------
meteo_a_n_jours $periode
decoupage $periode
rm ${DirShell}/cookie
fi#!/bin/bash
# Créé par Didier-T (forum.ubuntu-fr.org)
# utilisation
# afmeteo.sh 'info à afficher' 'jour' 'moment'
#<jour> soit maintenant = cc soit un nombre de 0 à 14 (0 prévision pour aujourd'hui)
#<moment> jour ou soir (uniquement pour les prévisions)
DirShell="$HOME/conky/"
meteo() {
case $3 in
[Jj]our)
m=0
;;
[Ss]oir)
m=1
;;
*)
m=0
;;
esac
p=$(($1+$(($m*21))))
echo $(sed -n "$(($p))p" ${DirShell}/jour$2)
}
case $2 in
cc)
case $1 in
[Tt]emp) affichage=$(sed -n "2p" ${DirShell}/curr_cond) ;;
[Hh]eure) affichage=$(sed -n "3p" ${DirShell}/curr_cond) ;;
[Mm]eteo) affichage=$(sed -n "4p" ${DirShell}/curr_cond) ;;
[Tt]emp_res) affichage=$(sed -n "5p" ${DirShell}/curr_cond);;
[Dd]irection_[Vv]ent) affichage=$(sed -n "6p" ${DirShell}/curr_cond) ;;
[Vv]itesse_[Vv]ent) affichage=$(sed -n "7p" ${DirShell}/curr_cond) ;;
[Tt]aux_[Hh]umidite) affichage=$(sed -n "8p" ${DirShell}/curr_cond) ;;
[Pp]_[Rr]osee) affichage=$(sed -n "9p" ${DirShell}/curr_cond) ;;
[Pp]ression) affichage=$(sed -n "10p" ${DirShell}/curr_cond) ;;
[Tt]end_[Pp]ression) affichage=$(sed -n "11p" ${DirShell}/curr_cond) ;;
[Vv]isibilite) affichage=$(sed -n "12p" ${DirShell}/curr_cond) ;;
[Ll]ever_[Ss]oleil) affichage=$(sed -n "13p" ${DirShell}/curr_cond) ;;
[Cc]oucher_[Ss]oleil) affichage=$(sed -n "14p" ${DirShell}/curr_cond) ;;
*)
affichage="erreur"
;;
esac
;;
*)
case $1 in
[Jj]our) affichage=$(meteo 1 $2) ;;
[Mm]eteo) affichage=$(meteo 3 $2 $3) ;;
[Tt]emp) affichage=$(meteo 5 $2 $3) ;;
[Tt]emp_res) affichage=$(meteo 7 $2 $3) ;;
[Dd]irection_[Vv]ent) affichage=$(meteo 9 $2 $3) ;;
[Vv]itesse_[Vv]ent) affichage=$(meteo 10 $2 $3) ;;
[Pp]rob_[Oo]rage) affichage=$(meteo 12 $2 $3) ;;
[Qq]_[Pp]recipitation) affichage=$(meteo 14 $2 $3) ;;
[Qq]_[Pp]luie) affichage=$(meteo 16 $2 $3) ;;
[Qq]_[Nn]eige) affichage=$(meteo 18 $2 $3) ;;
[Dd]uree_[Pp]recipitation) affichage=$(meteo 20 $2 $3) ;;
[Dd]uree_[Pp]luie) affichage=$(meteo 22 $2 $3) ;;
[Ll]ever_[Ss]oleil) affichage=$(meteo 45 $2) ;;
[Cc]oucher_[Ss]oleil) affichage=$(meteo 47 $2) ;;
[Ll]ever_[Ll]une) affichage=$(meteo 49 $2) ;;
[Cc]oucher_[Ll]une) affichage=$(meteo 51 $2) ;;
[Dd]uree_[Jj]our) affichage=$(meteo 53 $2) ;;
[Dd]uree_[Nn]uit) affichage=$(meteo 55 $2) ;;
uv|UV|Uv|uV) affichage=$(meteo 57 $2) ;;
*)
affichage="erreur"
;;
esac
;;
esac
# retour information
echo $affichage
exit 0#21 Re : -1 » [Conky] Alternative à weather.com ( icones conkyforecast ) » Le 18/11/2011, à 11:49
- MimileVadrouille
- Réponses : 658
un peit post pour poster mon conkyrc:
Attention moi je l ai le temps en horizontal
:):):)
# 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 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 normal
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 580 85 # taille mini (px) ; largeur / hauteur
maximum_width 580 # 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 550
gap_y 28
#gap_y 148
# 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
color2 CCCCCC #Gris 1
color3 555555 #Gris 2
color4 333333 #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}
TEXT
${voffset 0} ${texeci 500 bash /home/antoine1/.conky/meteo}${font Vera:size=11}${color1}Chez moi ${goto 120}${font Vera:size=10}${color1}Aujourd'hui ${goto 245}${execpi 60 /home/antoine1/.conky/afmeteo jour 1}${goto 330}${execpi 60 /home/antoine1/.conky/afmeteo jour 2}${goto 420}${execpi 60 /home/antoine1/.conky/afmeteo jour 3}${goto 510}${execpi 60 /home/antoine1/.conky/afmeteo jour 4}${image /home/antoine1/.conky/icones/cc.png -p -15,10 -s 150x90}${image /home/antoine1/.conky/icones/J0jour.png -p 100,20 -s 80x48}${image /home/antoine1/.conky/icones/J0soir.png -p 160,20 -s 80x48}${image /home/antoine1/.conky/icones/J1jour.png -p 225,20 -s 60x36}${image /home/antoine1/.conky/icones/J1soir.png -p 265,20 -s 60x36}${image /home/antoine1/.conky/icones/J2jour.png -p 310,20 -s 60x36}${image /home/antoine1/.conky/icones/J2soir.png -p 350,20 -s 60x36}${image /home/antoine1/.conky/icones/J3jour.png -p 400,20 -s 60x36}${image /home/antoine1/.conky/icones/J3soir.png -p 440,20 -s 60x36}${image /home/antoine1/.conky/icones/J4jour.png -p 490,20 -s 60x36}${image /home/antoine1/.conky/icones/J4soir.png -p 530,20 -s 60x36}${font}
${voffset 1}
${voffset 1}
${voffset 0}
${voffset 1}
${voffset 1} ${goto 120}${font Vera:size=8}${color1}Max: ${font Vera:size=8:style=bold}${color4}${execpi 60 /home/antoine1/.conky/afmeteo Temp 0 jour}°C${goto 180}${font Vera:size=8}${color1}Min: ${font Vera:size=8:style=bold}${color4}${execpi 60 /home/antoine1/.conky/afmeteo Temp 0 soir}°C${goto 245}${execpi 60 /home/antoine1/.conky/afmeteo Temp 1 jour}°C${goto 285}${execpi 60 /home/antoine1/.conky/afmeteo Temp 1 soir}°C${goto 330}${execpi 60 /home/antoine1/.conky/afmeteo Temp 2 jour}°C${goto 370}${execpi 60 /home/antoine1/.conky/afmeteo Temp 2 soir}°C${goto 420}${execpi 60 /home/antoine1/.conky/afmeteo Temp 3 jour}°C${goto 460}${execpi 60 /home/antoine1/.conky/afmeteo Temp 3 soir}°C${goto 510}${execpi 60 /home/antoine1/.conky/afmeteo Temp 4 jour}°C${goto 550}${execpi 60 /home/antoine1/.conky/afmeteo Temp 4 soir}°C${font}
${voffset 0} ${goto 120}${font Vera:size=8}${color1}${execpi 60 /home/antoine1/.conky/afmeteo Lever_Soleil 0 jour}${goto 180}${font Vera:size=8}${color1}${execpi 60 /home/antoine1/.conky/afmeteo Coucher_Soleil 0 jour}${goto 245}${execpi 60 /home/antoine1/.conky/afmeteo Lever_Soleil 1 jour}${goto 285}${execpi 60 /home/antoine1/.conky/afmeteo Coucher_Soleil 1 jour}${goto 330}${execpi 60 /home/antoine1/.conky/afmeteo Lever_Soleil 2 jour}${goto 370}${execpi 60 /home/antoine1/.conky/afmeteo Coucher_Soleil 2 jour}${goto 420}${execpi 60 /home/antoine1/.conky/afmeteo Lever_Soleil 3 jour}${goto 460}${execpi 60 /home/antoine1/.conky/afmeteo Coucher_Soleil 3 jour}${goto 510}${execpi 60 /home/antoine1/.conky/afmeteo Lever_Soleil 4 jour}${goto 550}${execpi 60 /home/antoine1/.conky/afmeteo Coucher_Soleil 4 jour}${font}
${voffset 1} ${goto 5}${font Vera:size=10}${color1}${execpi 60 /home/antoine1/.conky/afmeteo Meteo cc} : ${font Vera:size=10}${execpi 60 /home/antoine1/.conky/afmeteo Temp cc}°C / FL : ${execpi 60 /home/antoine1/.conky/afmeteo Temp_res cc}°C${font}${alignr}${font Vera:size=6}Last update: ${execpi 60 /home/antoine1/.conky/afmeteo Heure cc}${font}et pour le deuxième (les info)
# 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
# mail spool
#mail_spool $MAIL
# 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 normal
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
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 155
# 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
text_buffer_size 4096
max_specials 1024
path_affiche /home/antoine1/.conky/afmeteo
# 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
TEXT
${voffset 0}${goto 0}${color3}Température : $color1${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Temp cc}° / FL ${execpi 60 /home/antoine1/.conky/afmeteo Temp_res cc}°
${voffset -5}${goto 0}${color3}Vent : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Direction_Vent cc} ${execpi 60 /home/antoine1/.conky/afmeteo Vitesse_Vent cc} km/h
${voffset -5}${goto 0}${color3}Humidité : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Taux_Humidite cc }
${voffset -5}${goto 0}${color3}Point de rosée : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo P_Rosee cc }°C
${voffset -5}${goto 0}${color3}Pression : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Pression cc }
${voffset -5}${goto 0}${color3}Tendance : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Tend_Pression cc }
${voffset -5}${goto 0}${color3}Visibilité : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Visibilite cc }
${voffset -5}${goto 0}${color3}Levé du soleil : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Lever_Soleil cc }
${voffset -5}${goto 0}${color3}Couché du soleil : ${color1}${alignr}${execpi 60 /home/antoine1/.conky/afmeteo Coucher_Soleil cc}
${voffset 0}${font Vera:size=6}${color1}${alignr}last update : ${execpi 60 /home/antoine1/.conky/afmeteo Heure cc}#22 Re : -1 » [résolu]choix logiciel de gestion de photos ? » Le 01/05/2012, à 13:43
- MimileVadrouille
- Réponses : 12
J utilise jbrout, simple et efficace surtout pour la gestion des mots clefs!
#23 Re : -1 » [Résolu] Enregistrer son travail sur GIMP toutes les 5min ? » Le 07/08/2011, à 14:37
- MimileVadrouille
- Réponses : 2
Salut,
peut etre aussi ferais tu bien de vérifier ta mémoire ; j utilise énormément GIMP et il est vraiment stable sur ma machine
#24 Re : -1 » [+/- Résolu] Python GIMP : comment selectionner un drawable ? » Le 18/07/2011, à 11:33
- MimileVadrouille
- Réponses : 2
Salut
est cela que tu cherches ?
vers la fin je sélectionne le l avant dernier calque pour le merger avec celui du dessous, et rebelote pour celui qui est tout au dessus.
(set! overlay-layer (car (gimp-image-merge-down inImage overlay-layer 0)))
(set! GreenishYellow-layer (car (gimp-image-merge-down inImage GreenishYellow-layer 0)))
PS: cest ma petite adaptation du du script Cross Process de Ben Mesander
(define (script-fu-cross inImage inLayer contrast tint color MergeDown)
; start an undoable group of operations
(gimp-image-undo-group-start inImage)
; remap curves for red/green/blue components
(gimp-curves-spline inLayer HISTOGRAM-RED 10 #(0 0 88 47 170 188 221 249 255 255))
; pdb.gimp_curves_spline(drw, RED, 10, (0, 0,
; rint(j, 88), rint(j, 47),
; rint(j,170), rint(j,188),
; rint(j,221), rint(j,249),
; 255, 255))
(gimp-curves-spline inLayer HISTOGRAM-GREEN 8 #(0 0 65 57 184 208 255 255))
(gimp-curves-spline inLayer HISTOGRAM-BLUE 4 #(0 29 255 226))
; duplicate image layer, mark it as contrast% opacity, and overlay it
(let* (
(overlay-layer (car (gimp-layer-copy inLayer FALSE)))
(GreenishYellow-layer (car (gimp-layer-new inImage (car (gimp-image-width inImage))
(car (gimp-image-height inImage)) RGB-IMAGE
"GreenishYellow" 10 OVERLAY-MODE)))
)
(gimp-image-add-layer inImage overlay-layer -1)
(gimp-layer-set-opacity overlay-layer contrast)
(gimp-layer-set-mode overlay-layer OVERLAY-MODE)
; create a new greenish-yellow layer at 10% opacity and overlay it
(gimp-context-set-foreground '(0 255 186))
(gimp-drawable-fill GreenishYellow-layer FOREGROUND-FILL)
(gimp-image-add-layer inImage GreenishYellow-layer -1)
;Merge down
(if(= MergeDown TRUE)
(begin
;Merge the Yellow layer down
(gimp-image-set-active-layer inImage overlay-layer)
(set! overlay-layer (car (gimp-image-merge-down inImage overlay-layer 0)))
;Merge the magenta layer down
(gimp-image-set-active-layer inImage GreenishYellow-layer)
(set! GreenishYellow-layer (car (gimp-image-merge-down inImage GreenishYellow-layer 0)))
;Merge the cyan layer down
; (gimp-image-set-active-layer img cyan-layer)
; (set! cyan-layer (car (gimp-image-merge-down img cyan-layer 0)))
)
)
)
; display cross processed image, and end the undoable group of operations
(gimp-displays-flush)
(gimp-image-undo-group-end inImage))

