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
|
return is_in_dir
|
||||||
|
|
||||||
def exec_command(command):
|
def exec_command(command):
|
||||||
'''command is a string that contain arguments'''
|
subprocess.Popen(command, shell = True)
|
||||||
# os.system(command)
|
|
||||||
subprocess.Popen(command.split())
|
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):
|
def launch_browser_mailer(kind, uri):
|
||||||
#kind = 'url' or 'mail'
|
#kind = 'url' or 'mail'
|
||||||
|
@ -404,7 +409,8 @@ def launch_browser_mailer(kind, uri):
|
||||||
command = gajim.config.get('custommailapp')
|
command = gajim.config.get('custommailapp')
|
||||||
if command == '': # if no app is configured
|
if command == '': # if no app is configured
|
||||||
return
|
return
|
||||||
command = command + ' ' + uri
|
|
||||||
|
command = build_command(command, uri)
|
||||||
try:
|
try:
|
||||||
exec_command(command)
|
exec_command(command)
|
||||||
except:
|
except:
|
||||||
|
@ -425,7 +431,7 @@ def launch_file_manager(path_to_open):
|
||||||
command = gajim.config.get('custom_file_manager')
|
command = gajim.config.get('custom_file_manager')
|
||||||
if command == '': # if no app is configured
|
if command == '': # if no app is configured
|
||||||
return
|
return
|
||||||
command = command + ' ' + path_to_open
|
command = build_command(command, path_to_open)
|
||||||
try:
|
try:
|
||||||
exec_command(command)
|
exec_command(command)
|
||||||
except:
|
except:
|
||||||
|
@ -453,7 +459,7 @@ def play_sound_file(path_to_soundfile):
|
||||||
if gajim.config.get('soundplayer') == '':
|
if gajim.config.get('soundplayer') == '':
|
||||||
return
|
return
|
||||||
player = gajim.config.get('soundplayer')
|
player = gajim.config.get('soundplayer')
|
||||||
command = player + ' ' + path_to_soundfile
|
command = build_command(player, path_to_soundfile)
|
||||||
exec_command(command)
|
exec_command(command)
|
||||||
|
|
||||||
def get_file_path_from_dnd_dropped_uri(uri):
|
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))
|
notif = gajim.config.get_per('notifications', str(num))
|
||||||
|
|
||||||
def notify(event, jid, account, parameters, advanced_notif_num = None):
|
def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
'''Check what type of notifications we want, depending on basic configuration
|
'''Check what type of notifications we want, depending on basic
|
||||||
of notifications and advanced one and do these notifications'''
|
and the advanced configuration of notifications and do these notifications'''
|
||||||
# First, find what notifications we want
|
# First, find what notifications we want
|
||||||
do_popup = False
|
do_popup = False
|
||||||
do_sound = False
|
do_sound = False
|
||||||
|
|
Loading…
Add table
Reference in a new issue