Onur Güzel

9Aug/100

Show forecast using Yahoo! Weather

Note: This snippet uses piksemel module to parse XML files. If you don't have it, read this article to install it.

First of all, you need the WOEID (Where on Earth Identification) of the city. In order to learn it, go to http://weather.yahoo.com and search for the city. You'll find the WOEID at the end of the url of the page.

# for Istanbul, TR
woeid = 2344116

Use this id in Yahoo! Weather API url, for w parameter.

weatherUri = "http://weather.yahooapis.com/forecastrss?w=%d" % woeid

If you want the results to be in metric units, add u=c parameter into your query.

weatherUri = "http://weather.yahooapis.com/forecastrss?w=%d&u=c" % woeid

Using urllib, fetch the XML file:

import urllib
xml = urllib.urlopen(weatherUri).read()

We can parse this XML easily using piksemel:

import piksemel
temp = piksemel.parseString(xml).getTag('channel').getTag('item').getTag('yweather:condition').getAttribute('temp')

You can also view XML file and look for other resources such as: humidity, visibility, wind, etc.

9Aug/100

How to install piksemel module

piksemel is a easy to use python XML parser, based on iksemel.

Not: If you're using Pardus, piksemel is preinstalled on your system.

Not: If you're using Windows, before you continue make sure you've already installed mingw32 to your system and its directory is included in PATH.

Steps for Linux users:

  • Download the package from http://cekirdek.pardus.org.tr/~bahadir/piksemel/piksemel-1.3.1.tar.gz and unpack it.
  • Run:
    python setup.py build
  • Run:
    python setup.py install

Steps for Windows users:

  • Download the package from http://cekirdek.pardus.org.tr/~bahadir/piksemel/piksemel-1.3.1.tar.gz and unpack it.
  • In piksemel-1.3.1 directory, run:
    setup.py bdist_wininst build --compiler=mingw32
  • Run the installer file under the piksemel-1.3.1/dist directory.
Filed under: Uncategorized No Comments
14Jun/100

yatp: yet another transfer protocol

In the beginning of March, I started to a new project with my room-mate Diego.

The main problem is sharing. We shouldn't be sending e-mails to our friends to share a link, a document file, a presentation or some pictures. We shouldn't try to memorize a TinyURL to tell a friend. Instant messengers? Eww! We hate those, who doesn't?

Instant messengers are often useful. However there are many alternatives. Most of them requires you to be online to receive messages, and your online status will be public to your contacts. Most of them uses more then 30 MB of your computer memory. You cannot use them in a network which has no internet connection. Lots of disadvantages.

There's also no easy way to share files. Websites providing file sharing services make you to much, enter a CAPTCHA image, then wait again. You cannot share a file even if you're in the same network. OS differences, lack of configuration, bugs, security holes...

We are planning to create a new service based on HTTP to simplify sharing things between friends, especially whose computers are in the same network. We called it yatp, yet another transfer protocol, even it's not a protocol. We did some brainstorming and created a website. More details will be announced later. And do not forget to visit: yatp.net

Sharing will be fun.

4Mar/100

Hello World

I decided to activate my blog again, with brand-new posts!

My posts will be about php and python programming languages, Linux and open source software. I'm planning to write in English, but some posts might be in Turkish as well. Since I'm just not that good at English, excuse me for my probable mistakes and feel free to correct them.

Tutorials, snippets, reviews and more... It's gonna be fun!

Stay connected.