annotate Generic/openwith.py @ 18:878159a13494

bug fix: except raise when parses X records importing fiebdc files
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Thu, 28 Nov 2013 12:54:42 +0100
parents a7b9f7e7dfa4
children 65e7ae0d0e63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1 #!/usr/bin/python
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3 ## File openwith.py
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4 ## This file is part of pyArq-Presupuestos.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5 ##
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
6 ## Copyright (C) 2010-2013 Miguel Ángel Bárcena Rodríguez
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
7 ## <miguelangel@obraencurso.es>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
8 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
9 ## This file is based in gtkgui_helpers.py and common/helpers.py from gajim
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
10 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
11 ## Copyright (C) 2003-2008 Yann Leboulanger <asterix AT lagaule.org>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
12 ## Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT gmail.com>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
13 ## Nikos Kouremenos <kourem AT gmail.com>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
14 ## Copyright (C) 2006 Alex Mauer <hawke AT hawkesnest.net>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
15 ## Copyright (C) 2006-2007 Travis Shirk <travis AT pobox.com>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
16 ## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
17 ## Copyright (C) 2007 Lukas Petrovicky <lukas AT petrovicky.net>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
18 ## James Newton <redshodan AT gmail.com>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
19 ## Julien Pivotto <roidelapluie AT gmail.com>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
20 ## Copyright (C) 2007-2008 Stephan Erb <steve-e AT h3c.de>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
21 ## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
22 ## Jonathan Schleifer <js-gajim AT webkeks.org>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
23 ## This program is free software; you can redistribute it and/or modify
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
24 ## it under the terms of the GNU General Public License as published
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
25 ## by the Free Software Foundation; version 3 only.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
26 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
27 ## This program is distributed in the hope that it will be useful,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
28 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
29 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
30 ## GNU General Public License for more details.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
31 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
32 ## You should have received a copy of the GNU General Public License
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
33 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
34 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
35 # Modules
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
36 import subprocess
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
37 import os
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
38
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
39 # pyArq-Presupuestos modules
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
40 import globalVars
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
41
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
42 # from gtkgui_helpers.py
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
43 def autodetect_desktop():
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
44 # recognize the environment and sets it in globalVars
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
45 if os.name == 'nt':
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
46 globalVars.desktop["desktop"] = "windows"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
47 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
48 _processes = get_running_processes()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
49 if 'gnome-session' in _processes:
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
50 globalVars.desktop["desktop"] = "gnome"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
51 elif 'startkde' in _processes:
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
52 globalVars.desktop["desktop"] = "kde"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
53 elif 'startxfce4' in _processes or 'xfce4-session' in _processes:
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
54 globalVars.desktop["desktop"] = "xfce"
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
55 elif 'startlxde' in _processes or 'lxsession' in _processes:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
56 globalVars.desktop["desktop"] = "lxde"
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
57 elif 'awesome' in _processes:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
58 globalVars.desktop["desktop"] = "awesome"
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
59 elif 'dwm' in _processes:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
60 globalVars.desktop["desktop"] = "dwm"
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
61 elif 'startfluxbox' in _processes:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
62 globalVars.desktop["desktop"] = "fluxbox"
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
63 elif 'fvwm2' in _processes:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
64 globalVars.desktop["desktop"] = "fvwm"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
65 else:
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
66 globalVars.desktop["desktop"] = ""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
67
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
68 def get_running_processes():
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
69 '''returns running processes or None (if not /proc exists)'''
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
70 if os.path.isdir('/proc'):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
71 # under Linux: checking if 'gnome-session' or
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
72 # 'startkde' programs were run before gajim, by
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
73 # checking /proc (if it exists)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
74 #
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
75 # if something is unclear, read `man proc`;
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
76 # if /proc exists, directories that have only numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
77 # in their names contain data about processes.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
78 # /proc/[xxx]/exe is a symlink to executable started
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
79 # as process number [xxx].
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
80 # filter out everything that we are not interested in:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
81 files = os.listdir('/proc')
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
82
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
83 # files that doesn't have only digits in names...
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
84 files = filter(str.isdigit, files)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
85
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
86 # files that aren't directories...
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
87 files = [f for f in files if os.path.isdir('/proc/' + f)]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
88
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
89 # processes owned by somebody not running gajim...
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
90 # (we check if we have access to that file)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
91 files = [f for f in files if os.access('/proc/' + f +'/exe', os.F_OK)]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
92
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
93 # be sure that /proc/[number]/exe is really a symlink
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
94 # to avoid TBs in incorrectly configured systems
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
95 files = [f for f in files if os.path.islink('/proc/' + f + '/exe')]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
96
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
97 # list of processes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
98 processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f in files]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
99
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
100 return processes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
101 return []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
102
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
103 # from common/helpers.py
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
104
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
105 def exec_command(command):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
106 subprocess.Popen('%s &' % command, shell=True).wait()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
107
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
108 def build_command(executable, parameter):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
109 # we add to the parameter (can hold path with spaces)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
110 # "" so we have good parsing from shell
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
111 parameter = parameter.replace('"', '\\"') # but first escape "
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
112 command = '%s "%s"' % (executable, parameter)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
113 return command
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
114
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
115 def launch_file(kind, uri):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
116 # kind = "url" ,"mail", "image", "dxf"
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
117 _desktop = globalVars.desktop["desktop"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
118 if _desktop == "windows":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
119 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
120 os.startfile(uri) # if pywin32 is installed we open
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
121 except Exception:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
122 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
123 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
124 if kind == 'mail' and not uri.startswith('mailto:'):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
125 uri = 'mailto:' + uri
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
126 if _desktop == "gnome":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
127 command = 'gnome-open'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
128 elif _desktop == "kde":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
129 command = 'kfmclient exec'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
130 elif _desktop == "xfce":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
131 command = 'exo-open'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
132 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
133 if kind == 'url':
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
134 command = globalVars.desktop["browser"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
135 elif kind == 'mail':
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
136 command = globalVars.desktop["mailapp"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
137 elif kind == 'image':
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
138 command = globalVars.desktop["imageapp"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
139 elif kind == 'dxf':
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
140 command = globalVars.desktop["cadapp"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
141 else: # if no app is configured
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
142 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
143 command = build_command(command, uri)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
144 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
145 exec_command(command)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
146 except Exception:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
147 pass