<?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>blog.sudosu.net &#187; Python</title>
	<atom:link href="http://blog.sudosu.net/category/computers/programming/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sudosu.net</link>
	<description>Got root?</description>
	<lastBuildDate>Mon, 21 Dec 2009 18:27:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>File &#8220;Created Date&#8221; Under OS X &#8212; Harder Than You Think</title>
		<link>http://blog.sudosu.net/2009/file-created-date-under-os-x/</link>
		<comments>http://blog.sudosu.net/2009/file-created-date-under-os-x/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 21:28:57 +0000</pubDate>
		<dc:creator>schof</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.sudosu.net/?p=290</guid>
		<description><![CDATA[A client had an OS X server with tens of thousands of files in a directory tree, and wanted to move some of them based on their creation date. I put together a Python script that worked perfectly on my test system, but failed in production. (I put in a &#8220;&#8211;dryrun&#8221; option, so no harm [...]]]></description>
			<content:encoded><![CDATA[<p>A client had an OS X server with tens of thousands of files in a directory tree, and wanted to move some of them based on their creation date. I put together a Python script that worked perfectly on my test system, but failed in production. (I put in a &#8220;&#8211;dryrun&#8221; option, so no harm was done.)</p>
<p>The modification date the script reported was correct, but the creation date the script reported was different from the creation date that doing &#8220;Get Info&#8221; in the OS X Finder reported. Hmm. Not good. I did some investigating.</p>
<p>Let&#8217;s look at a test file. The Finder reports the following creation and modification dates:<br />
<code>Created: Monday, April 10, 2006 17:04<br />
Modified: Thursday, April 13, 2006 15:54</code></p>
<p>Python reports a different creation date and the same modification date:<br />
<code><br />
&gt;&gt;&gt; import os.path<br />
&gt;&gt;&gt; import time<br />
&gt;&gt;&gt; stamp = os.path.getctime('datetest.txt')<br />
&gt;&gt;&gt; time.ctime(stamp)<br />
'Fri Apr 10 15:51:10 2009'<br />
&gt;&gt;&gt; stamp = os.path.getmtime('datetest.txt')<br />
&gt;&gt;&gt; time.ctime(stamp)<br />
'Thu Apr 13 15:54:43 2006'<br />
</code><br />
Hmmm. What does &#8220;ls&#8221; in the Terminal report? The standard &#8220;ls -l&#8221; reports creation date. Adding &#8220;-T&#8221; makes it report the full date in all cases. And &#8220;-c&#8221; counter-intuitively means &#8220;display modification date.&#8221;<br />
<code><br />
$ ls -lT datetest.txt<br />
-rwxr-xr-x@ 1 schof  schof  2448091 Apr 13 15:54:43 2006 datetest.txt<br />
$ ls -lcT datetest.txt<br />
-rwxr-xr-x@ 1 schof  schof  2448091 Apr 10 15:51:10 2009 datetest.txt<br />
</code><br />
The plot thickens. The modification date matches the Finder and Python, but both Python and ls are reporting an incorrect (according to the Finder) creation date.</p>
<p>Quite a bit of Googling showed me the &#8220;<a href="http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/mdls.1.html">mdls</a>&#8221; tool &#8212; or &#8220;metadata ls.&#8221; Very useful. This shows the complete set of metadata for a file. Including the OS X creation date. Actually, two creation dates, one for the file, and one for the file content. (I&#8217;m not sure what circumstances would make those creation dates differ. The <a href="http://developer.apple.com/macosx/spotlight.html">documentation I&#8217;ve been able to find</a> has been unclear and <a href="http://developer.apple.com/documentation/Carbon/Reference/MetadataAttributesRef/Reference/CommonAttrs.html">contradictory</a>.)</p>
<p><code><br />
$ mdls datetest.txt<br />
kMDItemContentCreationDate     = 2006-04-10 17:04:34 -0700<br />
kMDItemContentModificationDate = 2006-04-13 15:54:43 -0700<br />
...<br />
kMDItemFSContentChangeDate     = 2006-04-13 15:54:43 -0700<br />
kMDItemFSCreationDate          = 2006-04-10 17:04:34 -0700<br />
...<br />
kMDItemLastUsedDate            = 2009-04-11 11:48:03 -0700<br />
kMDItemUsedDates               = (<br />
2009-04-11 00:00:00 -0700<br />
)<br />
</code></p>
<p>Now that we&#8217;ve got all that information, what does it tell us? The Unix/Linux standard for &#8220;creation date&#8221; is to show you the date on which a particular file was created. If you copy file &#8220;a&#8221; to file &#8220;b,&#8221; those are two different files, and the &#8220;creation date&#8221; for file &#8220;b&#8221; will be the date you made the copy.</p>
<p>OS X metadata travels with the file, so if you copy file &#8220;a&#8221; to file &#8220;b&#8221; using ditto on the command-line or using the Finder, the Unix creation date will be the date the copy was done, but the OS X creation date of file &#8220;b&#8221; will be the same as file &#8220;a.&#8221;</p>
<p>There&#8217;s good arguments for handling &#8220;creation date&#8221; the Unix way, and there are good arguments for doing &#8220;creation date&#8221; the OS X way, but mixing them as OS X does is kind of frustrating.</p>
<p>I&#8217;ve written a quick-and-dirty Python example script that reports the Unix creation date and the OS X creation date for any particular file. Since it&#8217;s released under the open-source MIT license, feel free to use it in your own programs. You can download it here: <a href="http://www.sudosu.net/getcreationdate.safe">http://www.sudosu.net/getcreationdate.safe</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sudosu.net/2009/file-created-date-under-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working on the spec for SPBS</title>
		<link>http://blog.sudosu.net/2008/working-on-the-spec-for-spbs/</link>
		<comments>http://blog.sudosu.net/2008/working-on-the-spec-for-spbs/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 18:23:03 +0000</pubDate>
		<dc:creator>schof</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[SPBS]]></category>

		<guid isPermaLink="false">http://blog.sudosu.net/2008/working-on-the-spec-for-spbs/</guid>
		<description><![CDATA[I&#8217;ve been working on the spec for SPBS &#8212; it&#8217;s slow going, as my real job has been taking most of my focus. But I realized that in designing the templating system for the blog, I&#8217;m actually designing a domain-specific mini-language. I think I&#8217;m going to reread that chapter of The Art of Unix Programming.
But [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on the spec for <a href="http://code.google.com/p/spbs/" target="_blank">SPBS</a> &#8212; it&#8217;s slow going, as my real job has been taking most of my focus. But I realized that in designing the templating system for the blog, I&#8217;m actually designing a <a href="http://catb.org/~esr/writings/taoup/html/minilanguageschapter.html" target="_blank">domain-specific mini-language</a>. I think I&#8217;m going to reread that chapter of <a href="http://catb.org/~esr/writings/taoup/html/" target="_blank">The Art of Unix Programming</a>.</p>
<p>But in general, I&#8217;m finding SPBS both challenging and a hell of a lot of fun. It&#8217;s turning into a bigger project than I expected &#8212; or perhaps, a better way of saying it is that SPBS is slowly revealing its complexity to me. I could get this done a lot fast by adapting pyBloxsom. But where&#8217;s the fun in that? {grin}</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sudosu.net/2008/working-on-the-spec-for-spbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing The Launch Of SPBS &#8212; the Simplest Possible Blogging System</title>
		<link>http://blog.sudosu.net/2008/announcing-the-launch-of-spbs-the-simplest-possible-blogging-system/</link>
		<comments>http://blog.sudosu.net/2008/announcing-the-launch-of-spbs-the-simplest-possible-blogging-system/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 07:24:27 +0000</pubDate>
		<dc:creator>schof</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[John Mark Schofield Meta]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.sudosu.net/2008/announcing-the-launch-of-spbs-the-simplest-possible-blogging-system/</guid>
		<description><![CDATA[And by &#8220;Launch,&#8221; I mean &#8220;I&#8217;m starting to write it.&#8221; There&#8217;s a long way between that and a completed program. But you can check my progress at SPBS&#8217; Google Code site: http://code.google.com/p/spbs/
I&#8217;ve written an introduction to SPBS, and the reasons I&#8217;m writing it here, at http://code.google.com/p/spbs/wiki/SPBSIntroduction
]]></description>
			<content:encoded><![CDATA[<p>And by &#8220;Launch,&#8221; I mean &#8220;I&#8217;m starting to write it.&#8221; There&#8217;s a long way between that and a completed program. But you can check my progress at SPBS&#8217; Google Code site: <a href="http://code.google.com/p/spbs/" target="_blank">http://code.google.com/p/spbs/</a></p>
<p>I&#8217;ve written an introduction to SPBS, and the reasons I&#8217;m writing it here, at <a href="http://code.google.com/p/spbs/wiki/SPBSIntroduction" target="_blank">http://code.google.com/p/spbs/wiki/SPBSIntroduction</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sudosu.net/2008/announcing-the-launch-of-spbs-the-simplest-possible-blogging-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google FTW: Fixing Arrow Problems in OS X Python</title>
		<link>http://blog.sudosu.net/2007/google-ftw-fixing-arrow-problems-in-os-x-python/</link>
		<comments>http://blog.sudosu.net/2007/google-ftw-fixing-arrow-problems-in-os-x-python/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 00:38:35 +0000</pubDate>
		<dc:creator>schof</dc:creator>
				<category><![CDATA[Broken]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.sudosu.net/2007/google-ftw-fixing-arrow-problems-in-os-x-python/</guid>
		<description><![CDATA[I lived with it for ages. I tried to fix it on my own, by selecting different emulation types. Finally I Googled for it. And pretty much instantly found the answer:
 python `python -c &#8220;import pimp; print pimp.__file__&#8221;` -i readline
Moral? If at first you don&#8217;t succeed, Google. If Google fails, try, try again.
Update: And to [...]]]></description>
			<content:encoded><![CDATA[<p>I lived with it for ages. I tried to fix it on my own, by selecting different emulation types. Finally I Googled for it. And <a href="http://forums.macosxhints.com/archive/index.php/t-64151.html" target="_blank">pretty much instantly</a> <a href="http://simplygenius.com/geekblog/2005/08/30/readline-for-python-on-osx/" target="_blank">found the answer</a>:</p>
<blockquote><p> python `python -c &#8220;import pimp; print pimp.__file__&#8221;` -i readline</p></blockquote>
<p>Moral? If at first you don&#8217;t succeed, Google. If Google fails, try, try again.</p>
<p><strong>Update:</strong> And to make forward-delete work, <a href="http://www.macosxhints.com/article.php?story=20050525040921189" target="_blank">try this.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sudosu.net/2007/google-ftw-fixing-arrow-problems-in-os-x-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Workflow: TextMate, Subversion, and Python</title>
		<link>http://blog.sudosu.net/2007/my-workflow-textmate-subversion-and-python/</link>
		<comments>http://blog.sudosu.net/2007/my-workflow-textmate-subversion-and-python/#comments</comments>
		<pubDate>Mon, 02 Apr 2007 01:33:49 +0000</pubDate>
		<dc:creator>schof</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Macintosh Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.sudosu.net/2007/my-workflow-textmate-subversion-and-python/</guid>
		<description><![CDATA[I&#8217;m focusing in on some very important parts of my workflow. Version control is Subversion. I&#8217;m most of the way through the book on it.
Text editing is TextMate. I was trying to use vim, because it&#8217;s one editor I can use both on my OS X desktop and SSH&#8217;d across the network to linux boxes. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m focusing in on some very important parts of my workflow. Version control is Subversion. I&#8217;m most of the way through the book on it.</p>
<p>Text editing is TextMate. I was trying to use vim, because it&#8217;s one editor I can use both on my OS X desktop and SSH&#8217;d across the network to linux boxes. I will continue to use vim remotely &#8212; though I may look at emacs as well. But for local editing, it&#8217;s TextMate for sure. Its functionality when dealing with large source code files and trees with many different files is impressive &#8212; I can see myself working significantly more efficiently with TextMate.</p>
<p>I&#8217;m used to working on the command-line with Subversion, but TextMate integrates with it, so I can commit changes by hotkey, etc.</p>
<p>And Python is rapidly becoming my system administration language of choice. All of this seems to fit together really well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sudosu.net/2007/my-workflow-textmate-subversion-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

