zhasm
7/22/2011 - 11:02 AM

open for ubuntu

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()