/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/launch.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-29 20:59:52 UTC
  • mfrom: (0.8.92 merge)
  • Revision ID: jelmer@samba.org-20060929205952-32ce1f02b7cf334b
MergeĀ OliveĀ code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
import sys
 
18
import os
 
19
import string
 
20
 
 
21
def launch(path):
 
22
    """ Launch program associated with path """
 
23
 
 
24
    # Normalize filepath
 
25
    normpath = os.path.normpath(path) 
 
26
    
 
27
    if sys.platform == 'win32':
 
28
        # Windows is easy
 
29
        os.startfile(normpath)
 
30
    else:
 
31
        # Maybe Gnome?
 
32
        exe = search_exe('gnome-open')
 
33
        if exe != None:
 
34
            os.system("gnome-open %s" % normpath)
 
35
            return
 
36
        # Maybe KDE?
 
37
        exe = search_exe('kfmclient')
 
38
        if exe != None:
 
39
            os.system("kfmclient exec file:%s" % normpath)
 
40
            return
 
41
 
 
42
        # TODO: support other platforms
 
43
        print "DEBUG: file launch not supported on this platform."
 
44
 
 
45
def search_exe(exe):
 
46
    """ Search for given executable. """
 
47
    found = 0
 
48
    paths = os.environ['PATH'].split(os.pathsep)
 
49
    for path in paths:
 
50
        if os.path.exists(os.path.join(path,exe)):
 
51
            found = 1
 
52
            break
 
53
    if found:
 
54
        return True
 
55
    return None