3 # Copyright (C) 2010-2013 CEA/DEN
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 In this file : all functions that do a system call, like open a browser or an editor, or call a git command
25 from . import printcolors
27 def show_in_editor(editor, filePath, logger):
28 '''open filePath using editor.
30 :param editor str: The editor to use.
31 :param filePath str: The path to the file to open.
33 # default editor is vi
34 if editor is None or len(editor) == 0:
37 if '%s' not in editor:
41 # launch cmd using subprocess.Popen
42 cmd = editor % filePath
43 logger.write('Launched command:\n' + cmd + '\n', 5)
44 p = subprocess.Popen(cmd, shell=True)
47 logger.write(printcolors.printcError(_("Unable to edit file %s\n") % filePath), 1)