9. status >>> for x in data.entries[0]
version ... print x
encoding ...
bozo updated
headers yweather_condition
etag updated_parsed
href links
namespaces title
entries summary_detail
geo_lat
summary
guidislink
title_detail
link
geo_long
yweather_forecast
id
>>>type(data)
<class 'feedparser.FeedParser
Dict'>
>>> import feedparser
>>> url = "http://weather.yah
ooapis.com/forecastrss?p=UKXX
0637&u=c"
>>> data = feedparser.parse(u
rl)
>>> data
>>> data.entries[0]
{'updated': u'Wed, 1 Apr
>>>for x in data : 2009 12:50 am BST',
... print x ... 'yweather_condition': u,
feed 'updated_parsed': ...
10. from mutagen.mp3 import MP3
import os
from os.path import
join,getsize,exists
import sys
import apsw
Dev Graphics Internet M/media System
def MakeDataBase():
pass
def S2HMS(t):
CD/DVD HDD USB Drive Laptop Wireless
pass
def WalkThePath(musicpath):
pass
def error(message):
pass
def main():
pass
def usage():
pass
if __name__ == '__main__':
main()
11. def error(message):
print >> sys.stderr,
str(message)
def usage():
message = (
'==============================================n'
'mCat - Finds all *.mp3 files in a given folder (and sub-folders),n'
'tread the id3 tags, and write that information to a SQLite database.nn'
'Usage:n'
't{0} <foldername>n'
't WHERE <foldername> is the path to your MP3 files.nn'
'Author: Greg Waltersn'
'For Full Circle Magazinen'
'==============================================n'
).format(sys.argv[0])
error(message)
sys.exit(1)
12. def main():
global connection
global cursor
#----------------------------------------------
if len(sys.argv) != 2:
usage()
else:
StartFolder = sys.argv[1]
if not exists(StartFolder): # From os.path
print('Path {0} does not seem to
exist...Exiting.').format(StartFolder)
sys.exit(1)
else:
print('About to work {0}
folder(s):').format(StartFolder)
# Create the connection and cursor.
connection=apsw.Connection("mCat.db3")
cursor=connection.cursor()
# Make the database if it doesn't exist...
MakeDataBase()
# Do the actual work...
WalkThePath(StartFolder)
# Close the cursor and connection... Print('String that will be
cursor.close() printed with {0} number of
connection.close() statements”).format(replaceme
# Let us know we are finished... nt values)
print("FINISHED!")
13.
14. Dev Graphics Internet M/media System
CD/DVD HDD USB Drive Laptop Wireless
15.
16. Dev Graphics Internet M/media System
CD/DVD HDD USB Drive Laptop Wireless
wget
http://www.kegel.com/wine/win
etricks
17. >>> temp = re.split(r'n',tem
p)
>>> temp
[u, u'Current Conditions:',
sh winetricks corefonts u'Haze, 13 C', u'Forecast:',
vcrun6 vcrun2005 u'Thu - Rain. High: 14 Low:
9', u'Fri - Light Rain.
High: 12 Low: 7', u, u'Full
Forecast at Yahoo! Weather',
u'(provided by The Weather
Channel)'] >>>temp[2]
u'Haze, 13 C'
>>>summary = data.entries[0].
summary
>>>import re
>>>pattern = '<.+?>'
>>>temp = re.sub(pattern,,sum
mary)
>>>temp
u'nCurrent >>>temp = re.findall(u'[0-
Conditions:nHaze, 13 9]+',temp[2])[0]
CnForecast:nThu - Rain. >>>temp
High: 14 Low: 9nFri - Light u'13'
Rain. High: 12 Low: 7nn >>>
Full Forecast at Yahoo! >>> temp = int(temp)
Weathern(provided by The >>> temp
Weather Channel)' 13
24. #!/usr/bin/python
# -*- coding: utf-8 -*-
import feedparser,re,os
def change_wallpaper(filename):
cmd = .join(["gconftool-2 -s /desktop/gnome/background/picture_filename
-t string "",filename,"""])
os.system(cmd)
url = "http://weather.yahooapis.com/forecastrss?p=UKXX0637&u=c"
data = feedparser.parse(url)
# extract the summary from the data
summary = data.entries[0].summary
temp = re.split(r'n',re.sub('<.+?>',,summary))
temp = int(re.findall('[0-9]+',temp[2])[0])
if (temp <0) :
change_wallpaper('/home/evilnick/weather/freezing.svg')
elif (temp<9) :
change_wallpaper('/home/evilnick/weather/snow.svg')
elif (temp<16) :
change_wallpaper('/home/evilnick/weather/mild.svg')
elif (temp<26):
change_wallpaper('/home/evilnick/weather/warm.svg')
else:
change_wallpaper('/home/evilnick/weather/hot.svg')
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39. is presented by members of the
United Kingdom’s Ubuntu Linux community.
We aim is to provide current, topical information about, and
for, Ubuntu Linux users the world over. We cover all aspects
of Ubuntu Linux and Free Software, and appeal to everyone
from the newest user to the oldest coder, from the
command line to the latest GUI.
Because the show is produced by the Ubuntu UK
community, the podcast is covered by the Ubuntu Code of
Conduct and is therefore suitable for all ages.