<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>scaryclam.co.uk</title>
	<atom:link href="http://blog.scaryclam.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.scaryclam.co.uk</link>
	<description>Wibble</description>
	<lastBuildDate>Thu, 29 Dec 2011 16:49:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Opt out of Virgin Medias broken DNS</title>
		<link>http://blog.scaryclam.co.uk/2011/12/29/opt-out-of-virgin-medias-broken-dns/</link>
		<comments>http://blog.scaryclam.co.uk/2011/12/29/opt-out-of-virgin-medias-broken-dns/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 16:49:03 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=119</guid>
		<description><![CDATA[Recently I found that some Internet services were broken on my friends home connection. After some digging around I found that his connection was being hijacked by Virgin Media whenever a target server did not exist. Rather than following basic Internet protocols Virgin Media hijack the connection so that they can advertise themselves and sponsored [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I found that some Internet services were broken on my friends home connection. After some digging around I found that his connection was being hijacked by Virgin Media whenever a target server did not exist. Rather than following basic Internet protocols Virgin Media hijack the connection so that they can advertise themselves and sponsored websites rather than allowing the connection to fail like it should. So I tried to use their &#8216;opt out&#8217; link in order to restore some sanity. I found a 404 error page instead. After much Googling it seems that the link that they provide has been out of  order for much of the life of the &#8216;service&#8217;. The link they provide is: <a href="https://my.virginmedia.com/advancederrorsearch/settings">https://my.virginmedia.com/advancederrorsearch/settings</a>. However, there is hope for anyone finding a 404 error at the provided link to still manage to opt out. Try going to <a href="http://my.virginmedia.com/advancederrorsearch/settings">http://my.virginmedia.com/advancederrorsearch/settings</a> instead as this link worked just fine for me and my friend (notice the http rather than https). No more broken Internet!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2011/12/29/opt-out-of-virgin-medias-broken-dns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python, super and multiple arguments</title>
		<link>http://blog.scaryclam.co.uk/2011/10/26/python-super-and-multiple-arguments/</link>
		<comments>http://blog.scaryclam.co.uk/2011/10/26/python-super-and-multiple-arguments/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 13:51:49 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=106</guid>
		<description><![CDATA[After playing around with the super keyworld in Python, I finally stumbled across this question which helped explain some multiple inheritence, with arguments. This also helped me to understand the use of super in Python and how to whole thing links together. I edited the original answer to the question as I found Python complaining [...]]]></description>
			<content:encoded><![CDATA[<p>After playing around with the super keyworld in Python, I finally stumbled across <a href="http://bytes.com/topic/python/answers/43164-calling-__init__-multiple-inheritance">this question</a> which helped explain some multiple inheritence, with arguments. This also helped me to understand the use of super in Python and how to whole thing links together. I edited the original answer to the question as I found Python complaining about the arguments being passed into the last __init__.</p>
<pre class="brush: python">
class Mother(object):
    def __init__(self, p_mother, **more):
        print "Mother", p_mother, more
        self.p_mother = p_mother
        super(Mother, self).__init__(p_mother=p_mother, **more)

    def hello(self):
        print "Hello %s" % self.p_mother

class Father(object):
    def __init__(self, p_father, **more):
        print "Father", p_father, more
        self.p_father = p_father
        super(Father, self).__init__()

    def world(self):
        print "World %s" % self.p_father

    def hello(self):
        print "Hello %s" % self.p_father

class Child(Mother, Father):
    def __init__(self, p_mother, p_father, **more):
        print "Child", p_father, p_mother, more
        super(Child, self).__init__(p_mother=p_mother, p_father=p_father,
                                    **more)

if __name__ == '__main__':
    c = Child("Mother", "Father")
    c.hello()
    c.world()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2011/10/26/python-super-and-multiple-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pynmea &#8211;  a Python NMEA Library</title>
		<link>http://blog.scaryclam.co.uk/2011/07/22/pynmea-a-python-nmea-library/</link>
		<comments>http://blog.scaryclam.co.uk/2011/07/22/pynmea-a-python-nmea-library/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 13:12:30 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Shameless self-promotion]]></category>
		<category><![CDATA[nmea]]></category>
		<category><![CDATA[pynmea]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=101</guid>
		<description><![CDATA[I quite like playing with GPS and found it a real pain dealing with all the different NMEA sentences individually. I couldn&#8217;t find a standalone, general purpose NMEA library for Python that I liked (there are other libraries out there, but you either seem to have to get a bunch of other stuff you don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I quite like playing with GPS and found it a real pain dealing with all the different NMEA sentences individually. I couldn&#8217;t find a standalone, general purpose NMEA library for Python that I liked (there are other libraries out there, but you either seem to have to get a bunch of other stuff you don&#8217;t want with them or they are more GPS specific than I would like).</p>
<p>So, I&#8217;ve decided to create one!</p>
<p>pynmea is a Python library for parsing NMEA sentences into more useful objects. In its current form, it uses mapping to &#8216;fill in&#8217; an otherwise generic object with the information contained within the sentence. It&#8217;s a very basic solution right now but when all of the mappings are entered (right now there are a limited number but it&#8217;s pretty strait forward to add the one you want in if it&#8217;s missing) it provides a single object for each sentence.</p>
<p>In the future, I would very much like the library to be able to take a data stream as an input and just churn out sentences as objects, doing all the splitting and parsing for the developer.</p>
<p>The project is currently on google code: <a href="http://code.google.com/p/pynmea/">http://code.google.com/p/pynmea/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2011/07/22/pynmea-a-python-nmea-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mounting an image file as a disk under Linux</title>
		<link>http://blog.scaryclam.co.uk/2011/07/12/mounting-an-image-file-as-a-disk-under-linux/</link>
		<comments>http://blog.scaryclam.co.uk/2011/07/12/mounting-an-image-file-as-a-disk-under-linux/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 11:48:32 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=96</guid>
		<description><![CDATA[Just thought I&#8217;d post this as I always fail to find a nice example via google when I want one $ losetup /dev/loop2 /path/to/image.img $ mount /dev/loop2 /mnt/path That&#8217;s it!]]></description>
			<content:encoded><![CDATA[<p>Just thought I&#8217;d post this as I always fail to find a nice example via google when I want one</p>
<p><code><br />
$ losetup /dev/loop2 /path/to/image.img<br />
$ mount /dev/loop2 /mnt/path<br />
</code></p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2011/07/12/mounting-an-image-file-as-a-disk-under-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KDE Menu Language gets stuck (and how to fix it)</title>
		<link>http://blog.scaryclam.co.uk/2011/05/18/kde-menu-language-gets-stuck-and-how-to-fix-it/</link>
		<comments>http://blog.scaryclam.co.uk/2011/05/18/kde-menu-language-gets-stuck-and-how-to-fix-it/#comments</comments>
		<pubDate>Wed, 18 May 2011 09:52:01 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=91</guid>
		<description><![CDATA[As a part of my work I was playing with some internationalisation and changed my system language to German. I don&#8217;t speak German. When it came time to set everything back into English I found that my menu and system items had not got the message and continued to display most of their strings in [...]]]></description>
			<content:encoded><![CDATA[<p>As a part of my work I was playing with some internationalisation and changed my system language to German. I don&#8217;t speak German. When it came time to set everything back into English I found that my menu and system items had not got the message and continued to display most of their strings in German. I couldn&#8217;t find any way of forcing the language back to English via the system settings (everything was already back to English) and removing the German language did nothing to help.</p>
<p>After much Googling I found someone stating that removing /var/tmp/kdecache-username resolved their problem. Sure enough renaming my kdecache-username directory reset a whole bunch of stuff but really messed up some of the system settings that I really wanted to keep. After some trial and error I found that just removing /var/tmp/kdecache-username/ksycoca* got rid of the lingering German language problems and allowed me to keep the rest of my desktop settings as they were.</p>
<p>I have no idea if this is a bug in KDE or if there&#8217;s an option to reset the caching that is responsible for this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2011/05/18/kde-menu-language-gets-stuck-and-how-to-fix-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Samsung N220 Netbook and Linux</title>
		<link>http://blog.scaryclam.co.uk/2010/04/20/samsung-n220-netbook-and-linux/</link>
		<comments>http://blog.scaryclam.co.uk/2010/04/20/samsung-n220-netbook-and-linux/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 21:25:08 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=63</guid>
		<description><![CDATA[Got my hands on a new Samsung N220 Netbook. It came with Windows 7 starter pre-installed which isn&#8217;t ideal and so I decided to see how well Linux would fare. For the initial experiment I downloaded Kubuntu (Karmic) and made a live USB install. After moving the USB boot option up in the bios (turn [...]]]></description>
			<content:encoded><![CDATA[<p>Got my hands on a new Samsung N220 Netbook. It came with Windows 7 starter pre-installed which isn&#8217;t ideal and so I decided to see how well Linux would fare. For the initial experiment I downloaded Kubuntu (Karmic) and made a live USB install. After moving the USB boot option up in the bios (turn on the Netbook and press F2), it booted up just fine and presented the normal KDE desktop.</p>
<p>Out of the box, this is what was working (or not):</p>
<ul>
<li>The trackpad and both mouse buttons behave as normal</li>
<li>Wireless: Not Working</li>
<li>Ethernet: Working</li>
<li>External monitor: Yes but only to the extent that an image was trying to show. My monitor was shredding the image and flickering. I should note that my monitor is a 24&#8243; widesceen monitor so it&#8217;s quite possible that this was an issue. Will update this if I test on a more sensible screen / projector.</li>
<li>Graphics are using VGA, will test more later as the Intel Pineview graphics chip looks like it&#8217;s supported in the xf86-video-intel 2.10.0 driver</li>
<li>Bluetooth: Working</li>
<li>Sound: Working</li>
<li>Microphone: Not working (tested using Skype)</li>
</ul>
<ul>
<li>Webcam: Working (tested using Skype)</li>
</ul>
<p>With this all in mind (no wireless) I decided not to wipe off Windows quite yet. I used the Windows partitioning tool to shrink down the C:\ drive partition so that I could make a dual boot system. I then installed Kubuntu and rebooted into the nice new system. After this I connected the Netbook to my wired network and got online.</p>
<h3>Getting Wireless working</h3>
<p>I tried out two methods for getting wireless to work. I should note here that even though I got the wireless card working with ndiswrapper, I would recommend skipping ahead to installing the Realtek RTL 8192E driver as it performs much better.</p>
<h4>NDiswrapper</h4>
<p>I installed ndiswrapper and retrieved the RealTek wireless drivers from the Samsung website. After doing this the installation of the drivers was very straight forward. I found that I could find the local networks in the area but had lots of trouble connecting to my router, which is one of the better wireless routers on the market.</p>
<h4>Realtek RTL 8192E Wireless driver</h4>
<p>As there were issues with ndiswrapper, I carried on searching and came across <a href="http://moss.csc.ncsu.edu/~mueller/samsung-n510.html">this page</a>. The part of the page that is of interest is:</p>
<p><code><br />
#wireless<br />
#Realtek RTL 8192E Wireless LAN 802.11n PCI-E NIC<br />
wget http://www.dirk-hoeschen.de/temp/rtl819Xe.tar.gz<br />
tar xzf rtl819Xe.tar.gz<br />
./install.sh<br />
#modprobe r8192_pci<br />
iwconfig<br />
</code></p>
<p>These commands (with the exception of the lines starting with a # character) should typed at the command line.</p>
<p>I did not have to run the final two lines as KDE kindly informed me that my wireless card had been found just after I ran ./install.sh. I&#8217;m not actually sure why as I didn&#8217;t run the command as root so YMMV. With this driver the signal from all networks was noticeably higher than it was when using ndiswrapper and connection to my home router was quick and without issue. All in all a very happy result!</p>
<h4>Wireless update</h4>
<p>I&#8217;ve seen that some people who are installing Lucid are reporting that the Lucid kernel now has support for RTL8192E wireless devices. If you are planning on installing Linux on the Samsung N220 then I would highly recommend using a live distribution and finding out if wireless is enabled out of the box. This will save you the trouble of installing the above driver.</p>
<p>I can also report that after allowing Kubuntu to upgrade to either Lucid or Meerkat (I cannot remember right now and don&#8217;t have my netbook on me to verify which I upgraded to) wireless continues to work. I have no installed from scratch but at least upgrading did not break it!</p>
<h2>Backlight Issues</h2>
<p>Since getting the netbook I was not able to change the backlight setting. This meant that I was working with a dimmed screen. I finally got around to fixing this issue and I now have functioning brightness keys.</p>
<p>The solution that has worked for me was to install the samsung-backlight driver. I did this by adding the PPA to my sources list and installing the driver by executing the following commands:</p>
<p><code><br />
sudo apt-add-repository ppa:voria/ppa<br />
sudo aptitude update<br />
sudo aptitude install samsung-backlight</code></p>
<p>The driver was successfully installed and after a reboot to check and see if the driver would automatically get loaded on boot I wasn&#8217;t disappointed to see that I was able to use the brightness keys as normal.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2010/04/20/samsung-n220-netbook-and-linux/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Congratulations LHC!</title>
		<link>http://blog.scaryclam.co.uk/2010/03/30/congratulations-lhc/</link>
		<comments>http://blog.scaryclam.co.uk/2010/03/30/congratulations-lhc/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 11:44:14 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=61</guid>
		<description><![CDATA[Congratulations to the LHC for making history today. Fingers crossed they&#8217;ll find what they&#8217;re looking for (and lots of things that they weren&#8217;t)! Exciting stuff, even for us non-physics bods!]]></description>
			<content:encoded><![CDATA[<p>Congratulations to the LHC for making history today. Fingers crossed they&#8217;ll find what they&#8217;re looking for (and lots of things that they weren&#8217;t)!</p>
<p>Exciting stuff, even for us non-physics bods!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2010/03/30/congratulations-lhc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python plasmoids</title>
		<link>http://blog.scaryclam.co.uk/2010/03/15/python-plasmoids/</link>
		<comments>http://blog.scaryclam.co.uk/2010/03/15/python-plasmoids/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 20:00:27 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=47</guid>
		<description><![CDATA[I recently upgraded to Kubuntu Karmic and since it&#8217;s so shiny (I&#8217;m a sucker for a bit of eye candy&#8230;so long as it doesn&#8217;t get in my way) I decided to try my hand at making a widget. Now, I&#8217;ve tinkered with this before and made a widget that gets a fortune but that was [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded to Kubuntu Karmic and since it&#8217;s so shiny (I&#8217;m a sucker for a bit of eye candy&#8230;so long as it doesn&#8217;t get in my way) I decided to try my hand at making a widget. Now, I&#8217;ve tinkered with this before and made a widget that gets a <a title="Fortune man page" href="http://linux.die.net/man/6/fortune">fortune</a> but that was simple. I want something a bit more complicated. Since I&#8217;ve also recently found the python-twitter API it seemed quite a nice little project (yes I&#8217;m aware it&#8217;s been done before).</p>
<p><a title="KDE Techbase" href="http://techbase.kde.org">KDE TechBase</a> provides some good starting documentation but I had a lot of trouble with just getting a simple data engine set up, installed and a plasmoid that could connect to it. The documentation does a nice job of telling you how to make a data engine, how to make a widget but then gave an over complicated example of how to use to use the two together. So here is the result of some of my trial and error in this simple task&#8230;</p>
<p>Let&#8217;s start with the data engine.</p>
<pre class="brush: python">

from PyQt4.QtCore import *
from PyKDE4.kdecore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
import twitter

class PyTwitterData(plasmascript.DataEngine):
    def __init__(self,parent,args=None):
        plasmascript.DataEngine.__init__(self,parent)

    # Set up the initial stuff. self.source_dict is just something I was trying out. Read the note
    # in updateSourceEvent
    def init(self):
        self.source_dict = {'username':'password'}
        # Minimum polling interval is in milliseconds
        self.setMinimumPollingInterval(30000)

    # Return the available sources
    def sources(self):
        sources = ['username']
        return sources

    # This gets called when the data engine has new data or when polled
    def sourceRequestEvent(self, name):
        return self.updateSourceEvent(name)

    def updateSourceEvent(self, source):
        # username and password of the required user. Note that the original idea was to allow
        # the use of a dictionary to store the username and password but for some reason it
        # wasn't storing it properly so you may have to just replace this to use your normal
        # username and password here.
        twitter_username = source
        twitter_password = self.source_dict.get(str(source), 'default_password')

        # Twitter API things. This just makes a twitter API object that gets you own status
        api_base = twitter.Api(username=twitter_username,
                               password=twitter_password)
        my_status = api_base.GetUser('username').GetStatus().GetText()

        # Set the in the 'Status' key of source (username) to the status string
        self.setData(source, 'Status', my_status)
        # As far as I know this always returns true so return True!
        return True

# Create and return the data engine object
def CreateDataEngine(parent):
    return PyTwitterData(parent)
</pre>
<p>If you&#8217;ve read the KDE TechBase documentation you&#8217;ll know that this code is meant to go in a file named main.py. The directory structure for the data engine is as follows:<br />
.<br />
| &#8212; contents<br />
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211; code<br />
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&#8211; main.py<br />
| &#8212; metadata.desktop<br />
` &#8212; twitterdataengine.zip</p>
<p>As stated, the code above goes in the main.py file. The metadata.desktop file is important and contains all of the information required to install this data engine. Mine looks like the following:</p>
<p>
[Desktop Entry]<br />
Encoding=UTF-8<br />
Name=twitterdataengine<br />
Type=Service<br />
ServiceTypes=Plasma/DataEngine<br />
X-Plasma-API=python<br />
X-Plasma-MainScript=code/main.py<br />
X-KDE-PluginInfo-Author=ScaryClam<br />
X-KDE-PluginInfo-Email=twitterdataengine@scaryclam.co.uk<br />
X-KDE-PluginInfo-Name=twitterdataengine<br />
X-KDE-PluginInfo-Version=1.0<br />
X-KDE-PluginInfo-Website=http://plasma.kde.org/<br />
X-KDE-PluginInfo-Category=Examples<br />
X-KDE-PluginInfo-Depends=<br />
X-KDE-PluginInfo-License=GPL<br />
X-KDE-PluginInfo-EnabledByDefault=true
</p>
<p>When the main.py and metadata.desktop file are complete, the contents need zipping. From the base directory for this dataengine run:<br />
$ zip -r twitterdataengine.zip *<br />
Which should zip the entire directory structure into a file named twitterdataengine.zip.</p>
<p>Installing the data engine required the command:<br />
$ plasmapkg -t dataengine -i twitterdataengine.zip</p>
<p>As a side note, removing the data engine also requires the -t dataengine option, obvious when you know but a pain when you&#8217;re not thinking and leave it out.</p>
<p>OK, if everything went smoothly the data engine is now installed and ready to be used. A nice little utility for examining data engine is plasmaengine which allows you to have a look at the different engines available and their current sources/values.</p>
<p>Now for the plasmoid to make use of the data engine!</p>
<pre class="brush: python">
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript

class TwitterClient(plasmascript.Applet):
    def __init__(self,parent,args=None):
        plasmascript.Applet.__init__(self,parent)

    def init(self):
        # Make a widget, 300x300, no configuration (to keep this simple) and
        # connect to the data engine
        self.setHasConfigurationInterface(False)
        self.resize(300, 300)
        self.setAspectRatioMode(Plasma.Square)
        self.status_text = 'No Status set!'
        self.connectToEngine()

    def paintInterface(self, painter, option, rect):
        # This will just print the status text into an otherwise blank widget
        painter.save()
        painter.setPen(Qt.white)
        painter.drawText(rect, Qt.AlignVCenter | Qt.AlignHCenter,
                         self.status_text)
        painter.restore()

    def connectToEngine(self):
        # Connect to the source "username" in the twitterdataengine data engine,
        # every 30000 milliseconds (30 seconds)
        self.twitterEngine = self.dataEngine("twitterdataengine")
        self.twitterEngine.connectSource('username', self, 30000)

    # This will get called when polled
    @pyqtSignature("dataUpdated(const QString &#038;, const Plasma::DataEngine::Data &#038;)")
    def dataUpdated(self, sourceName, data):
        # data contains all of the data from the source requested. In this case
        # it just has one key: "Status"
        status = data[QString("Status")]
        self.status_text = status
        self.update()

def CreateApplet(parent):
    # Create applet
    return TwitterClient(parent)
</pre>
<p>Again, this should go into the main.py file and the directory structure is:<br />
.<br />
| &#8212; contents<br />
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211; code<br />
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&#8211; main.py<br />
| &#8212; metadata.desktop<br />
` &#8212; twitterclient.zip</p>
<p>The metadata.desktop file is:<br />
[Desktop Entry]<br />
Encoding=UTF-8<br />
Name=TwitterClient<br />
Type=Service<br />
ServiceTypes=Plasma/Applet<br />
Icon=games-hint<br />
X-Plasma-API=python<br />
X-Plasma-MainScript=code/main.py<br />
X-KDE-PluginInfo-Author=ScaryClam<br />
X-KDE-PluginInfo-Email=twitterclient@scaryclam.co.uk<br />
X-KDE-PluginInfo-Name=twitter_client<br />
X-KDE-PluginInfo-Version=1.0<br />
X-KDE-PluginInfo-Website=http://plasma.kde.org/<br />
X-KDE-PluginInfo-Category=Examples<br />
X-KDE-PluginInfo-Depends=<br />
X-KDE-PluginInfo-License=GPL<br />
X-KDE-PluginInfo-EnabledByDefault=true</p>
<p>Zip up the directory contents (in the same way as the data engine) and then install using:</p>
<p>$ plasmapkg -i twitter_client.zip</p>
<p>If successful, the installed plasmoid can be seen by using the plasmoidviewer utility:</p>
<p>$ plasmoidviewer twitter_client</p>
<p>Hopefully there is now a widget showing the status text of the twitter user entered.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2010/03/15/python-plasmoids/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Python, DeviceKit and Partitioning</title>
		<link>http://blog.scaryclam.co.uk/2010/02/26/python-devicekit-and-partitioning/</link>
		<comments>http://blog.scaryclam.co.uk/2010/02/26/python-devicekit-and-partitioning/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 13:41:52 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=22</guid>
		<description><![CDATA[Lately I&#8217;ve been using DeviceKit via DBus in Python as part of my work. The DeviceKit documentation is actually pretty good but I have found that it lacks examples. I&#8217;ve had trouble finding much via Google either so I thought it might be nice to post up some short blog articles as I find things [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been using DeviceKit via DBus in Python as part of my work. The DeviceKit documentation is actually pretty good but I have found that it lacks examples. I&#8217;ve had trouble finding much via Google either so I thought it might be nice to post up some short blog articles as I find things out.</p>
<p>I have a need to be able to partition USB compact flash cards and here&#8217;s an example that works for me, broken up so I can give some explanation as I go:</p>
<pre class="brush: python">
import dbus

bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.DeviceKit.Disks', '/org/freedesktop/DeviceKit/Disks')
iface = dbus.Interface(proxy, "org.freedesktop.DeviceKit.Disks")

cur_dev = bus.get_object('org.freedesktop.DeviceKit.Disks', '/org/freedesktop/DeviceKit/Disks/devices/sdb')
device_int = dbus.Interface(cur_dev, 'org.freedesktop.DeviceKit.Disks.Device')
</pre>
<p>Lines 3, 4 and 5 are getting and interface to DeviceKit from DBus. Lines 4 and 5 may not be necessary but are useful to have if you don&#8217;t know the device name yet and wan tot enumerate through the devices and see what&#8217;s there.<br  \><br />
Lines 7 and 8 are getting an interface to a specific device, which in this case is a USB card reader on /dev/sdb. I have a 1Gig SanDisk compact flash card, without any partitions, plugged into the card reader.<br \><br />
Now that there is a device interface, I can start using it to partition that card:</p>
<pre class="brush: python">
device_int.PartitionTableCreate('none', [])
device_int.PartitionTableCreate('mbr', [])
device_int.PartitionCreate(0, 1019215872, '06', '', [], [], 'vfat', [])
</pre>
<p>device_int.PartitionTableCreate() can take 2 arguments: scheme and options. For more information on the schemes and options allowed see <a href="http://hal.freedesktop.org/docs/DeviceKit-disks/Device.html#Device.PartitionTableCreate">this page</a> as it does a better job than I will at explaining. Here I&#8217;ve opted, mainly to just help with the example, to call it twice; once with &#8216;none&#8217; as the scheme and once with &#8216;mbr&#8217;. The &#8216;none&#8217; scheme will clear anything that happened to be there before and &#8216;mbr&#8217; sets up the master boot record at the start of the disk.<br />
Line 3 shows an actual partition being created. The arguments are as follows: offset, size, type, label, flags, options, fstype, fsoptions). The above makes a FAT32 partition, just shy of 1Gig in size.<br \><br />
Normally this would be the end as the partition has been created. However, if you wan to removed partitions the following may be helpful:</p>
<pre class="brush: python">
cur_dev = bus.get_object('org.freedesktop.DeviceKit.Disks', '/org/freedesktop/DeviceKit/Disks/devices/sdb1')
sdb1_dev = dbus.Interface(cur_dev, 'org.freedesktop.DeviceKit.Disks.Device')
sdb1_dev.PartitionDelete('')
</pre>
<p>Line 1 gets an interface to the device /dev/sdb1, which is the partition that I have just created and wish to delete. As before, an interface is required to work on the device. Line 2 retrieves one.<br \><br />
Finally the delete is preformed using PartitionDelete(). The disk should now have no partitions.</p>
<p>
I&#8217;ve only just started using DeviceKit so apologies for missing things or getting things wrong. I&#8217;d more than welcome any corrections and tips!<br \><br />
There&#8217;s lots of information on DeviceKit Devices which can be found <a href="http://hal.freedesktop.org/docs/DeviceKit-disks/Device.html">here</a> and I would recommend it as reading for anyone who needs to work with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2010/02/26/python-devicekit-and-partitioning/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Now powered by WordPress!</title>
		<link>http://blog.scaryclam.co.uk/2010/02/24/now-powered-by-wordpress/</link>
		<comments>http://blog.scaryclam.co.uk/2010/02/24/now-powered-by-wordpress/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 18:59:09 +0000</pubDate>
		<dc:creator>scaryclam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.scaryclam.co.uk/?p=20</guid>
		<description><![CDATA[I&#8217;ve installed WordPress and decided to move the site onto it. While I love messing around with web technologies I never get around to finishing things and this way I get to have a shiny web site while still having room to play! Last night I tried out WordPress, Drupal and Joomla. Joomla suggested I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve installed WordPress and decided to move the site onto it. While I love messing around with web technologies I never get around to finishing things and this way I get to have a shiny web site while still having room to play!</p>
<p>Last night I tried out WordPress, Drupal and Joomla. Joomla suggested I install a bunch of example data, which I did. While I appreciate that this could be useful for beginners, I spent more time cleaning up the mess than it would haven taken to read through a tutorial on how to get started.</p>
<p>Drupal looks like it&#8217;ll be a great resource but it also lives up to its reputation of having a bit of a learning curve. Perhaps in the future I&#8217;ll come back to this one but for now I just want something quick and easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scaryclam.co.uk/2010/02/24/now-powered-by-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

