<?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>logIt &#187; python</title>
	<atom:link href="https://lakm.us/logit/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Nebri Automation for Weather Feed to Twitter</title>
		<link>https://lakm.us/logit/2015/06/nebri-automation-weather-feed-twitter/</link>
		<comments>https://lakm.us/logit/2015/06/nebri-automation-weather-feed-twitter/#comments</comments>
		<pubDate>Tue, 02 Jun 2015 14:13:39 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[job automation]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[socialmedia]]></category>
		<category><![CDATA[wearable]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=842</guid>
		<description><![CDATA[The season was intermittently rainy or dry as I began to take interest in weather. After getting stuck with “If-this-than-that” (IFTTT) for multiple location feeds of weather, I found out that I wasn&#8217;t alone, a geek hit the same wall, yet bringing another automation forgery: Nebri OS, an event-driven development platform based-on writing rules in [...]]]></description>
				<content:encoded><![CDATA[<p>The season was intermittently rainy or dry as I began to take interest in weather. After getting stuck with <a href="https://ifttt.com/" title="IFTTT" target="_blank">“If-this-than-that” (IFTTT)</a> for multiple location feeds of weather, I found out that I wasn&#8217;t alone, a geek hit the same wall, yet bringing another automation forgery: <a href="https://nebrios.com/" title="Nebri: Event-driven development platform" target="_blank">Nebri OS</a>, an event-driven development platform based-on writing rules in <a href="https://www.python.org/" title="Python" target="_blank">Python</a>. Without despise, eventually I still use IFTTT on the other end to send weather alert to my smartwatch <a href="../../../2015/01/commuter-train-trouble-alert-delivered-watch-ifttt/" title="Get Commuter Train Trouble Alert Delivered to Watch by IFTTT" target="_blank">again</a>.</p>
<p>A quick adaptation of <a href="https://nebrios.com/blog/weather-alerts-in-multiple-locations" title="Weather Alerts In Multiple Locations" target="_blank">Nebri&#8217;s straightforward blog post</a> is to first shortlist rain related codes into <a href="https://github.com/bandono/nebri/blob/master/tweet_rain/README.md" title="README.md" target="_blank">15 of them</a> and changing from forecast to latest measurement instead. Bridging Nebri and <a href="http://www.cookoo2.com/" title="COOKOO 2" target="_blank">my smartwatch</a> are <a href="https://twitter.com/" title="Twitter" target="_blank">Twitter</a> and <a href="https://ifttt.com/recipes/296352-bogor-jakarta-rain-weather-alert" title="Bogor-Jakarta rain weather alert " target="_blank">IFTTT recipe</a>–the watch merely mirrored my phone, you don&#8217;t need it actually. Why (again) Twitter? Well, rather than the &#8220;then that&#8221; side–the watch enabler, the &#8220;if this&#8221; side of IFTTT for Twitter recipes is quite powerful given so many tweet filtering options.</p>
<p><div class="wp-caption aligncenter" style="width: 460px"><img alt="Nebri OS workflow from YWeather to Twitter" src="../../../../images/nebrios-event-driven-workflow-illustration.png" title="Nebri OS workflow from YWeather to Twitter" width="320" height="262" /><p class="wp-caption-text">Key-value pairs as trigger for event driven Nebri OS workflow</p></div><br />
<span id="more-842"></span><br />
The workflow starts with Drips, a scheduler (<code>cron</code>) where key value-pairs (KVP) is created at certain time. A rule script (<code>yweather</code>) is triggered when this KVP is created. The weather results are sets of later KVPs feeding the <code>twitter</code> rule script where our simple Nebri workflow ends. This is how I get multiple cities, by using different Drips, different events, running the same workflow. Both <code>yweather</code> and <code>twitter</code> scripts are also example of API connectivity to Nebri.</p>
<p>Many things already taken care by Nebri, hence unseasoned programmer should easily cope with writing simple Python rule and focus on the automation, nevertheless complex rule should also be accommodated. I was having trouble on using previous KVP from different PID though–moved them to comment in the script, but they seem to be <a href="https://nebrios.com/blog/releases-2689" title="Releases 2689" target="_blank">working on it</a>. Check their <a href="https://nebrios.com/blog/weather-alerts-in-multiple-locations" title="Weather Alerts In Multiple Locations" target="_blank">YWeather blog post</a> on how the basics work and compare <a href="https://github.com/bandono/nebri/tree/master/tweet_rain" title="Nebri: tweet rain Github" target="_blank">what I did in Github</a>. I embed an example tweet from <a href="https://twitter.com/twithujan" title="@twithujan" target="_blank">@twithujan</a> below. <a href="https://weather.yahoo.com/" title="Yahoo! Weather" target="_blank">Yahoo! Weather</a> frequency of measurement and accuracy are of different topic by the way.</p>
<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">Bogor is Light Rain with temperature at 23 °C. Taken at Thu, 28 May 2015 7:00 pm WIT</p>
<p>&mdash; Twit Hujan (@twithujan) <a href="https://twitter.com/twithujan/status/603908598314434560">May 28, 2015</a></p></blockquote>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>PS: &#8220;<em>hujan</em>&#8221; means &#8220;rain&#8221; in Indonesian</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2015/06/nebri-automation-weather-feed-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Any m-by-n Matrix Keypad for Raspberry Pi</title>
		<link>https://lakm.us/logit/2014/02/any-m-x-n-matrix-keypad-raspberry-pi/</link>
		<comments>https://lakm.us/logit/2014/02/any-m-x-n-matrix-keypad-raspberry-pi/#comments</comments>
		<pubDate>Sat, 08 Feb 2014 18:30:57 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[GPIO]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=746</guid>
		<description><![CDATA[What about instantiating any m x n matrix keypad by a Python class? Raspberry Pi takes me to learn how to build a Python class for the first time while expanding my initial WiringPi-based matrix keypad into a derivative work. A matrix keypad instance is defined by: Actual GPIO pins used forming the row and [...]]]></description>
				<content:encoded><![CDATA[<p>What about instantiating any m x n matrix keypad by a <a href="http://docs.python.org/2/tutorial/classes.html" title="Python Classes" target="_blank">Python class</a>? <a href="http://www.raspberrypi.org/" target="_blank">Raspberry Pi</a> takes me to learn how to build a Python class for the first time while expanding my initial <a href="../../2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/" title="Raspberry Pi: Membrane (Matrix) Keypad as GPIO Input" target="_blank">WiringPi-based matrix keypad</a> into a derivative work.</p>
<p>A matrix keypad instance is defined by:</p>
<ol>
<li>Actual GPIO pins used forming the row and column of the m x n matrix</li>
<li>Individual character in-use as symbol for each button</li>
</ol>
<p>Hence, I instantiate and call method like</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">...
<span style="color: black;">QPad</span>  = matrixQPi<span style="color: black;">&#40;</span>keyPad=keyPad,row=row,col=col<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> QPad.<span style="color: black;">scanQ</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>to print the character being pressed. Some examples pushed to <a href="https://github.com/bandono/matrixQPi/tree/v2.0" title="Github: matrixQPi v2.0" target="_blank">my github</a> explains how the above <code>keyPad</code>, <code>row</code>, and <code>col</code> are defined to scan-read pressed button of 2&#215;2, 2&#215;3, and 4&#215;3 matrix keypads <time datetime="2014-02-23">(or have it 3&#215;4 matrix keypads in other words)</time>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols &#038; GPIO combinations" src="../../../../images/any-mxn-matrix-keypad-raspberry-pi.png" title="Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols &#038; GPIO combinations" width="368" height="264" /><p class="wp-caption-text">Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols &#038; GPIO combinations</p></div>
<p>I used deprecated <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">Wiring-Pi Python</a> (they already moved to <a href="https://github.com/WiringPi/WiringPi2-Python" title="WiringPi2-Python" target="_blank">2.x version</a>) without problem. However, you&#8217;ll fail building from latest commit and must use combination of older commits as described by my updated part of <a href="../../2013/03/raspberry-pi-gpio-input-button-basics-1/" title="Raspberry Pi GPIO Input Button Basics" target="_blank">an old-post</a>. By the way, there&#8217;s I/O expander support for <a href="https://github.com/WiringPi/WiringPi2-Python" title="WiringPi2-Python" target="_blank">WiringPi2-Python</a> which is good, considering:</p>
<blockquote><p>GPIO is expensive and for the sake of a keypad, you should not spend all.</p></blockquote>
<p>(A friend told me that once)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2014/02/any-m-x-n-matrix-keypad-raspberry-pi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi: Membrane (Matrix) Keypad as GPIO Input</title>
		<link>https://lakm.us/logit/2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/</link>
		<comments>https://lakm.us/logit/2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 08:55:13 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[GPIO]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=533</guid>
		<description><![CDATA[Membrane matrix keypad using GPIO as Raspberry Pi input has been my goal since WiringPi deployed in the first place. To begin with, GPIO hacking was initially started with some important basics (see previous post). Without external system (other interfacing chip), the 3&#215;4 membrane keypad reserved all seven GPIO pins plus one pin used for [...]]]></description>
				<content:encoded><![CDATA[<p>Membrane matrix keypad using GPIO as <a href="http://www.raspberrypi.org" target="_blank">Raspberry Pi</a> input has been my goal since <em><a href="https://projects.drogon.net/raspberry-pi/wiringpi/" target="_blank">WiringPi</a></em> deployed in the first place. To begin with, GPIO hacking was initially started with some important basics (see <a href="./2013/03/raspberry-pi-gpio-input-button-basics-1/" target="_blank">previous post</a>). Without external system (other interfacing chip), the <a href="http://www.adafruit.com/products/419" title="Similar product from Adafruit: Membrane Matrix Keypad 3x4" target="_blank">3&#215;4 membrane keypa</a>d reserved all seven GPIO pins plus one pin used for LED indicating successful reading of pressed key.</p>
<p><time datetime="2014-02-09"><br />
<blockquote style="background-color:lightyellow;"><strong><em>Updated:</em></strong> for those who fail to build using <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">deprecated WiringPi-Python</a>, check <a href="../../2013/03/raspberry-pi-gpio-input-button-basics-1/" title="Raspberry Pi GPIO Input Button Basics" target="_blank">this updated post</a> to know which commit that build without error. There is now also <a href="../../2014/02/any-m-x-n-matrix-keypad-raspberry-pi/" title="Any m-by-n Matrix Keypad for Raspberry Pi" target="_blank">a Python class for matrix keypad</a>.</p></blockquote>
<p></time></p>
<p>My idea of having the keypad is to make alternative input available under no keyboard presence nor shell access. List of things I can think of for instances, pressed key &#8220;0&#8243; will make the Raspberry Pi (RPi) dial GPRS to a specific ISP and act as router to the USB WiFi stick, pressed key &#8220;7&#8243; will convert it to a router that will bridge the ethernet to WiFi, etc. In short, those key readings will invoke subsequent scripts to run inside RPi.</p>
<p>The physical connection schematic drawings and code are gitified (visit <a href="https://github.com/bandono/matrixQPi/tree/v1.2" title="gitHub: matrixQPi v1.2" target="_blank">v1.2 of the project on gitHub</a>). A nice animated image on how the buttons connect pins forming a matrix can be found in <a href="http://www.hackyourmind.org/blog/rpi-hw-interfacing-the-raspberry-pi-with-matrix-keypad/" target="_blank">hackyourmind.org</a>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a href="http://www.flickr.com/photos/aqila_rifti/8541074196/" title="Raspberry #Pi membrane (matrix) keypad. Longer hours with the circuitry in fear of bricking it. The code took half day of work instead by aqila_rifti, on Flickr"><img src="http://farm9.staticflickr.com/8375/8541074196_a22dccbd2a.jpg" width="310" height="310" alt="Raspberry #Pi membrane (matrix) keypad. Longer hours with the circuitry in fear of bricking it. The code took half day of work instead"></a> <p class="wp-caption-text">Matrix keypad: alternative quick input for Raspberry Pi to start certain command</p></div>
<p>Some remarks over what the code does:<br />
<span id="more-533"></span></p>
<ul>
<li>It only read one pressed key at a time.</li>
<li>It uses no interrupt. To read input it must wait and scan (this waiting experience is by far negligible to human sense).</li>
<li>Debouncing doesn&#8217;t seem necessary as <em>WiringPi</em> already provided this by software (I suppose <a href="https://github.com/WiringPi/WiringPi/blob/master/examples/wfi.c" title="WiringPi: wfi.c" target="_blank">this timing method on their gitHub</a> deals with debounce).</li>
</ul>
<p>How it works? <a href="http://www.raspberrypi.org/phpBB3/viewtopic.php?t=30376&#038;p=291617" title="RPi Forum: Membrane Keypad Circuit Help" target="_blank">RPi forum thread</a> gives a general idea that applies in my case:</p>
<ol>
<li>Divide the 3&#215;4 matrix as columns and rows. 4 GPIO pins as rows are pulled-up with 10k resistors and initialized as input.</li>
<li>Other 3 GPIO pins as columns are initialized as output low.</li>
<li>First loop will scan for one pressed key being read as one of the rows pulled-low</li>
<li>After the loop breaks, all columns are set as input, then the row pin found in the loop is set as output-high</li>
<li>Second loop will scan for column being pulled-high by that row pin. Between both loops, it is assumed that the key press is still in effect. In reality, normal human act of pressing this key elapses long enough for the software to run the scans in two loops.</li>
<li>Bingo! The code reads row-column combination of the pressed key.</li>
</ol>
<p>Example of the code&#8217;s output by calling from shell:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>matrixQPi.py -i; <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000;">3</span>
<span style="color: #000000;">6</span>
<span style="color: #000000;">9</span>
<span style="color: #000000;">8</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>(In the above example <code>^C</code> will throw Python <code>KeyboardInterrupt</code> messages before  breaking the <code>bash</code> loop)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi GPIO Input Button Basics</title>
		<link>https://lakm.us/logit/2013/03/raspberry-pi-gpio-input-button-basics-1/</link>
		<comments>https://lakm.us/logit/2013/03/raspberry-pi-gpio-input-button-basics-1/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 02:57:58 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[GPIO]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=500</guid>
		<description><![CDATA[When you start hacking Raspberry Pi&#8217;s GPIO, first thing to keep in mind is the +3.3V CMOS logic level voltage despite the 5V supply. Secondly, read references about current limiting resistors (eLinux Wiki has a section there). What to avoid then? Try not to physically short the GPIO pin to ground when it is programmed [...]]]></description>
				<content:encoded><![CDATA[<p>When you start hacking Raspberry Pi&#8217;s GPIO, first thing to keep in mind is the +3.3V CMOS logic level voltage despite the 5V supply. Secondly, read references about current limiting resistors (eLinux Wiki has <a href="http://elinux.org/RPi_Tutorial_EGHS:Switch_Input" title="RPi_Tutorial_EGHS:Switch_Input" target="_blank">a section there</a>). What to avoid then? Try not to <strong>physically</strong> short the GPIO pin to ground when it is <strong>programmed</strong> as the opposite output-high.</p>
<p>GPIO pin logic state (meaning voltage) are both programmable and driven by physical-connection. I choose <em><a href="https://projects.drogon.net/raspberry-pi/wiringpi/" title="WiringPi" target="_blank">wiringPi</a></em> for practical reasons: availability of its <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">Python wrapper</a> and its simple syntax (glancing it at first sight). <strong>WiringPi</strong> has an option of using its own pin numbering to address it in the code instead of the original GPIO numbering (there are board revisions to watch for in some cases of usage, not mine). Every pin can be initialized as input or output.</p>
<p><time datetime="2014-02-08"><br />
<blockquote style="background-color:lightyellow;"><strong><em>Updated:</em></strong> <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">Wiring-Pi Python</a> is deprecated and moving to <a href="https://github.com/WiringPi/WiringPi2-Python" title="WiringPi2-Python" target="_blank">2.x version</a> that supports I/O expander. However, you can still find this combination of commits that will work and build without error message:</p>
<p>- main module: <a href="https://github.com/WiringPi/WiringPi-Python/tree/9c77bde53fb5fa6283268b4a529e47048f8a379d">WiringPi-Python@9c77bde</a><br />
- submodule: <a href="https://github.com/WiringPi/WiringPi/tree/89bbe97856407979fa75c4c793fabf4db839a0ee">WiringPi@89bbe97</a></p>
<p>(Check how to build on my <a href="https://github.com/bandono/matrixQPi/tree/v2.0" title="matrixQP v2.0" target="_blank">README</a>)</p></blockquote>
<p></time></p>
<p>Using an <a href="http://overseas.sanwa-meter.co.jp/items/detail.php?id=85" title="Sanwa Multimeter: DIY KIT-8D" target="_blank">analog multitester</a>, here are behavioral findings:</p>
<ul>
<li>GPIO pin voltage swings to high logic after reboot (the meter&#8217;s needle is rocking for a second or so). It is in low voltage afterward until being programmed or physically pulled-up.</li>
<li>Two pins, wiringPi pin 8 and 9, remain in high logic voltage after reboot. They are SDA0 and SCL0 to be used as an I²C, however they can be used to read button as well. (<a href="http://elinux.org/RPi_Low-level_peripherals" title="RPi low-level peripherals" target="_blank">eLinux Wiki</a>: &#8220;there are 1.8 k pulls up resistors on the board for these pins&#8221;)</li>
<li>I did short the high logic to ground accidentally, it invoked reboot. (I don&#8217;t know how many times or how long of this will brick the Raspberry Pi)</li>
</ul>
<p>Prior to trying the push-button switch, I didn&#8217;t have proper circuitry and working with wires as probes, prone to accident that was. I found an advice to insulate the +5V pin voltage so I could worry less.</p>
<div class="wp-caption aligncenter" style="width: 460px"><br />
<a href="http://www.flickr.com/photos/aqila_rifti/8440986498/" title="Raspbery Pi: Getting Started with GPIO Hack by aqila_rifti, on Flickr"><img src="http://farm9.staticflickr.com/8230/8440986498_5acd920148.jpg" width="300" height="300" alt="Raspbery Pi: Getting Started with GPIO Hack"></a><p class="wp-caption-text">Insulate the +5V pin of Raspberry Pi</p></div>
<p>A 10k pull-up resistor and a button are enough to test the following. Go to interactive Python shell and run line by line until the button push is read as low logic (GPIO7 in this example):</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># python</span>
Python 2.7.3rc2 <span style="color: black;">&#40;</span>default, May  <span style="color: #ff4500;">6</span> <span style="color: #ff4500;">2012</span>, <span style="color: #ff4500;">20</span>:02:<span style="color: #ff4500;">25</span><span style="color: black;">&#41;</span> 
<span style="color: black;">&#91;</span>GCC 4.6.3<span style="color: black;">&#93;</span> on linux2
Type <span style="color: #483d8b;">&quot;help&quot;</span>, <span style="color: #483d8b;">&quot;copyright&quot;</span>, <span style="color: #483d8b;">&quot;credits&quot;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #483d8b;">&quot;license&quot;</span> <span style="color: #ff7700;font-weight:bold;">for</span> more information.
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> wiringpi
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> INPUT=<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> OUTPUT=<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> HIGH=<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> LOW=<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> SETUP=wiringpi.<span style="color: black;">wiringPiSetup</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> SETUP
<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> wiringpi.<span style="color: black;">pinMode</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span>,INPUT<span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> RESULT=wiringpi.<span style="color: black;">digitalRead</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> RESULT
<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> RESULT=wiringpi.<span style="color: black;">digitalRead</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> RESULT
<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> RESULT=wiringpi.<span style="color: black;">digitalRead</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> RESULT
<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span></pre></div></div>

<p>These basics convince me to go ahead with my goal of having a <a href="http://www.adafruit.com/products/419" title="Adafruit: Membrane Matrix Keypad 3x4" target="_blank">membrane (matrix) keypad</a> as input for Raspberry Pi to run some script (see <a href="../../../2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/" title="Raspberry Pi: Membrane (Matrix) Keypad as GPIO Input" target="_blank">next post</a>).</p>
<p>(Check also <a href="./2013/03/raspberry-pi-common-usb-problems/" title="Raspberry Pi Common USB Problems" target="_blank">RPi common USB problems post</a>)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/raspberry-pi-gpio-input-button-basics-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>That Handy Tap Interface on Mac OSX</title>
		<link>https://lakm.us/logit/2013/01/handy-tap-interface-mac-osx/</link>
		<comments>https://lakm.us/logit/2013/01/handy-tap-interface-mac-osx/#comments</comments>
		<pubDate>Fri, 04 Jan 2013 09:04:46 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Moving to Mac]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=426</guid>
		<description><![CDATA[Ubuntu has been my desktop for some years. I&#8217;ve become so attached in a way that I no longer know how to work without. Then of course, the pain of moving to Mac is one foreseeable future. Unlike my usual repository where everything is on the table and for free, this one is a little [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.ubuntu.com/" title="Ubuntu" target="_blank">Ubuntu</a> has been my desktop for some years. I&#8217;ve become so attached in a way that I no longer know how to work without. Then of course, the pain of moving to <a href="http://www.apple.com/macbook-pro/" title="MacBook Pro" target="_blank">Mac</a> is one foreseeable future. Unlike my usual repository where everything is on the table and for free, this one is a little tougher to handle. Well, if I were to cut to the chase, <a href="./2009/02/startup-script-for-tap-interfaces/" title="Startup script for TAP interfaces" target="_blank">tap interface</a> for instance, was nowhere near to be found. My <a href="https://www.virtualbox.org/" title="VirtualBox" target="_blank">VirtualBox</a> depends a lot on these virtual networks as I&#8217;m used to try things out.</p>
<blockquote><p>
<em>..you’ll always have love-hate relationship with the tools you work with.. blindly turning yourself into devoted-fanatic is another thing..</em></p></blockquote>
<p>
<p>Enough bragging (let&#8217;s spare that). First we need to have <code>/dev/tap0</code>, <code>/dev/tap1</code>, etc., available using <a href="http://tuntaposx.sourceforge.net/" title="TunTap - SourceForge" target="_blank">TunTap</a> kernel extension.</p>
<p>I modify the small script from <a href="http://snakeoilresearch.com/blog_discussing_snake_oil_o/using_taptun_interfaces_in_.html" title="Using 'tap/tun' interfaces in Mac OS X with VirtualBox" target="_blank">this post</a> to have it available on background instead of keeping a shell open all the time:</p>
<p>I saved it as <code>/usr/local/bin/setup-tap1.py</code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
	<span style="color: #ff7700;font-weight:bold;">try</span>:
		file_path = <span style="color: #483d8b;">'/dev/tap1'</span>
		dev_file = <span style="color: #dc143c;">os</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>file_path, <span style="color: #dc143c;">os</span>.<span style="color: black;">O_RDWR</span><span style="color: black;">&#41;</span>
		interface = <span style="color: #483d8b;">'tap1'</span>
		<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
			<span style="color: #ff7700;font-weight:bold;">pass</span>
	<span style="color: #ff7700;font-weight:bold;">except</span>:
		<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;tap interface is closing&quot;</span>
		exit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">break</span></pre></td></tr></table></div>

<p>Let the shell takes care of putting it to background (daemon):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>setup-tap1.py <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<p>and there you have one working tap interface:</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="virtualbox-mac-osx-tap-interface.png" src="../../../../images/virtualbox-mac-osx-tap-interface.png" title="VirtualBox tap interface in Mac OSX Lion" width="438" height="249" /><p class="wp-caption-text">VirtualBox tap interface in Mac OSX Lion 10.7</p></div>
<p>[Moving-in would probably be easier if I started <code>life</code> with <code><a href="http://en.wikipedia.org/wiki/FreeBSD" title="FreeBSD" target="_blank">FreeBSD</a></code>. More posts to come]</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/01/handy-tap-interface-mac-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Alas my LinkedIn password is in the file! (Howto check compromised password)</title>
		<link>https://lakm.us/logit/2012/06/alas-linkedin-password-file-howto-check-compromised-password/</link>
		<comments>https://lakm.us/logit/2012/06/alas-linkedin-password-file-howto-check-compromised-password/#comments</comments>
		<pubDate>Tue, 12 Jun 2012 08:59:10 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Web Apps]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[socialmedia]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=393</guid>
		<description><![CDATA[When LinkedIn privacy breach was about to be revealed during Yuval Ne&#8217;eman workshop in Tel Aviv University, suddenly the timeline trends were that of friends, telling people to change LinkedIn password. Both were separate issues and of course the privacy breach was then subsided from people&#8217;s attention. To tell you the truth, as a secret [...]]]></description>
				<content:encoded><![CDATA[<p>When <a href="http://blog.skycure.com/2012/06/linkedout-linkedin-privacy-issue.html" title="LinkedOut - A LinkedIn Privacy Issue" target="_blank">LinkedIn privacy breach</a> was about to be revealed during Yuval Ne&#8217;eman workshop in Tel Aviv University, suddenly the timeline trends were that of friends, telling people to <a href="http://blog.linkedin.com/2012/06/06/linkedin-member-passwords-compromised/" title="LinkedIn Blog" target="_blank">change LinkedIn password</a>. Both were separate issues and of course the privacy breach was then subsided from people&#8217;s attention. To tell you the truth, as a secret admirer of conspiracy theory (whether I admit it or not), this coincident was just too perfectly timed. But, I&#8217;m also curious whether my password was among the stolen 6,458,020 (yes: 6,4 millions) uploaded by the hacker in hashed <a href="http://en.wikipedia.org/wiki/SHA-1" title="http://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1</a> without the user name.</p>
<div class="wp-caption alignnone" style="width: 460px"><a href="http://blog.skycure.com/2012/06/linkedout-linkedin-privacy-issue.html"><img alt="linkedin-uploading-contact-resized-skycure-dot-com.png" src="../../../../images/linkedin-uploading-contact-resized-skycure-dot-com.png" title="Snapshot of uploaded contact data from calendar (skycure.com)" width="420" height="197" /></a><p class="wp-caption-text">Snapshot of uploaded contact data from calendar (skycure.com)</p></div>
<p>There is not other way but to check my password against the <code>combo_not.txt</code> found via <a href="http://www.filestube.com/" title="Filestube.com" target="_blank">Filestube</a>. People already posted howto check this, the easiest way is doing <a href="http://news.ycombinator.com/item?id=4076768" title="Y Hacker News" target="_blank">a single line in the shell</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">printf</span> bandito <span style="color: #000000; font-weight: bold;">|</span> openssl sha1 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-c10-</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-f</span> - combo_not.txt
00000d40df69b72328229d2425714f40d7d9a7a3</pre></div></div>

<p>Bingo! a match there for the password &#8220;bandito&#8221; (I choose this randomly expecting some person out there is using it). Another way (for comparison as I&#8217;m no security expert) is by this short python script (slightly altered from <a href="http://wordpress.phobostechnology.com/?p=149" title="LinkedIn Passwords – Change them" target="_blank">Phobos Technology blog post</a>):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #483d8b;">&quot;&quot;&quot;
Save this file as linkedin_hash.py and ensure it's
in the same folder as combo_not.txt
Usage: python linkedin_hash.py hunter2
&quot;&quot;&quot;</span>
<span style="color: #ff7700;font-weight:bold;">from</span> hashlib <span style="color: #ff7700;font-weight:bold;">import</span> sha1
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
password = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
hsh = sha1<span style="color: black;">&#40;</span>password<span style="color: black;">&#41;</span>.<span style="color: black;">hexdigest</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;SHA-1: %s&quot;</span> <span style="color: #66cc66;">%</span> hsh
x = <span style="color: #ff4500;">0</span>
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'combo_not.txt'</span>,<span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> hsh == line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        x += <span style="color: #ff4500;">1</span>
    <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #483d8b;">&quot;00000&quot;</span> + hsh<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span>:<span style="color: black;">&#93;</span> == line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        x += <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Matching line: %s&quot;</span> <span style="color: #66cc66;">%</span> line
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Number of matches: %d&quot;</span> <span style="color: #66cc66;">%</span> x</pre></td></tr></table></div>

<p>My verdict is: <strong>my password is on the list</strong> and I&#8217;m considering a leap of faith from devoted conspiracy believer.</p>
<p>PS: I don&#8217;t find that &#8220;password&#8221; or &#8220;123456&#8243; as common passwords used by many people.<br />
PPS: A side story: Indonesians are found to be using weakest passwords (as <a href="http://bit.ly/JGECVM" title="Indonesia has weakest computer passwords: Researcher | The Jakarta Post">research over Yahoo ID revealed</a>)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/06/alas-linkedin-password-file-howto-check-compromised-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acknowledging Event: Zabbix Python API</title>
		<link>https://lakm.us/logit/2012/05/acknowledging-event-zabbix-python-api/</link>
		<comments>https://lakm.us/logit/2012/05/acknowledging-event-zabbix-python-api/#comments</comments>
		<pubDate>Mon, 14 May 2012 02:40:43 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Zabbix]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=388</guid>
		<description><![CDATA[Acknowledgement is one of the things that is provided by Zabbix API in its event section. We can make use of the methods get() and acknowledge() to automatically acknowledge an event. Digging through the attributes of those methods, the official doc doesn&#8217;t provide complete example to follow. Added with some luck, my search get me [...]]]></description>
				<content:encoded><![CDATA[<p>Acknowledgement is one of the things that is provided by <a href="http://www.zabbix.com/" title="Zabbix" target="_blank">Zabbix</a> API in its <a href="http://www.zabbix.com/documentation/1.8/api/event" title="Zabbix API 1.8: Event" target="_blank">event section</a>. We can make use of the methods <code>get()</code> and <code>acknowledge()</code> to automatically acknowledge an event. Digging through the attributes of those methods, the official doc doesn&#8217;t provide complete example to follow. Added with some luck, my search get me to have the following JSON RPC that works in <a href="http://www.zabbix.com/rn1.8.7.php" title="Zabbix 1.8.7 Release Announcement" target="_blank">Zabbix 1.8.7</a> using <a href="https://github.com/gescheit/scripts" title="Gescheit github" target="_blank">Gescheit API implementation</a> written in Python. </p>
<p>When the goal is to acknowledge a specific event, the JSON call is however limited to some basic responses. It means that you can&#8217;t query a single RPC request for i.e. the following combination: <em>list of acknowledged events <strong>with</strong> &#8220;problem&#8221; status <strong>and</strong> trigger ID 500</em> (500 is merely an example).</p>
<p>However, combination in a single request do exist i.e. I&#8217;ve tried: <em>list of acknowledged events <strong>with</strong> &#8220;problem&#8221; status</em> as the following GET request:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
<span style="color: #3366CC;">&quot;params&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;acknowledged&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;jsonrpc&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2.0&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;event.get&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;auth&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;some-hash-authentication&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span> some<span style="color: #339933;">-</span>RPC<span style="color: #339933;">-</span>sequence<span style="color: #339933;">-</span>integer
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><em>(Note: <code>value=1</code> means status is &#8220;problem&#8221;)</em></p>
<p>For the basic example above, find the script in <a href="https://github.com/bandono/scripts" title="forked Gescheit API github" target="_blank">my fork</a> of Gescheit API.</p>
<p>Back to our goal of acknowledging events, our API can make the following RPCs:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">ack_list=zapi.<span style="color: black;">event</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;acknowledged&quot;</span>:<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
problem_list=zapi.<span style="color: black;">event</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;value&quot;</span>:<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
event_trigger_list=zapi.<span style="color: black;">event</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;triggerids&quot;</span>:<span style="color: black;">&#91;</span>trigger_id<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Yes, they are three requests. We can then filter out a single event to be acknowledged by intersecting the three results. The first intersection is between <code>event_trigger_list</code>, <code>problem_list</code>, and <code>ack_list</code> as illustrated below:</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="problem-list-acknowledgement-intersection.jpg" src="../../../../images/problem-list-acknowledgement-intersection.jpg" title="Intersection of problem list, event list with specific trigger ID, and acknowledged event list" width="309" height="211" /><p class="wp-caption-text">Intersection of problem list, event list with specific trigger ID, and acknowledged event list</p></div>
<p>After we opt-out those intersections, we can then get the event with problem status and choose the latest event only to be acknowledged. Check the code on <a href="https://github.com/bandono/zabbix-custom-integration/blob/master/bin/api/zabbix_event_ack.py" title="zabbix_event_ack.py" target="_blank">my github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/05/acknowledging-event-zabbix-python-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python 2.6 in Red Hat 5</title>
		<link>https://lakm.us/logit/2012/05/python-2-6-red-hat-5/</link>
		<comments>https://lakm.us/logit/2012/05/python-2-6-red-hat-5/#comments</comments>
		<pubDate>Mon, 14 May 2012 02:39:46 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[repo]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=386</guid>
		<description><![CDATA[I need Gescheit Zabbix API implementation to run on RHEL5.2 Installing RPMs from Geekymedia seems to be the easiest. I only need the following to make it work: python26-2.6-geekymedia1.i386.rpm python26-libs-2.6-geekymedia1.i386.rpm]]></description>
				<content:encoded><![CDATA[<p>I need <a href="https://github.com/gescheit/scripts" title="Gescheit github" target="_blank">Gescheit Zabbix API implementation</a> to run on RHEL5.2</p>
<p>Installing RPMs from <a href="http://www.geekymedia.com/uncategorized/rhel5-centos5-rpms-for-python-2-5-and-2-6/" title="RHEL5/CentOS5 RPMs for Python 2.5 and 2.6" target="_blank">Geekymedia</a> seems to be the easiest. I only need the following to make it work: </p>
<ol>
<li>python26-2.6-geekymedia1.i386.rpm</li>
<li>python26-libs-2.6-geekymedia1.i386.rpm</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/05/python-2-6-red-hat-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Close Low Level Socket in Python</title>
		<link>https://lakm.us/logit/2012/02/close-level-socket-python/</link>
		<comments>https://lakm.us/logit/2012/02/close-level-socket-python/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 05:12:11 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[socket]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=390</guid>
		<description><![CDATA[Important to do in socket programming is to close the socket. Python.org says Close the socket. All future operations on the socket object will fail. The remote end will receive no more data (after queued data is flushed). Sockets are automatically closed when they are garbage-collected. I implemented this low level networking interface for a [...]]]></description>
				<content:encoded><![CDATA[<p>Important to do in socket programming is to close the socket. <a href="http://docs.python.org/library/socket.html" title="Python Doc: Low-level networking interface" target="_blank">Python.org</a> says</p>
<blockquote><p>Close the socket. All future operations on the socket object will fail. The remote end will receive no more data (after queued data is flushed). Sockets are automatically closed when they are garbage-collected.</p></blockquote>
<p>I implemented this low level networking interface for a server listening to remote command. The complete code can be found on <a href="https://github.com/bandono/zoom-camera-board/blob/2.2/server.py" title="Github: server.py" target="_blank">Github</a>, the following lines are just part to show when to close socket:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>43
44
45
46
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">        clientSocket,address =s.<span style="color: black;">accept</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        data = clientSocket.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1024</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Receive command:&quot;</span>+data
        clientSocket.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>What happened with the TCP state when the socket wasn&#8217;t closed: it stayed in <code>CLOSE_WAIT</code> state. The screenshot below shows a clip of the TCP conversation in <a href="http://www.wireshark.org/" title="www.wireshark.org/" target="_blank">Wireshark</a> sniff and the <code>netstat</code> output:</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="" src="../../../../images/python-tcp-socket-without-close-server-wait.jpg" title="python-tcp-socket-without-close-server-wait.jpg" width="420" height="297" /><p class="wp-caption-text">Listening port state of a socket server written in Python</p></div>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/02/close-level-socket-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hijri Calendar</title>
		<link>https://lakm.us/logit/2009/09/hijri-calendar/</link>
		<comments>https://lakm.us/logit/2009/09/hijri-calendar/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 07:29:53 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[install-deinstall]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://localhost/it/?p=86</guid>
		<description><![CDATA[Not succeding to find Hijri Calendar in Synaptic, I go for http://www.ojuba.org/wiki/hijra/. First, let Google translate does the job. Secondly, install this python applet. Inside hijra-0.1.18 run $ sudo python setup.py install It&#8217;d fail as it couldn&#8217;t find HijriApplet. Rename HijriApplet.py to HijriApplet to make it work. Now, it is in path (/usr/bin/) and can [...]]]></description>
				<content:encoded><![CDATA[<p>Not succeding to find Hijri Calendar in Synaptic, I go for <a title="http://www.ojuba.org/wiki/hijra" href="http://www.ojuba.org/wiki/hijra" target="_blank">http://www.ojuba.org/wiki/hijra/</a>. First, let Google translate does the job. Secondly, install this python applet.</p>
<p>Inside hijra-0.1.18 run <code>$ sudo python setup.py install</code></p>
<p>It&#8217;d fail as it couldn&#8217;t find <code>HijriApplet</code>. Rename <code>HijriApplet.py</code> to <code>HijriApplet</code> to make it work. Now, it is in path (<code>/usr/bin/</code>) and can be called by <code>HijriApplet</code> command. We can copy <code>hijra-autostart.desktop</code> description to i.e. <code>~/.gnome2/panel2.d/default/launchers</code> for shortcut launcher.</p>
<p><code>python-gnome2-extras</code> must be installed or else it&#8217;d fail to launch saying can&#8217;t find <code>egg.trayicon</code></p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2009/09/hijri-calendar/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
