mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-13 21:14:55 +00:00
Refactored the way external commands are called.
This commit is contained in:
parent
1e00b4f0a8
commit
ff64068c6d
@ -51,6 +51,8 @@ class FilesTabManager(FilesBaseManager):
|
||||
def open_file(self, widget=None):
|
||||
import os
|
||||
|
||||
from deluge.common import exec_command
|
||||
|
||||
save_dir = self.manager.unique_IDs[self.file_unique_id].save_dir
|
||||
selected_paths = self.file_view.get_selection().get_selected_rows()[1]
|
||||
try:
|
||||
@ -59,8 +61,8 @@ class FilesTabManager(FilesBaseManager):
|
||||
convert_path_to_child_path(path)
|
||||
file_name = self.file_store.get_value(
|
||||
self.file_store.get_iter(child_path), 0)
|
||||
os.popen2('%s "%s"' % (self.file_viewer,
|
||||
os.path.join(save_dir, file_name)))
|
||||
exec_command(self.file_viewer,
|
||||
os.path.join(save_dir, file_name))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
@ -129,11 +129,7 @@ def open_url_in_browser(link):
|
||||
import webbrowser
|
||||
webbrowser.open(link)
|
||||
else:
|
||||
import os, sys
|
||||
py_version = sys.version[:3]
|
||||
file = os.path.join(INSTALL_PREFIX, 'lib', 'python' \
|
||||
+ py_version, 'site-packages', 'deluge', 'browser.py')
|
||||
os.spawnlp(os.P_NOWAIT, 'python', 'python', file, link)
|
||||
exec_deluge_command('browser.py', link)
|
||||
|
||||
def is_url(url):
|
||||
import re
|
||||
@ -156,6 +152,24 @@ def fetch_url(url):
|
||||
|
||||
return None
|
||||
|
||||
def exec_command(executable, *parameters):
|
||||
from subprocess import Popen
|
||||
|
||||
command = [executable]
|
||||
command.extend(parameters)
|
||||
Popen(command)
|
||||
|
||||
|
||||
def exec_deluge_command(script, *parameters):
|
||||
"""Execute deluge's command like browser.py, update.py and others"""
|
||||
|
||||
import sys
|
||||
|
||||
py_version = sys.version[:3]
|
||||
full_path = os.path.join(INSTALL_PREFIX, 'lib', 'python' + py_version,
|
||||
'site-packages', 'deluge', script)
|
||||
exec_command('python', full_path, *parameters)
|
||||
|
||||
# Encryption States
|
||||
class EncState:
|
||||
forced, enabled, disabled = range(3)
|
||||
|
@ -115,25 +115,13 @@ class DelugeGTK:
|
||||
self.update_interface = True
|
||||
|
||||
def new_release_check():
|
||||
import sys
|
||||
py_version = sys.version[:3]
|
||||
file = os.path.join(common.INSTALL_PREFIX, 'lib', 'python' \
|
||||
+ py_version, 'site-packages', 'deluge', 'update.py')
|
||||
os.spawnlp(os.P_NOWAIT, 'python', 'python', file,
|
||||
common.PROGRAM_VERSION)
|
||||
common.exec_deluge_command('update.py', common.PROGRAM_VERSION)
|
||||
|
||||
def send_info():
|
||||
import time
|
||||
|
||||
def _run_script():
|
||||
import sys
|
||||
|
||||
py_version = sys.version[:3]
|
||||
|
||||
file = os.path.join(common.INSTALL_PREFIX, 'lib', 'python' \
|
||||
+ py_version, 'site-packages', 'deluge', 'info.py')
|
||||
os.spawnlp(os.P_NOWAIT, 'python', 'python', file,
|
||||
common.PROGRAM_VERSION)
|
||||
common.exec_deluge_command('info.py', common.PROGRAM_VERSION)
|
||||
|
||||
info_file = os.path.join(common.CONFIG_DIR, 'infosent')
|
||||
|
||||
@ -657,7 +645,7 @@ class DelugeGTK:
|
||||
torrent_path = os.path.join(torrent_path,
|
||||
file["path"].split("/", 1)[0])
|
||||
|
||||
os.popen2('%s "%s"' % (file_manager, torrent_path))
|
||||
common.exec_command(file_manager, torrent_path)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user