<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for Magoo</title>
	
	<link>http://morgangoose.com/blog</link>
	<description>affiliated with the society of blog bloggables</description>
	<lastBuildDate>Tue, 25 Aug 2009 13:39:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForMagoo" /><feedburner:info uri="commentsformagoo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Comment on Logitech MX Revolution configuration by Morgan</title>
		<link>http://morgangoose.com/blog/2009/08/logitech-mx-revolution-configuration/comment-page-1/#comment-478</link>
		<dc:creator>Morgan</dc:creator>
		<pubDate>Tue, 25 Aug 2009 13:39:32 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/2009/08/logitech-mx-revolution-configuration/#comment-478</guid>
		<description>I'll have to check that out and see. I tend to not use that button (will have to remedy). On my nano though I use it as the middle click, since it also has the switch gearing for the middle wheel. But thats a different setup, and doesn't use btnx as I recall.</description>
		<content:encoded><![CDATA[<p>I&#8217;ll have to check that out and see. I tend to not use that button (will have to remedy). On my nano though I use it as the middle click, since it also has the switch gearing for the middle wheel. But thats a different setup, and doesn&#8217;t use btnx as I recall.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Logitech MX Revolution configuration by Samuel Huckins</title>
		<link>http://morgangoose.com/blog/2009/08/logitech-mx-revolution-configuration/comment-page-1/#comment-476</link>
		<dc:creator>Samuel Huckins</dc:creator>
		<pubDate>Tue, 25 Aug 2009 12:43:33 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/2009/08/logitech-mx-revolution-configuration/#comment-476</guid>
		<description>Oh these are sweet, thanks for posting the config! I had the thumb scroll wheel mapped to switch virtual desktops, but I like this much better.

Do you have any issues with the button right behind the main scroll wheel losing its config? By default it brings up help dialogs, and it seems I have to restart btnx on occasion to get it to remember a new mapping.</description>
		<content:encoded><![CDATA[<p>Oh these are sweet, thanks for posting the config! I had the thumb scroll wheel mapped to switch virtual desktops, but I like this much better.</p>
<p>Do you have any issues with the button right behind the main scroll wheel losing its config? By default it brings up help dialogs, and it seems I have to restart btnx on occasion to get it to remember a new mapping.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Decouple with kwargs by Morgan</title>
		<link>http://morgangoose.com/blog/2009/07/decouple-with-kwargs/comment-page-1/#comment-27</link>
		<dc:creator>Morgan</dc:creator>
		<pubDate>Fri, 24 Jul 2009 22:33:45 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/?p=45#comment-27</guid>
		<description>Thats good to know on the function line definition. It wasn't a case that came up in this instance, only because the thread_hosts is only run once. I don't see a need to run it more than once, but I'll probably implement it similar to how you've suggested, because I can't be sure that someone else won't want to run it twice, in one script.

I think the most helpful suggestion was on my modification of kwargs by rolling options into it. It got me thinking that the script user needn't have any interaction with the argument parser at all. Instead I will pass the thread_hosts function sys.argv, and let is deal with deciding what it need. The issue of changing kwargs still is present, but in this implementation its now hidden, and only crops up when the user wants to specify a kwarg that is already used in the optparse options.

End result looking something like this:
&lt;strong&gt;script.py&lt;/strong&gt;

&lt;code lang="python"&gt;
if __name__ == '__main__':
    import automation

    automation.thread_hosts(
            automation.process_args(sys.argv),
            get_commands,
            options,
            user="test"
            )
&lt;/code&gt;

&lt;strong&gt;automation.py&lt;/strong&gt;

&lt;code lang="python"&gt;
def thread_hosts(processed_args, get_commands, **kwargs):
    import multiprocessing

    hosts = []
    jobs = []

    (hosts, options) = processed_args
    kwargs.update(options)

    for host in hosts:
        p = multiprocessing.Process(
                target=run_commands,
                args=(
                    host,
                    get_commands(host, **kwargs),
                    ), )

        jobs.append(p)
        p.start()
&lt;/code&gt;

</description>
		<content:encoded><![CDATA[<p>Thats good to know on the function line definition. It wasn&#8217;t a case that came up in this instance, only because the thread_hosts is only run once. I don&#8217;t see a need to run it more than once, but I&#8217;ll probably implement it similar to how you&#8217;ve suggested, because I can&#8217;t be sure that someone else won&#8217;t want to run it twice, in one script.</p>
<p>I think the most helpful suggestion was on my modification of kwargs by rolling options into it. It got me thinking that the script user needn&#8217;t have any interaction with the argument parser at all. Instead I will pass the thread_hosts function sys.argv, and let is deal with deciding what it need. The issue of changing kwargs still is present, but in this implementation its now hidden, and only crops up when the user wants to specify a kwarg that is already used in the optparse options.</p>
<p>End result looking something like this:<br />
<strong>script.py</strong></p>
<div class="codecolorer-container python vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">import</span> automation<br />
<br />
&nbsp; &nbsp; automation.<span style="color: black;">thread_hosts</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; automation.<span style="color: black;">process_args</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get_commands,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">user</span>=<span style="color: #483d8b;">&quot;test&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span></div></div>
<p><strong>automation.py</strong></p>
<div class="codecolorer-container python vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> thread_hosts<span style="color: black;">&#40;</span>processed_args, get_commands, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">import</span> multiprocessing<br />
<br />
&nbsp; &nbsp; hosts = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; jobs = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>hosts, options<span style="color: black;">&#41;</span> = processed_args<br />
&nbsp; &nbsp; kwargs.<span style="color: black;">update</span><span style="color: black;">&#40;</span>options<span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> host <span style="color: #ff7700;font-weight:bold;">in</span> hosts:<br />
&nbsp; &nbsp; &nbsp; &nbsp; p = multiprocessing.<span style="color: black;">Process</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target=run_commands,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args=<span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; host,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get_commands<span style="color: black;">&#40;</span>host, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span>, <span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; jobs.<span style="color: black;">append</span><span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; p.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Decouple with kwargs by Alfred Rossi</title>
		<link>http://morgangoose.com/blog/2009/07/decouple-with-kwargs/comment-page-1/#comment-26</link>
		<dc:creator>Alfred Rossi</dc:creator>
		<pubDate>Fri, 24 Jul 2009 22:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/?p=45#comment-26</guid>
		<description>@Heikki Toivonen

Your example doesn't make your point. Since foo always sets option[2] = 2 it never does anything unexpected.

&lt;code lang='python'&gt;
alfred@alfred-desktop:~$ cat ./foo.py 
def foo(pair = None, options={}):
    if pair:
        key, value = pair
        options[key] = value

    print options

foo()
foo((2,2))
foo()

alfred@alfred-desktop:~$ python ./foo.py 
{}
{2: 2}
{2: 2}
&lt;/code&gt;

</description>
		<content:encoded><![CDATA[<p>@Heikki Toivonen</p>
<p>Your example doesn&#8217;t make your point. Since foo always sets option[2] = 2 it never does anything unexpected.</p>
<div class="codecolorer-container python vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">alfred@alfred-desktop:~$ cat ./foo.<span style="color: black;">py</span> <br />
<span style="color: #ff7700;font-weight:bold;">def</span> foo<span style="color: black;">&#40;</span>pair = <span style="color: #008000;">None</span>, options=<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> pair:<br />
&nbsp; &nbsp; &nbsp; &nbsp; key, value = pair<br />
&nbsp; &nbsp; &nbsp; &nbsp; options<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span> = value<br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> options<br />
<br />
foo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
foo<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span>,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
foo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
alfred@alfred-desktop:~$ python ./foo.<span style="color: black;">py</span> <br />
<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#123;</span><span style="color: #ff4500;">2</span>: <span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#123;</span><span style="color: #ff4500;">2</span>: <span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Decouple with kwargs by Heikki Toivonen</title>
		<link>http://morgangoose.com/blog/2009/07/decouple-with-kwargs/comment-page-1/#comment-25</link>
		<dc:creator>Heikki Toivonen</dc:creator>
		<pubDate>Fri, 24 Jul 2009 22:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/?p=45#comment-25</guid>
		<description>There are some subtle gotchas in the way you coded thread_hosts. First of all the default is dict, which means that if you modify options in the function, the modifications are remembered in future calls. Try this:

&lt;code lang='python'&gt;
def foo(options={}):
    options[2] = 2
    print options

foo({1:1})
foo()
&lt;/code&gt;

The normal way to handle this is to make the default value None, and if so, make the value into dict inside the function:

&lt;code lang='python'&gt;
def foo(options=None):
    if options is None:
        options = {}
    options[2] = 2
    print options
&lt;/code&gt;

The other thing is that you are modifying the passed in datastructure, which would probably surprise the callers. Better way would be to create a copy of kwargs to play.</description>
		<content:encoded><![CDATA[<p>There are some subtle gotchas in the way you coded thread_hosts. First of all the default is dict, which means that if you modify options in the function, the modifications are remembered in future calls. Try this:</p>
<div class="codecolorer-container python vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> foo<span style="color: black;">&#40;</span>options=<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; options<span style="color: black;">&#91;</span>2<span style="color: black;">&#93;</span> = 2<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> options<br />
<br />
foo<span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #ff4500;">1</span>:<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span><br />
foo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
<p>The normal way to handle this is to make the default value None, and if so, make the value into dict inside the function:</p>
<div class="codecolorer-container python vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> foo<span style="color: black;">&#40;</span>options=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> options <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; options = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; options<span style="color: black;">&#91;</span>2<span style="color: black;">&#93;</span> = 2<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> options</div></div>
<p>The other thing is that you are modifying the passed in datastructure, which would probably surprise the callers. Better way would be to create a copy of kwargs to play.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Fedora 10 on the eeePC 900 by Morgan</title>
		<link>http://morgangoose.com/blog/2009/05/fedora-10-on-the-eeepc-900/comment-page-1/#comment-24</link>
		<dc:creator>Morgan</dc:creator>
		<pubDate>Tue, 09 Jun 2009 15:49:25 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/?p=5#comment-24</guid>
		<description>Very cool! I will have to use that now, perhaps on all my machines. Thanks for the comment. I think I'll be rewriting this tutorial here again shortly to update it for fedora 11, and I'll have to include this fact.</description>
		<content:encoded><![CDATA[<p>Very cool! I will have to use that now, perhaps on all my machines. Thanks for the comment. I think I&#8217;ll be rewriting this tutorial here again shortly to update it for fedora 11, and I&#8217;ll have to include this fact.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Fedora 10 on the eeePC 900 by Juhamatti Niemelä</title>
		<link>http://morgangoose.com/blog/2009/05/fedora-10-on-the-eeepc-900/comment-page-1/#comment-23</link>
		<dc:creator>Juhamatti Niemelä</dc:creator>
		<pubDate>Tue, 09 Jun 2009 12:17:15 +0000</pubDate>
		<guid isPermaLink="false">http://morgangoose.com/blog/?p=5#comment-23</guid>
		<description>You can use rpm macros to filter out unwanted locales when installing, or updating packages. Check this forum post for more information: http://fedoraforum.org/forum/showpost.php?p=1178755&amp;postcount=16</description>
		<content:encoded><![CDATA[<p>You can use rpm macros to filter out unwanted locales when installing, or updating packages. Check this forum post for more information: <a href="http://fedoraforum.org/forum/showpost.php?p=1178755&amp;postcount=16" rel="nofollow">http://fedoraforum.org/forum/showpost.php?p=1178755&amp;postcount=16</a></p>
]]></content:encoded>
	</item>
</channel>
</rss><!-- Dynamic page generated in 0.907 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-02-28 02:21:40 -->
