![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
General Help All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
Conky Weather Forecast Python Script
ArchLinux : Package support is present in the AUR. All my packages can be seen here: http://aur.archlinux.org/packages.php?SeB=m&K=kaivalagi
IMPORTANT NEWS All the script packages have now been copied into the Conky Hardcore PPA. Any package updates will be provided by the team through this new ppa. The ppa can be found here: https://launchpad.net/~conkyhardcore/+archive/ppa To use this ppa first delete the old ppa files using this: Code:
sudo rm /etc/apt/sources.list.d/m-buck* __________________________________________________ __________________________________________________ ______________________________ Intro I put together this python script to produce various bits of weather data on demand for use in Conky. This sort of thing has been done already by lvleph, a post for his contribution is here. I wanted to create something, firstly to gain some experience with Python, and secondly so that there was no dependency on the yahoo weather website and it's formatting. This hopefully means that it will have a little longevity. Some key features
There is a README with the install and attached here, I suggest you give it atleast a quick once over! Hope some of you find it useful Any suggestions, please speak up. Basic Install Method 1: Using apt 1) Create the necessary list file for access to the repository by running one of these. Karmic Koala: Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-karmic.list -O /etc/apt/sources.list.d/conkyhardcore-karmic.list Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-jaunty.list -O /etc/apt/sources.list.d/conkyhardcore-jaunty.list Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-intrepid.list -O /etc/apt/sources.list.d/conkyhardcore-intrepid.list Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-hardy.list -O /etc/apt/sources.list.d/conkyhardcore-hardy.list Code:
wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-key.gpg -O- | sudo apt-key add - Code:
sudo apt-get update && sudo apt-get install conkyforecast Download and run latest .deb file for conkyforecast from the launchpad site here: https://launchpad.net/~conkyhardcore/+archive/ppa Warning, this will not ensure you are kept up-to-date. Only method 1 will do that Method 3: Using tar.gz file Download the latest .tar.gz file for conkyforecast from the launchpad site here: https://launchpad.net/~conkyhardcore/+archive/ppa. Once downloaded extract all the contents to an appropriate folder, and edit the conkyForecast script to point to the correct location where conkyForecast.py is. Unless you are using a non-Debian based OS I don't suggest this. Users of Debian/Ubuntu flavour OS's should ideally use method 1. Again you will not receive updates using this method. ONLY method 1 can do this for you All further details on setup are orientated around the deb package based install, so may differ from what you choose your setup to be, if done using the tarball. Weather.com XOAP Service Registration Due to the risk of having the previously registered xoap weather.com account terminated because of high volumes of requests, I have upgraded the script to use a users own registered details. A template config file exists which holds all the settings used by the script, and most importantly, stores the partner id and registration code for the weather.com xoap service. It can be found here "/usr/share/conkyforecast/conkyForecast.config" For a working script you NEED to define, in a user specific config file, a partner id and registration code for the weather.com xoap service. For this purpose the config file should be copied to "~/.conkyForecast.config" and setup as required. To register and obtain the necessary codes you need to visit the following url and fill out the form: http://www.weather.com/services/xmloap.html After successfully completing the form, you will then receive a couple of emails providing you with the necessary codes to update these settings with, along with the software development kit and terms and conditions. To copy and edit the config file, using the command line , run the following two commands in a terminal, one after the other: Code:
cp /usr/share/conkyforecast/conkyForecast.config ~/.conkyForecast.config nano ~/.conkyForecast.config Location Code For Script Calls To identify the location code for your town/city the following URL should be used, replacing NORWICH with the one you're looking up : http://xoap.weather.com/search/search?where=NORWICH The following xml is returned for the above url, from which the correct location code (loc id value) can be picked. Mine was UKXX0103. Code:
<search ver="2.0"> <loc id="USNY0428" type="1">East Norwich, NY</loc> <loc id="USNY1036" type="1">North Norwich, NY</loc> <loc id="USCT0155" type="1">Norwich, CT</loc> <loc id="UKXX0103" type="1">Norwich, United Kingdom</loc> <loc id="USKS0428" type="1">Norwich, KS</loc> <loc id="USND0266" type="1">Norwich, ND</loc> <loc id="USNY1044" type="1">Norwich, NY</loc> <loc id="USOH0716" type="1">Norwich, OH</loc> <loc id="USVT0175" type="1">Norwich, VT</loc> </search> Example Use In the /usr/share/conkyforecast/example folder you'll find 2 files, conkyrc and conkyForecast.template Conky can be run using these example files as follows: Code:
conky -c /usr/share/conkyforecast/example/conkyrc & The important thing to note now is that the script is called using this in Conky: Code:
{execi 1800 conkyForecast ...options...}
Code:
{execi 1800 python /path/to/file/conkyForecast.py ...options...}
Usage Help You can get the current help options at any time by running (change the path as necessary): Code:
conkyForecast -h Code:
conkyForecast --help Code:
Usage: conkyForecast [options]
Options:
-h, --help show this help message and exit
-l CODE, --location=CODE
location code for weather data [default: UKXX0103],Use
the following url to determine your location code by
city name:
http://xoap.weather.com/search/search?where=Norwich
-d DATATYPE, --datatype=DATATYPE
[default: HT] The data type options are: DW (Day of
Week), WF (Weather Font output), WI (Weather Icon
Path), LT (Forecast:Low Temp,Current:Feels Like Temp),
HT (Forecast:High Temp,Current:Current Temp), CC
(Current Conditions), CT (Conditions Text), PC
(Precipitation Chance), HM (Humidity), VI
(Visibility), WD (Wind Direction), WA (Wind Angle - in
degrees), WS (Wind Speed), WG (Wind Gusts), BF
(Bearing Font), BI (Bearing Icon Path), BS (Bearing
font with Speed), CN (City Name), CO (Country), OB
(Observatory), SR (SunRise), SS (SunSet), DL
(DayLight), MP (Moon Phase), MF (Moon Font), MI (Moon
Icon Path), BR (Barometer Reading), BD (Barometer
Description), UI (UV Index), UT (UV Text), DP (Dew
Point), LU (Last Update at weather.com), LF (Last
Fetch from weather.com). Not applicable at command
line when using templates.
-s NUMBER, --startday=NUMBER
define the starting day number, if omitted current
conditions are output. Not applicable at command line
when using templates.
-e NUMBER, --endday=NUMBER
define the ending day number, if omitted only starting
day data is output. Not applicable at command line
when using templates.
-S NUMBER, --spaces=NUMBER
[default: 1] Define the number of spaces between
ranged output. Not applicable at command line when
using templates.
-t FILE, --template=FILE
define a template file to generate output in one call.
A displayable item in the file is in the form
[--datatype=HT --startday=1]. The following are
possible options within each item: --location,--
datatype,--startday,--endday,--night,--shortweekday,--
imperial,--beaufort,--hideunits,--hidedegreesymbol,--
spaces,--minuteshide. Note that the short forms of the
options are not supported! If any of these options is
set from the commandline, it sets the default value of
the option for all template items.
-L LOCALE, --locale=LOCALE
override the system locale for language output
(bg=bulgarian, cs=czech, de=german, es=spanish,
en=english, es=spanish, fj=fijian, fr=french,
it=italian, nl=dutch, pl=polish, ro=romanian,
sk=slovak, more to come)
-i, --imperial request imperial units, if omitted output is in
metric.
-b, --beaufort request beaufort scale for wind speeds, if omitted
output is either metric/imperial.
-n, --night switch output to night data, if omitted day output
will be output.
-w, --shortweekday Shorten the day of week data type to 3 characters.
-u, --hideunits Hide units such as mph or C, degree symbols (°) are
still shown.
-x, --hidedegreesymbol
Hide the degree symbol used with temperature output,
this is only valid if used in conjunction with
--hideunits.
-m NUMBER, --minuteshide=NUMBER
Works only with LU and LF. If present, hides the date
part of the LU or LF timestamp if the day of the
timestamp is today. The time part is also hidden, if
the timestamp is older than minutes specified in this
argument. If set to 0, the time part is always shown.
If set to -1, the value EXPIRY_MINUTES from the config
file is used.
-c WIDTH, --centeredwidth=WIDTH
If used the output will be centered in a string of the
set width, padded out with spaces, if the output width
is greater than the setting it will have no effect
-r, --refetch Fetch data regardless of data expiry.
-v, --verbose Request verbose output, not a good idea when running
through conky!
-V, --version Displays the version of the script.
--errorlogfile=FILE If a filepath is set, the script appends errors to the
filepath.
--infologfile=FILE If a filepath is set, the script appends info to the
filepath.
Notes On Fonts There are several fonts included in the release, these are located in /usr/share/fonts/truetype/conkyforecast They should be used as follows:
Notes On Images There are now three datatype options which provide image paths to be used with the new $image parameter in Conky 1.7.1+ The data types are WI (Weather icons), MI (Moon icons) and BI (Bearing icons). For more help and guidance on the $image parameter needed in conjunction with these datatype options visit the Conky Hardcore website, specifically this page: http://conky.linux-hardcore.com/?page_id=2487 Notes On Conky Config Files I recommend using the test files as a templates when creating your own conkyrc file. Note that if the location of the python script is different to the example given, please ensure the conkyrc-test* file, or your own, is amended to point to the correct location. A quick example of use in conky config: Code:
Conditions: ${execi 3600 conkyForecast --location=UKXX0103 --datatype=CC}
${font ConkyWeather:size=36}${execi 3600 conkyForecast --location=UKXX0103 --datatype=WF}${font}
Temp: ${execi 3600 conkyForecast --location=UKXX0103 --datatype=HT}
Notes On Template Files Recently the use of templates was added, so that a single exec call can be made to retrieve a multitude of data. An example template file is included in the install, and the usage text also explains the options available. Note that you can combine standard font output with weather fonts in a single template by using the execp and execpi commands in conky. The example uses this so to see how this works take a look at that. A quick example of template file options and layout: Code:
[--datatype=DW --startday=1 --shortweekday] [--datatype=HT --startday=1 --hideunits]/[--datatype=LT --startday=1 --hideunits] Notes On Script Config File Values The conkyForecast.config which accompanies the script has a few config values worthy of a mention. Code:
CACHE_FOLDERPATH = /tmp/ Pickling the information retrieved means that it can be reused without needing a round trip to the weather.com XOAP service each time something is displayed through a script call. The default folder used is /tmp which is fine in most cases. However it should be noted that the /tmp folder is emptied on reboot, so data will not be kept in this case and a will needs refetching from the web again. In situations where reboots are common, you could change the path to your own home folder if desired, meaning that cached data will never be lost. Code:
CONNECTION_TIMEOUT = 5 Code:
EXPIRY_MINUTES = 30 When the script is called, if the datetime of the cached files is older than this setting in minutes, the script will refetch the weather data required, and refresh the cache. Code:
TIME_FORMAT = %H:%M DATE_FORMAT = %Y-%m-%d They follow standard strftime formatting conventions. For more details, see the section on strftime here: http://docs.python.org/lib/module-time.html Code:
LOCALE = Code:
XOAP_PARTNER_ID = XOAP_LICENCE_KEY = fetching data from the weather.com XOAP service. As mentioned before above to register and obtain the necessary codes you need to visit this url: http://www.weather.com/services/xmloap.html and fill out the form Gotchas 1) Conky has a default limitation of 128 bytes for any text output from a variable (such as execi). If you are creating large templates with more characters than the default buffer size can handle, the output will get truncated. If this happens you can override the default behaviour by setting as new buffer size before the TEXT section in your conkyrc file, as follows: Code:
text_buffer_size 1024 Code:
--datatype=HT --startday=0 --endday=4 Code:
# Force UTF8? note that UTF8 support required XFT override_utf8_locale yes Code:
uppercase yes Further Help If you have an issue and are not sure, try running the same conkyForecast command in the terminal window and add the option --verbose, you should then see lots of information about what the script is doing, any warnings or errors should also be displayed. If after doing the above you are still stuck, further help relating to conkyForecast can be got on this thread. Note that it is best to post --verbose (hint on the option to use) output of your script call, as well as the conkyrc you are using. This way the issue can be understood quickly and easily. The README is attached to this post also, take a look at this is you want to know more. Most of it's contents are here but there is some useful info there. For any updates you receive you can view the readme file by running this in the terminal: Code:
gunzip -c /usr/share/doc/conkyforecast/README.gz | less Development History Created: 13/04/2008 Noteworthy thanks go, in alphabetical order, to benpaka, Bruce M., El_Belgicano, HippyRandall, jjgomera, Nite, stancho and vasilub1 for their contributions to the script and it's rollouts over the past few months. Development history going forwards can be seen here https://code.launchpad.net/~m-buck/+junk/conkyforecast All packages available from me can be found here: https://launchpad.net/~conkyhardcore/+archive/ppa I have also created a new website, for now it is relatively sparse, but it does details my conky scripts to a certain degree. You can find it here: http://www.kaivalagi.com
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA Last edited by kaivalagi; 4 Weeks Ago at 08:01 PM.. Reason: updated script, see development history |
|
|
|
|
|
#2 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Sep 2007
Location: 34°35'S - 58°21'W
My beans are hidden!
|
Re: Conky Weather Forecast Python Script
Hi kaivalagi,
OK, I'm here and will spread the word. I would have though as long as it was active it would be OK. Little do I know. But it's here now. Thanks. BTW, you might want to consider grabbing the post about your e-mail script (# 154 or 156) from the old thread and start that up as a "new" thread too. Be a shame to loose that. CHIMO! Bruce
__________________
|
|
|
|
|
|
#3 | |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
Re: Conky Weather Forecast Python Script
Quote:
I also want to add another thread about rtorrent integration into conky, but that's going to take some explaining... Edit: thread added for the email script - http://ubuntuforums.org/showthread.php?p=5454877
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA Last edited by kaivalagi; July 25th, 2008 at 05:36 AM.. |
|
|
|
|
|
|
#4 |
|
Gee! These Aren't Roasted!
![]() |
Re: Conky Weather Forecast Python Script
Does this script check for network connectivity / internet access?
if not do you know of any way to force conky to check? ...I am currently using {if_running } to only load my weather if Thunderbird is open.
__________________
| Kubuntu 10.04 (amd64) | KDE 4.4 RC1 |
| Biostar TForce7050-M2 5.x | 4GB OCZ PC2-6400 Platinum Rv.2 RAM | Athlon 64 X2 4000+ | | Razer Lachesis Gaming Mouse | Logitech G15 Gaming Keyboard | Conky: ... no such configuration: 'normal' |
|
|
|
|
|
#5 | |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
Re: Conky Weather Forecast Python Script
Quote:
The script tries to connect to weather.com before doing it's thing, if unsuccessful it then checks for cached weather data from a previously successful connection, and uses that. If none of this works out a fairly short error message is displayed instead. Let me know how you get on
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA |
|
|
|
|
|
|
#6 |
|
Just Give Me the Beans!
![]() Join Date: Oct 2007
Location: Belgium
Beans: 73
Ubuntu 8.04 Hardy Heron
|
Re: Conky Weather Forecast Python Script
hello,
I have a problem with my template, as you can see the precipitaion and lower temperatures are not completely displayed. Also i have a question about the variable LT for the current day. I suppose this displays the temperature of the upcoming night? As you can see this is not currect, following my weather.com screenlet this should display 17°C. Here is my template: Code:
{--datatype=DW --startday=1 --shortweekday} {--datatype=DW --startday=2 --shortweekday} {--datatype=DW --startday=3 --shortweekday} {--datatype=DW --startday=4 --shortweekday}
{--datatype=HT --startday=1} {--datatype=HT --startday=2} {--datatype=HT --startday=3} {--datatype=HT --startday=4}
{--datatype=LT --startday=1} {--datatype=LT --startday=2} {--datatype=LT --startday=3} {--datatype=LT --startday=4}
{--datatype=PC --startday=1} {--datatype=PC --startday=2} {--datatype=PC --startday=3}
{--datatype=PC --startday=4}
Code:
${alignc 20}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=CC}${alignr}${color1}tonight: ${color}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=LT}???
${font Weather:size=45}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=WF}
${alignc 4}${voffset -45}${font size=15}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=HT}
$font${voffset -75}${alignr}${color1}Wind: $color${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=WS}
${alignr}${color1}Vochtigheid: $color${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=HM}
${alignr}${color1}Neerslag: ${color}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=PC}
${alignr}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=BR} - ${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=BD}$color$font
${color1}Zon op: ${color3}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=SR}${alignr}${color1}onder: ${color}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=SS}$color
${voffset 12}${color1}Maan: ${color}${voffset -3}${color}${font moon phases:size=15}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=MF}$font$color
${stippled_hr}
${font weather:size=30}${execi 3600 python /home/matt/conky/conkyForecast.py --location=BEXX0008 --startday=1 --endday=4 --datatype=WF --spaces=5}$font$color
${execi 3600 python /home/matt/conky/conkyForecast.py --location=BEXX0008 --template=/home/matt/conky/conky3Days.template}
thanks! Matt |
|
|
|
|
|
#7 | |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
Re: Conky Weather Forecast Python Script
Quote:
--location=UKXX0103 --datatype=PC <-- N/A (current conditions, default to N/A always) --location=UKXX0103 --datatype=PC --startday=0 <-- 20% (today's forecast) For forecasts LT is the lowest temperature forecasted, for current conditions it is the feels like temperature rather than the night time one. I ended up using the LT datatype for this in current conditions as it served no purpose previously...as with precipitation you might find it more appropriate using --startday=0 --datatype=LT to get todays forecast low temp, this is likely to be night time temperature. I hope that's answered your questions, if you have suggestions for any changes based on this let me know. For now it is a simple case of xml for current goes into current class data, xml for forecasts goes in forecast class data...
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA |
|
|
|
|
|
|
#8 |
|
Just Give Me the Beans!
![]() Join Date: Oct 2007
Location: Belgium
Beans: 73
Ubuntu 8.04 Hardy Heron
|
Re: Conky Weather Forecast Python Script
hello,
thanks. I understand it better now. But you forgot to answer why the low temps in the 4-day forecast are not completely displayed (see screenshot). Thanks! Matt |
|
|
|
|
|
#9 | |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
Re: Conky Weather Forecast Python Script
Quote:
You should be able to sort out that issue by including the following in your conkyrc before the TEXT section: Code:
text_buffer_size 1024 Hope that helps
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA |
|
|
|
|
|
|
#10 |
|
Just Give Me the Beans!
![]() Join Date: Oct 2007
Location: Belgium
Beans: 73
Ubuntu 8.04 Hardy Heron
|
Re: Conky Weather Forecast Python Script
OK,
The text-buffer thingy worked, thanks! Now i am having an issue with the wind direction arrows (see screenshot). Conky: Code:
${alignc 20}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=CC}${alignr}${color1}tonight: ${color}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=LT}???
${font Weather:size=45}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=WF}
${alignc 4}${voffset -45}${font size=15}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=HT}
$font${voffset -75}${alignr}${color1}Wind: $color${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=WS}
${alignr}${color1}Vochtigheid: $color${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=HM}
${alignr}${color1}Neerslag: ${color}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=PC}
${alignr}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=BR} - ${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=BD}$color$font
${color1}Zon op: ${color3}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=SR}${alignr}${color1}onder: ${color}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=SS}$color
${voffset 12}${color1}Maan: ${color}${voffset -3}${color}${font moon phases:size=15}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=MF}$font$color${font arrows:size=15}${execi 3600 python conky/conkyForecast.py --location=BEXX0008 --datatype=WD}
|
|
|
|
| Bookmarks |
| Tags |
| conky, forecast, python, script, weather |
| Thread Tools | |
| Display Modes | |
|
|