Skip to content

Instantly share code, notes, and snippets.

@zhasm
Created July 22, 2011 11:02
Show Gist options
  • Save zhasm/1099252 to your computer and use it in GitHub Desktop.
Save zhasm/1099252 to your computer and use it in GitHub Desktop.
open for ubuntu
#!/usr/bin/env python
import gnomevfs
import sys
import commands
import os
try:
filename=os.path.abspath(sys.argv[1])
except Exception, e:
print "Usage: %s <Filename>" % sys.argv[0]
exit()
try:
file_mimetype = gnomevfs.get_mime_type(filename)
except Exception, e:
print str(e)
exit()
try:
default_app= gnomevfs.mime_get_default_application(file_mimetype)[2]
cmd="%s %s" % (default_app, filename)
commands.getoutput(cmd)
except Exception, e:
print str(e)
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment