I wanted to catch a sys.exit() call in my code (using Python 2.5) and handle it but alas even this wasn’t working:
import sys
try:
sys.exit()
except Exception,Err:
print 'hi'
It would just exit the script.
I found this is the way to go when you truly want to capture all exceptions:
try:
sys.exit()
except BaseException,Err:
print 'hi'
Please correct me if I’m missing anything. Are there any exceptions I still won’t catch?
Posted by Greg Pinero (Primary Searcher) as Python at 9:58 PM MST
5 Comments »
I had solved this problem a year or two ago, but when I accidentally blew out my winamp install a month ago or so, all my plugins came back, but my media library was gone (along with custom views, etc) and my beloved ability to view song ratings in the playlist. Long story short…Winamp 5.5 (can’t vouch for older ones, but probably everything over 5.0?)
Preferences >> General Preferences >> Titles
In the advanced title formatting section, (assuming it’s already turned on) add the following string…
$repeat(*,%rating%)
This will put as many stars for the rating after whatever else is displayed in the playlist. For instance
Weezer - Only In Dreams *****
Britney Spears - SomeSong *
Now, as to why I have Britney Spears’ songs on my computer is another Answer My Searches post entirely.
Posted by Jody as Other at 11:51 AM MST
Comments Off
These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.
Python - How to view request message sent from urllib2Here is how to do it for the simple case:
opener = urllib2.build_opener(urllib2.HTTPHandler(debuglevel=1))
urllib2.install_opener(opener)
But for using the HTTPBasicAuthHandler I had no clue, so I temporarily just hard coded debug levels in urllib2
The softlimit programsoftlimit runs another program with new resource limits. This might work when /etc/security/limits.conf doesn’t. I think limits.conf only works for logged in users?
friendsnippets.com - Snippet: A function to enumerate the items of a set product.Example:
>>> list(enumerate_set_product([1,2],[1,2]))
[[1, 1], [2, 1], [1, 2], [2, 2]]
VectorMagicThis site traces bitmap images, turning them into beautiful vector art. Just upload your image and we will convert it for you.
Tags: Bitmap, Convert, Crossproduct, Daemon, Enumerate, Eps, Favicon, Generator, Graphic, Graphics, Http, Icon, Image, Limits.Conf, Logo, Python, Svg, Tool, Tools, Ubuntu, Urllib2, Utility, Utilitymill, Validator, Vector, Xml, Xsd
Posted by Greg Pinero (Primary Searcher) as Uncategorized at 3:30 AM MST
Comments Off
I wanted a way to compare the page load times of my website on the old server and on the new server where I’m moving it.
I found an easy way to do this is to use curl. I was inspired by this article, but I improve on it by providing examples that work!
Here are the steps to getting a nice tabular file that shows load time information across a series of URL’s. (Only tested on Ubuntu.)
First I installed curl:
sudo apt-get install curl
Next I made a file called test_config.txt. Here are the contents:
-A "Mozilla/4.0 (compatible; cURL 7.10.5-pre2; Linux 2.4.20)"
-L
-w @logformat.txt
-D headers.txt
-H "Pragma: no-cache"
-H "Cache-control: no-cache"
-H "Connection: close"
url="http://foo.com/"
url="http://foo.members.linode.com/"
url="http://foo.com/utility/Text_Diff"
url="http://foo.com/"
url="http://foo.members.linode.com/"
url="http://foo.com/utility/Text_Diff"
The inspiration article explains a bit about what’s going on here.
Next I made a file called logformat.txt which you can see is referenced in test_config.txt above. Here are the contents of that file:
\n
%{url_effective}\t%{http_code}\t%{content_type}\t%{time_total}\t%{time_namelookup}\t%{time_connect}\t%{time_starttransfer}\t%{size_download}\n
\n
Again the inspiration article explains a bit about what’s going on with this.
Finally we’re ready to run curl. The trick here is that curl insists on outputting the contents of the web pages along with the statistics we want so we pipe it through grep as so (I’m assuming you’re in the directory with the files we just made.):
$ curl -K test_config.txt | grep -i -r "^http://.*$" >> final_output.txt
This whole command runs curl using our configuration files, passes the output to grep, which then pulls out only the lines starting with http:// and outputs that to the file final_output.txt.
Posted by Greg Pinero (Primary Searcher) as Ubuntu at 11:30 PM MST
Comments Off
These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.
Ubuntu Server GuideThis is supposed to be an excellent and thorough guide for setting up an entire Ubuntu server.
Tags: .Net, Apache, Asp.Net, C#, Delete, Documentation, Fastcgi, Guid, Guide, Iis, Linux, Mysql, Php, Privacy, Python, Reference, Security, Server, Shred, Sysadmin, Tutorial, Ubuntu, Vps, Win32, Work
Posted by Greg Pinero (Primary Searcher) as Uncategorized at 3:30 AM MST
Comments Off