intro helpers.build_command and fix helpers.exec_command(). fixes #2464 [now all is okay if path has spaces]
This commit is contained in:
parent
8e42587efc
commit
72e8da7130
2 changed files with 14 additions and 8 deletions
|
@ -377,9 +377,14 @@ def is_in_path(name_of_command, return_abs_path = False):
|
|||
return is_in_dir
|
||||
|
||||
def exec_command(command):
|
||||
'''command is a string that contain arguments'''
|
||||
# os.system(command)
|
||||
subprocess.Popen(command.split())
|
||||
subprocess.Popen(command, shell = True)
|
||||
|
||||
def build_command(executable, parameter):
|
||||
# we add to the parameter (can hold path with spaces)
|
||||
# "" so we have good parsing from shell
|
||||
parameter = parameter.replace('"', '\\"') # but first escape "
|
||||
command = '%s "%s"' % (command , parameter)
|
||||
return command
|
||||
|
||||
def launch_browser_mailer(kind, uri):
|
||||
#kind = 'url' or 'mail'
|
||||
|
@ -404,7 +409,8 @@ def launch_browser_mailer(kind, uri):
|
|||
command = gajim.config.get('custommailapp')
|
||||
if command == '': # if no app is configured
|
||||
return
|
||||
command = command + ' ' + uri
|
||||
|
||||
command = build_command(command, uri)
|
||||
try:
|
||||
exec_command(command)
|
||||
except:
|
||||
|
@ -425,7 +431,7 @@ def launch_file_manager(path_to_open):
|
|||
command = gajim.config.get('custom_file_manager')
|
||||
if command == '': # if no app is configured
|
||||
return
|
||||
command = command + ' ' + path_to_open
|
||||
command = build_command(command, path_to_open)
|
||||
try:
|
||||
exec_command(command)
|
||||
except:
|
||||
|
@ -453,7 +459,7 @@ def play_sound_file(path_to_soundfile):
|
|||
if gajim.config.get('soundplayer') == '':
|
||||
return
|
||||
player = gajim.config.get('soundplayer')
|
||||
command = player + ' ' + path_to_soundfile
|
||||
command = build_command(player, path_to_soundfile)
|
||||
exec_command(command)
|
||||
|
||||
def get_file_path_from_dnd_dropped_uri(uri):
|
||||
|
|
|
@ -111,8 +111,8 @@ def get_advanced_notification(event, account, contact):
|
|||
notif = gajim.config.get_per('notifications', str(num))
|
||||
|
||||
def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||
'''Check what type of notifications we want, depending on basic configuration
|
||||
of notifications and advanced one and do these notifications'''
|
||||
'''Check what type of notifications we want, depending on basic
|
||||
and the advanced configuration of notifications and do these notifications'''
|
||||
# First, find what notifications we want
|
||||
do_popup = False
|
||||
do_sound = False
|
||||
|
|
Loading…
Add table
Reference in a new issue