mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-14 05:26:28 +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):
|
def open_file(self, widget=None):
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from deluge.common import exec_command
|
||||||
|
|
||||||
save_dir = self.manager.unique_IDs[self.file_unique_id].save_dir
|
save_dir = self.manager.unique_IDs[self.file_unique_id].save_dir
|
||||||
selected_paths = self.file_view.get_selection().get_selected_rows()[1]
|
selected_paths = self.file_view.get_selection().get_selected_rows()[1]
|
||||||
try:
|
try:
|
||||||
@ -59,8 +61,8 @@ class FilesTabManager(FilesBaseManager):
|
|||||||
convert_path_to_child_path(path)
|
convert_path_to_child_path(path)
|
||||||
file_name = self.file_store.get_value(
|
file_name = self.file_store.get_value(
|
||||||
self.file_store.get_iter(child_path), 0)
|
self.file_store.get_iter(child_path), 0)
|
||||||
os.popen2('%s "%s"' % (self.file_viewer,
|
exec_command(self.file_viewer,
|
||||||
os.path.join(save_dir, file_name)))
|
os.path.join(save_dir, file_name))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -129,11 +129,7 @@ def open_url_in_browser(link):
|
|||||||
import webbrowser
|
import webbrowser
|
||||||
webbrowser.open(link)
|
webbrowser.open(link)
|
||||||
else:
|
else:
|
||||||
import os, sys
|
exec_deluge_command('browser.py', link)
|
||||||
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)
|
|
||||||
|
|
||||||
def is_url(url):
|
def is_url(url):
|
||||||
import re
|
import re
|
||||||
@ -156,6 +152,24 @@ def fetch_url(url):
|
|||||||
|
|
||||||
return None
|
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
|
# Encryption States
|
||||||
class EncState:
|
class EncState:
|
||||||
forced, enabled, disabled = range(3)
|
forced, enabled, disabled = range(3)
|
||||||
|
@ -115,25 +115,13 @@ class DelugeGTK:
|
|||||||
self.update_interface = True
|
self.update_interface = True
|
||||||
|
|
||||||
def new_release_check():
|
def new_release_check():
|
||||||
import sys
|
common.exec_deluge_command('update.py', common.PROGRAM_VERSION)
|
||||||
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)
|
|
||||||
|
|
||||||
def send_info():
|
def send_info():
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def _run_script():
|
def _run_script():
|
||||||
import sys
|
common.exec_deluge_command('info.py', common.PROGRAM_VERSION)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
info_file = os.path.join(common.CONFIG_DIR, 'infosent')
|
info_file = os.path.join(common.CONFIG_DIR, 'infosent')
|
||||||
|
|
||||||
@ -657,7 +645,7 @@ class DelugeGTK:
|
|||||||
torrent_path = os.path.join(torrent_path,
|
torrent_path = os.path.join(torrent_path,
|
||||||
file["path"].split("/", 1)[0])
|
file["path"].split("/", 1)[0])
|
||||||
|
|
||||||
os.popen2('%s "%s"' % (file_manager, torrent_path))
|
common.exec_command(file_manager, torrent_path)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user