mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-05 16:08:40 +00:00
[Python-Modernize] libmodernize.fixes.fix_print
* Replaces print with print()
This commit is contained in:
parent
1e6c811768
commit
3a53f4002a
16 changed files with 98 additions and 83 deletions
|
@ -39,6 +39,7 @@
|
||||||
# user runs the command 'deluge'.
|
# user runs the command 'deluge'.
|
||||||
|
|
||||||
"""Main starting point for Deluge. Contains the main() entry point."""
|
"""Main starting point for Deluge. Contains the main() entry point."""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -53,10 +54,10 @@ import deluge.configmanager
|
||||||
|
|
||||||
|
|
||||||
def version_callback(option, opt_str, value, parser):
|
def version_callback(option, opt_str, value, parser):
|
||||||
print os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version()
|
print(os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version())
|
||||||
try:
|
try:
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
print "libtorrent: %s" % lt.version
|
print("libtorrent: %s" % lt.version)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -123,7 +124,7 @@ def start_ui():
|
||||||
config = deluge.configmanager.ConfigManager("ui.conf")
|
config = deluge.configmanager.ConfigManager("ui.conf")
|
||||||
config["default_ui"] = options.default_ui
|
config["default_ui"] = options.default_ui
|
||||||
config.save()
|
config.save()
|
||||||
print "The default UI has been changed to", options.default_ui
|
print("The default UI has been changed to", options.default_ui)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
version = deluge.common.get_version()
|
version = deluge.common.get_version()
|
||||||
|
@ -187,7 +188,7 @@ this should be an IP address", metavar="IFACE",
|
||||||
|
|
||||||
if options.config:
|
if options.config:
|
||||||
if not deluge.configmanager.set_config_dir(options.config):
|
if not deluge.configmanager.set_config_dir(options.config):
|
||||||
print "There was an error setting the config directory! Exiting..."
|
print("There was an error setting the config directory! Exiting...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Check for any daemons running with this same config
|
# Check for any daemons running with this same config
|
||||||
|
@ -196,8 +197,8 @@ this should be an IP address", metavar="IFACE",
|
||||||
try:
|
try:
|
||||||
check_running_daemon(pid_file)
|
check_running_daemon(pid_file)
|
||||||
except deluge.error.DaemonRunningError:
|
except deluge.error.DaemonRunningError:
|
||||||
print "You cannot run multiple daemons with the same config directory set."
|
print("You cannot run multiple daemons with the same config directory set.")
|
||||||
print "If you believe this is an error, you can force a start by deleting: %s" % pid_file
|
print("If you believe this is an error, you can force a start by deleting: %s" % pid_file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Setup the logger
|
# Setup the logger
|
||||||
|
@ -209,7 +210,7 @@ this should be an IP address", metavar="IFACE",
|
||||||
os.makedirs(os.path.abspath(os.path.dirname(options.logfile)))
|
os.makedirs(os.path.abspath(os.path.dirname(options.logfile)))
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
if ex.errno != EEXIST:
|
if ex.errno != EEXIST:
|
||||||
print "There was an error creating the log directory, exiting... (%s)" % ex
|
print("There was an error creating the log directory, exiting... (%s)" % ex)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
logfile_mode = 'w'
|
logfile_mode = 'w'
|
||||||
|
@ -272,11 +273,11 @@ this should be an IP address", metavar="IFACE",
|
||||||
# Twisted catches signals to terminate
|
# Twisted catches signals to terminate
|
||||||
def save_profile_stats():
|
def save_profile_stats():
|
||||||
profiler.dump_stats(profile_output)
|
profiler.dump_stats(profile_output)
|
||||||
print "Profile stats saved to %s" % profile_output
|
print("Profile stats saved to %s" % profile_output)
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
reactor.addSystemEventTrigger("before", "shutdown", save_profile_stats)
|
reactor.addSystemEventTrigger("before", "shutdown", save_profile_stats)
|
||||||
print "Running with profiler..."
|
print("Running with profiler...")
|
||||||
profiler.runcall(run_daemon, options)
|
profiler.runcall(run_daemon, options)
|
||||||
else:
|
else:
|
||||||
run_daemon(options)
|
run_daemon(options)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
@ -35,7 +36,7 @@ from deluge.ui.client import sclient
|
||||||
|
|
||||||
sclient.set_core_uri()
|
sclient.set_core_uri()
|
||||||
|
|
||||||
print sclient.get_enabled_plugins()
|
print(sclient.get_enabled_plugins())
|
||||||
|
|
||||||
#enable plugin.
|
#enable plugin.
|
||||||
if not "label" in sclient.get_enabled_plugins():
|
if not "label" in sclient.get_enabled_plugins():
|
||||||
|
@ -43,27 +44,27 @@ if not "label" in sclient.get_enabled_plugins():
|
||||||
|
|
||||||
|
|
||||||
#test labels.
|
#test labels.
|
||||||
print "#init labels"
|
print("#init labels")
|
||||||
try:
|
try:
|
||||||
sclient.label_remove("test")
|
sclient.label_remove("test")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
id = sclient.get_session_state()[0]
|
id = sclient.get_session_state()[0]
|
||||||
|
|
||||||
print "#add"
|
print("#add")
|
||||||
sclient.label_add("test")
|
sclient.label_add("test")
|
||||||
print "#set"
|
print("#set")
|
||||||
sclient.label_set_torrent(id,"test")
|
sclient.label_set_torrent(id,"test")
|
||||||
|
|
||||||
print sclient.get_torrents_status({"label":"test"},"name")
|
print(sclient.get_torrents_status({"label":"test"},"name"))
|
||||||
|
|
||||||
|
|
||||||
print "#set options"
|
print("#set options")
|
||||||
sclient.label_set_options("test",{"max_download_speed":999}, True)
|
sclient.label_set_options("test",{"max_download_speed":999}, True)
|
||||||
print sclient.get_torrent_status(id, ["max_download_speed"]) , "999"
|
print(sclient.get_torrent_status(id, ["max_download_speed"]) , "999")
|
||||||
sclient.label_set_options("test",{"max_download_speed":9}, True)
|
sclient.label_set_options("test",{"max_download_speed":9}, True)
|
||||||
print sclient.get_torrent_status(id, ["max_download_speed"]) , "9"
|
print(sclient.get_torrent_status(id, ["max_download_speed"]) , "9")
|
||||||
sclient.label_set_options("test",{"max_download_speed":888}, False)
|
sclient.label_set_options("test",{"max_download_speed":888}, False)
|
||||||
print sclient.get_torrent_status(id, ["max_download_speed"]) , "9 (888)"
|
print(sclient.get_torrent_status(id, ["max_download_speed"]) , "9 (888)")
|
||||||
|
|
||||||
print sclient.get_torrent_status(id,['name', 'tracker_host', 'label'])
|
print(sclient.get_torrent_status(id,['name', 'tracker_host', 'label']))
|
||||||
|
|
|
@ -657,7 +657,7 @@ class GtkUI(GtkPluginBase, GtkUiNotifications):
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
new_filename = dialog.get_filename()
|
new_filename = dialog.get_filename()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
print new_filename
|
log.debug(new_filename)
|
||||||
model.set(iter,
|
model.set(iter,
|
||||||
SND_PATH, new_filename,
|
SND_PATH, new_filename,
|
||||||
SND_NAME, basename(new_filename))
|
SND_NAME, basename(new_filename))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from deluge.ui.client import sclient, aclient
|
from deluge.ui.client import sclient, aclient
|
||||||
sclient.set_core_uri()
|
sclient.set_core_uri()
|
||||||
import graph
|
import graph
|
||||||
|
@ -7,8 +8,8 @@ def test_sync():
|
||||||
if 1:
|
if 1:
|
||||||
upload = sclient.graph_get_upload()
|
upload = sclient.graph_get_upload()
|
||||||
download = sclient.graph_get_download()
|
download = sclient.graph_get_download()
|
||||||
print upload
|
print(upload)
|
||||||
print download
|
print(download)
|
||||||
else:
|
else:
|
||||||
upload = [66804, 66915, 66974, 67447, 67540, 67318, 67320, 67249, 66659, 66489, 67027, 66914, 66802, 67303, 67654, 67643, 67763, 67528, 67523, 67431, 67214, 66939, 67316, 67020, 66881, 67103, 67377, 67141, 67366, 67492, 67375, 67203, 67056, 67010, 67029, 66741, 66695, 66868, 66805, 66264, 66249, 66317, 66459, 66306, 66681, 66954, 66662, 66278, 65921, 65695, 65681, 65942, 66000, 66140, 66424, 66480, 66257, 66271, 66145, 65854, 65568, 65268, 65112, 65050, 65027, 64676, 64655, 64178, 64386, 63979, 63271, 62746, 62337, 62297, 62496, 62902, 63801, 64121, 62957, 62921, 63051, 62644, 63240, 64107, 63968, 63987, 63644, 63263, 63153, 62999, 62843, 62777, 63101, 63078, 63178, 63126, 63401, 62630, 62451, 62505, 62254, 61485, 61264, 60937, 60568, 61011, 61109, 60325, 60196, 59640, 59619, 59514, 60813, 60572, 61632, 61689, 63365, 64583, 66396, 67179, 68209, 68295, 67674, 67559, 67195, 66178, 65632, 66124, 66456, 66676, 67183, 67620, 66960, 66347, 65925, 65907, 65896, 66738, 66703, 67060, 67004, 67007, 66329, 65304, 52002, 38969, 25433, 12426, 0, 0]
|
upload = [66804, 66915, 66974, 67447, 67540, 67318, 67320, 67249, 66659, 66489, 67027, 66914, 66802, 67303, 67654, 67643, 67763, 67528, 67523, 67431, 67214, 66939, 67316, 67020, 66881, 67103, 67377, 67141, 67366, 67492, 67375, 67203, 67056, 67010, 67029, 66741, 66695, 66868, 66805, 66264, 66249, 66317, 66459, 66306, 66681, 66954, 66662, 66278, 65921, 65695, 65681, 65942, 66000, 66140, 66424, 66480, 66257, 66271, 66145, 65854, 65568, 65268, 65112, 65050, 65027, 64676, 64655, 64178, 64386, 63979, 63271, 62746, 62337, 62297, 62496, 62902, 63801, 64121, 62957, 62921, 63051, 62644, 63240, 64107, 63968, 63987, 63644, 63263, 63153, 62999, 62843, 62777, 63101, 63078, 63178, 63126, 63401, 62630, 62451, 62505, 62254, 61485, 61264, 60937, 60568, 61011, 61109, 60325, 60196, 59640, 59619, 59514, 60813, 60572, 61632, 61689, 63365, 64583, 66396, 67179, 68209, 68295, 67674, 67559, 67195, 66178, 65632, 66124, 66456, 66676, 67183, 67620, 66960, 66347, 65925, 65907, 65896, 66738, 66703, 67060, 67004, 67007, 66329, 65304, 52002, 38969, 25433, 12426, 0, 0]
|
||||||
download = [42926, 43853, 43157, 45470, 44254, 46272, 45083, 47344, 46716, 51963, 50112, 52334, 55525, 57545, 53691, 51637, 49574, 49836, 48295, 49843, 52878, 56014, 56966, 56938, 60065, 60461, 56542, 59526, 58678, 54424, 51862, 55109, 52132, 53783, 51687, 56567, 52182, 50758, 46714, 50511, 48161, 50920, 48694, 50528, 55074, 55420, 55882, 59268, 59958, 57938, 57115, 51424, 51180, 53184, 52879, 51177, 54417, 51097, 47901, 49870, 55865, 61118, 61476, 63498, 58878, 49630, 45975, 45632, 45892, 44855, 49495, 48304, 45829, 42152, 39403, 37574, 32384, 34933, 34901, 33492, 31953, 36271, 33826, 34515, 36408, 41106, 43054, 44110, 40810, 41383, 37267, 35881, 38660, 37525, 34857, 36718, 36842, 34281, 39528, 41854, 42952, 40021, 41722, 41045, 42917, 39287, 38672, 32824, 28765, 22686, 18490, 15714, 15268, 14793, 15305, 16354, 16720, 17502, 17857, 16622, 18447, 19929, 31138, 36965, 36158, 32795, 30445, 21997, 18100, 22491, 27227, 29317, 32436, 35700, 39140, 36258, 33697, 24751, 20354, 8211, 3836, 1560, 834, 2034, 1744, 1637, 1637, 1637, 0, 0]
|
download = [42926, 43853, 43157, 45470, 44254, 46272, 45083, 47344, 46716, 51963, 50112, 52334, 55525, 57545, 53691, 51637, 49574, 49836, 48295, 49843, 52878, 56014, 56966, 56938, 60065, 60461, 56542, 59526, 58678, 54424, 51862, 55109, 52132, 53783, 51687, 56567, 52182, 50758, 46714, 50511, 48161, 50920, 48694, 50528, 55074, 55420, 55882, 59268, 59958, 57938, 57115, 51424, 51180, 53184, 52879, 51177, 54417, 51097, 47901, 49870, 55865, 61118, 61476, 63498, 58878, 49630, 45975, 45632, 45892, 44855, 49495, 48304, 45829, 42152, 39403, 37574, 32384, 34933, 34901, 33492, 31953, 36271, 33826, 34515, 36408, 41106, 43054, 44110, 40810, 41383, 37267, 35881, 38660, 37525, 34857, 36718, 36842, 34281, 39528, 41854, 42952, 40021, 41722, 41045, 42917, 39287, 38672, 32824, 28765, 22686, 18490, 15714, 15268, 14793, 15305, 16354, 16720, 17502, 17857, 16622, 18447, 19929, 31138, 36965, 36158, 32795, 30445, 21997, 18100, 22491, 27227, 29317, 32436, 35700, 39140, 36258, 33697, 24751, 20354, 8211, 3836, 1560, 834, 2034, 1744, 1637, 1637, 1637, 0, 0]
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
|
from __future__ import print_function
|
||||||
from deluge.ui.client import sclient, aclient
|
from deluge.ui.client import sclient, aclient
|
||||||
from deluge.common import fsize
|
from deluge.common import fsize
|
||||||
sclient.set_core_uri()
|
sclient.set_core_uri()
|
||||||
|
|
||||||
def print_totals(totals):
|
def print_totals(totals):
|
||||||
for name, value in totals.iteritems():
|
for name, value in totals.iteritems():
|
||||||
print name , fsize(value)
|
print(name , fsize(value))
|
||||||
|
|
||||||
print "overhead:"
|
print("overhead:")
|
||||||
print "up:", fsize(totals["total_upload"] - totals["total_payload_upload"] )
|
print("up:", fsize(totals["total_upload"] - totals["total_payload_upload"] ))
|
||||||
print "down:", fsize(totals["total_download"] - totals["total_payload_download"] )
|
print("down:", fsize(totals["total_download"] - totals["total_payload_download"] ))
|
||||||
|
|
||||||
|
|
||||||
print "==totals=="
|
print("==totals==")
|
||||||
print_totals(sclient.stats_get_totals())
|
print_totals(sclient.stats_get_totals())
|
||||||
|
|
||||||
print "==session totals=="
|
print("==session totals==")
|
||||||
print_totals(sclient.stats_get_session_totals())
|
print_totals(sclient.stats_get_session_totals())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ example:
|
||||||
python create_plugin.py --name MyPlugin2 --basepath . --author-name "Your Name" --author-email "yourname@example.com"
|
python create_plugin.py --name MyPlugin2 --basepath . --author-name "Your Name" --author-email "yourname@example.com"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -27,23 +28,23 @@ parser.add_option("-c", "--config", dest="configdir", help="location of deluge c
|
||||||
|
|
||||||
def create_plugin():
|
def create_plugin():
|
||||||
if not options.name:
|
if not options.name:
|
||||||
print "--name is mandatory , use -h for more info"
|
print("--name is mandatory , use -h for more info")
|
||||||
return
|
return
|
||||||
if not options.path:
|
if not options.path:
|
||||||
print "--basepath is mandatory , use -h for more info"
|
print("--basepath is mandatory , use -h for more info")
|
||||||
return
|
return
|
||||||
if not options.author_email:
|
if not options.author_email:
|
||||||
print "--author-email is mandatory , use -h for more info"
|
print("--author-email is mandatory , use -h for more info")
|
||||||
return
|
return
|
||||||
if not options.author_email:
|
if not options.author_email:
|
||||||
print "--author-name is mandatory , use -h for more info"
|
print("--author-name is mandatory , use -h for more info")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not options.url:
|
if not options.url:
|
||||||
options.url = ""
|
options.url = ""
|
||||||
|
|
||||||
if not os.path.exists(options.path):
|
if not os.path.exists(options.path):
|
||||||
print "basepath does not exist"
|
print("basepath does not exist")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not options.configdir:
|
if not options.configdir:
|
||||||
|
@ -64,7 +65,7 @@ def create_plugin():
|
||||||
python_path = sys.executable
|
python_path = sys.executable
|
||||||
|
|
||||||
if os.path.exists(plugin_base):
|
if os.path.exists(plugin_base):
|
||||||
print "the directory %s already exists, delete it first" % plugin_base
|
print("the directory %s already exists, delete it first" % plugin_base)
|
||||||
return
|
return
|
||||||
|
|
||||||
def write_file(path, filename, template, include_gpl=True):
|
def write_file(path, filename, template, include_gpl=True):
|
||||||
|
@ -88,14 +89,14 @@ def create_plugin():
|
||||||
f.write(template % args)
|
f.write(template % args)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
print "creating folders.."
|
print("creating folders..")
|
||||||
os.mkdir(plugin_base)
|
os.mkdir(plugin_base)
|
||||||
os.mkdir(deluge_namespace)
|
os.mkdir(deluge_namespace)
|
||||||
os.mkdir(plugins_namespace)
|
os.mkdir(plugins_namespace)
|
||||||
os.mkdir(src)
|
os.mkdir(src)
|
||||||
os.mkdir(data_dir)
|
os.mkdir(data_dir)
|
||||||
|
|
||||||
print "creating files.."
|
print("creating files..")
|
||||||
write_file(plugin_base,"setup.py", SETUP)
|
write_file(plugin_base,"setup.py", SETUP)
|
||||||
write_file(deluge_namespace, "__init__.py", NAMESPACE_INIT, False)
|
write_file(deluge_namespace, "__init__.py", NAMESPACE_INIT, False)
|
||||||
write_file(plugins_namespace, "__init__.py", NAMESPACE_INIT, False)
|
write_file(plugins_namespace, "__init__.py", NAMESPACE_INIT, False)
|
||||||
|
@ -108,7 +109,7 @@ def create_plugin():
|
||||||
write_file(data_dir, "%s.js" % safe_name, DEFAULT_JS)
|
write_file(data_dir, "%s.js" % safe_name, DEFAULT_JS)
|
||||||
|
|
||||||
#add an input parameter for this?
|
#add an input parameter for this?
|
||||||
print "building dev-link.."
|
print("building dev-link..")
|
||||||
write_file(plugin_base,"create_dev_link.sh", CREATE_DEV_LINK)
|
write_file(plugin_base,"create_dev_link.sh", CREATE_DEV_LINK)
|
||||||
dev_link_path = os.path.join(plugin_base, "create_dev_link.sh")
|
dev_link_path = os.path.join(plugin_base, "create_dev_link.sh")
|
||||||
os.system("chmod +x %s" % dev_link_path) #lazy..
|
os.system("chmod +x %s" % dev_link_path) #lazy..
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
@ -42,7 +43,7 @@ import pydoc
|
||||||
import inspect
|
import inspect
|
||||||
import textwrap
|
import textwrap
|
||||||
sclient.set_core_uri()
|
sclient.set_core_uri()
|
||||||
print "\n\n"
|
print("\n\n")
|
||||||
|
|
||||||
|
|
||||||
if 0: #aclient non-core
|
if 0: #aclient non-core
|
||||||
|
@ -97,21 +98,21 @@ if 0: #plugin-manager
|
||||||
print("%s" % pydoc.getdoc(func))
|
print("%s" % pydoc.getdoc(func))
|
||||||
|
|
||||||
if 0: #possible config-values
|
if 0: #possible config-values
|
||||||
print "=== config-values ==="
|
print("=== config-values ===")
|
||||||
cfg = sclient.get_sconfig()
|
cfg = sclient.get_sconfig()
|
||||||
for key in sorted(cfg.keys()):
|
for key in sorted(cfg.keys()):
|
||||||
print "%s:%s()" % (key, type(cfg[key]).__name__)
|
print("%s:%s()" % (key, type(cfg[key]).__name__))
|
||||||
|
|
||||||
if 0: #keys
|
if 0: #keys
|
||||||
print """== Notes ==
|
print("""== Notes ==
|
||||||
* The available keys for get_torrent_status(id, keys)
|
* The available keys for get_torrent_status(id, keys)
|
||||||
{{{
|
{{{
|
||||||
#!python
|
#!python
|
||||||
>>>sorted(sclient.get_status_keys())"""
|
>>>sorted(sclient.get_status_keys())""")
|
||||||
print "\n".join(textwrap.wrap(str(sorted(sclient.get_status_keys())),100))
|
print("\n".join(textwrap.wrap(str(sorted(sclient.get_status_keys())),100)))
|
||||||
print """}}}"""
|
print("""}}}""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "\n\n"
|
print("\n\n")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
from __future__ import print_function
|
||||||
import deluge.pluginmanagerbase
|
import deluge.pluginmanagerbase
|
||||||
pm = deluge.pluginmanagerbase.PluginManagerBase("core.conf", "deluge.plugin.core")
|
pm = deluge.pluginmanagerbase.PluginManagerBase("core.conf", "deluge.plugin.core")
|
||||||
|
|
||||||
for p in pm.get_available_plugins():
|
for p in pm.get_available_plugins():
|
||||||
print "Plugin: %s" % (p)
|
print("Plugin: %s" % (p))
|
||||||
for k, v in pm.get_plugin_info(p).items():
|
for k, v in pm.get_plugin_info(p).items():
|
||||||
print "%s: %s" % (k, v)
|
print("%s: %s" % (k, v))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -61,10 +62,10 @@ class TorrentTestCase(unittest.TestCase):
|
||||||
tmp = ''
|
tmp = ''
|
||||||
for i, p in enumerate(priorities):
|
for i, p in enumerate(priorities):
|
||||||
if i % 100 == 0:
|
if i % 100 == 0:
|
||||||
print tmp
|
print(tmp)
|
||||||
tmp = ''
|
tmp = ''
|
||||||
tmp += "%s" % p
|
tmp += "%s" % p
|
||||||
print tmp
|
print(tmp)
|
||||||
|
|
||||||
def get_torrent_atp(self, filename):
|
def get_torrent_atp(self, filename):
|
||||||
filename = os.path.join(os.path.dirname(__file__), filename)
|
filename = os.path.join(os.path.dirname(__file__), filename)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# test_transfer.py
|
# test_transfer.py
|
||||||
|
@ -78,11 +79,11 @@ class TransferTestClass(DelugeTransferProtocol):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import zlib
|
import zlib
|
||||||
print "\n=== New Data Received ===\nBytes received:", len(data)
|
print("\n=== New Data Received ===\nBytes received:", len(data))
|
||||||
|
|
||||||
if self._buffer:
|
if self._buffer:
|
||||||
# We have some data from the last dataReceived() so lets prepend it
|
# We have some data from the last dataReceived() so lets prepend it
|
||||||
print "Current buffer:", len(self._buffer) if self._buffer else "0"
|
print("Current buffer:", len(self._buffer) if self._buffer else "0")
|
||||||
data = self._buffer + data
|
data = self._buffer + data
|
||||||
self._buffer = None
|
self._buffer = None
|
||||||
|
|
||||||
|
@ -90,10 +91,10 @@ class TransferTestClass(DelugeTransferProtocol):
|
||||||
self._bytes_received += len(data)
|
self._bytes_received += len(data)
|
||||||
|
|
||||||
while data:
|
while data:
|
||||||
print "\n-- Handle packet data --"
|
print("\n-- Handle packet data --")
|
||||||
|
|
||||||
print "Bytes received:", self._bytes_received
|
print("Bytes received:", self._bytes_received)
|
||||||
print "Current data:", len(data)
|
print("Current data:", len(data))
|
||||||
|
|
||||||
if self._message_length == 0:
|
if self._message_length == 0:
|
||||||
# handle_new_message uses _buffer so set data to _buffer.
|
# handle_new_message uses _buffer so set data to _buffer.
|
||||||
|
@ -102,21 +103,21 @@ class TransferTestClass(DelugeTransferProtocol):
|
||||||
data = self._buffer
|
data = self._buffer
|
||||||
self._buffer = None
|
self._buffer = None
|
||||||
self.packet_count = 1
|
self.packet_count = 1
|
||||||
print "New message of length:", self._message_length
|
print("New message of length:", self._message_length)
|
||||||
|
|
||||||
dobj = zlib.decompressobj()
|
dobj = zlib.decompressobj()
|
||||||
try:
|
try:
|
||||||
request = rencode.loads(dobj.decompress(data))
|
request = rencode.loads(dobj.decompress(data))
|
||||||
print "Successfully loaded message",
|
print("Successfully loaded message", end=' ')
|
||||||
print " - Buffer length: %d, data length: %d, unused length: %d" % \
|
print(" - Buffer length: %d, data length: %d, unused length: %d" % \
|
||||||
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data))
|
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data)))
|
||||||
print "Packet count:", self.packet_count
|
print("Packet count:", self.packet_count)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
#log.debug("Received possible invalid message (%r): %s", data, e)
|
#log.debug("Received possible invalid message (%r): %s", data, e)
|
||||||
# This could be cut-off data, so we'll save this in the buffer
|
# This could be cut-off data, so we'll save this in the buffer
|
||||||
# and try to prepend it on the next dataReceived()
|
# and try to prepend it on the next dataReceived()
|
||||||
self._buffer = data
|
self._buffer = data
|
||||||
print "Failed to load buffer (size %d): %s" % (len(self._buffer), str(ex))
|
print("Failed to load buffer (size %d): %s" % (len(self._buffer), str(ex)))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
data = dobj.unused_data
|
data = dobj.unused_data
|
||||||
|
@ -258,15 +259,15 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
||||||
three_messages_byte_count = two_messages_byte_count + \
|
three_messages_byte_count = two_messages_byte_count + \
|
||||||
len(base64.b64decode(self.msg1_expected_compressed_base64))
|
len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||||
|
|
||||||
print
|
print()
|
||||||
|
|
||||||
print "Msg1 size:", len(base64.b64decode(self.msg1_expected_compressed_base64)) - 4
|
print("Msg1 size:", len(base64.b64decode(self.msg1_expected_compressed_base64)) - 4)
|
||||||
print "Msg2 size:", len(base64.b64decode(self.msg2_expected_compressed_base64)) - 4
|
print("Msg2 size:", len(base64.b64decode(self.msg2_expected_compressed_base64)) - 4)
|
||||||
print "Msg3 size:", len(base64.b64decode(self.msg1_expected_compressed_base64)) - 4
|
print("Msg3 size:", len(base64.b64decode(self.msg1_expected_compressed_base64)) - 4)
|
||||||
|
|
||||||
print "one_message_byte_count:", one_message_byte_count
|
print("one_message_byte_count:", one_message_byte_count)
|
||||||
print "two_messages_byte_count:", two_messages_byte_count
|
print("two_messages_byte_count:", two_messages_byte_count)
|
||||||
print "three_messages_byte_count:", three_messages_byte_count
|
print("three_messages_byte_count:", three_messages_byte_count)
|
||||||
|
|
||||||
for d in self.receive_parts_helper(msg_bytes, packet_size, self.transfer.dataReceived_old_protocol):
|
for d in self.receive_parts_helper(msg_bytes, packet_size, self.transfer.dataReceived_old_protocol):
|
||||||
bytes_received = self.transfer.get_bytes_recv()
|
bytes_received = self.transfer.get_bytes_recv()
|
||||||
|
@ -281,8 +282,8 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
||||||
expected_msgs_received_count = 0
|
expected_msgs_received_count = 0
|
||||||
# Verify that the expected number of complete messages has arrived
|
# Verify that the expected number of complete messages has arrived
|
||||||
if expected_msgs_received_count != len(self.transfer.get_messages_in()):
|
if expected_msgs_received_count != len(self.transfer.get_messages_in()):
|
||||||
print "Expected number of messages received is %d, but %d have been received." % \
|
print("Expected number of messages received is %d, but %d have been received." % \
|
||||||
(expected_msgs_received_count, len(self.transfer.get_messages_in()))
|
(expected_msgs_received_count, len(self.transfer.get_messages_in())))
|
||||||
|
|
||||||
# Get the data as received by DelugeTransferProtocol
|
# Get the data as received by DelugeTransferProtocol
|
||||||
message1 = self.transfer.get_messages_in().pop(0)
|
message1 = self.transfer.get_messages_in().pop(0)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
#
|
#
|
||||||
# commander.py
|
# commander.py
|
||||||
#
|
#
|
||||||
|
@ -139,9 +140,9 @@ class Commander:
|
||||||
else:
|
else:
|
||||||
rm = reason.getErrorMessage()
|
rm = reason.getErrorMessage()
|
||||||
if host:
|
if host:
|
||||||
print "Could not connect to daemon: %s:%s\n %s" % (host, port, rm)
|
print("Could not connect to daemon: %s:%s\n %s" % (host, port, rm))
|
||||||
else:
|
else:
|
||||||
print "Could not connect to localhost daemon\n %s" % rm
|
print("Could not connect to localhost daemon\n %s" % rm)
|
||||||
self.do_command("quit")
|
self.do_command("quit")
|
||||||
|
|
||||||
if host:
|
if host:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
#
|
#
|
||||||
# main.py
|
# main.py
|
||||||
#
|
#
|
||||||
|
@ -190,7 +191,7 @@ class OptionParser(optparse.OptionParser):
|
||||||
def exit(self, status=0, msg=None):
|
def exit(self, status=0, msg=None):
|
||||||
self.values._exit = True
|
self.values._exit = True
|
||||||
if msg:
|
if msg:
|
||||||
print msg
|
print(msg)
|
||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg):
|
||||||
"""error(msg : string)
|
"""error(msg : string)
|
||||||
|
@ -317,7 +318,7 @@ class ConsoleUI(component.Component):
|
||||||
args = ' '.join(args)
|
args = ' '.join(args)
|
||||||
self.interactive = False
|
self.interactive = False
|
||||||
if not cmds:
|
if not cmds:
|
||||||
print "Sorry, couldn't find any commands"
|
print("Sorry, couldn't find any commands")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
from commander import Commander
|
from commander import Commander
|
||||||
|
@ -334,13 +335,13 @@ class ConsoleUI(component.Component):
|
||||||
import curses.wrapper
|
import curses.wrapper
|
||||||
curses.wrapper(self.run)
|
curses.wrapper(self.run)
|
||||||
elif self.interactive and deluge.common.windows_check():
|
elif self.interactive and deluge.common.windows_check():
|
||||||
print """\nDeluge-console does not run in interactive mode on Windows. \n
|
print("""\nDeluge-console does not run in interactive mode on Windows. \n
|
||||||
Please use commands from the command line, eg:\n
|
Please use commands from the command line, eg:\n
|
||||||
deluge-console.exe help
|
deluge-console.exe help
|
||||||
deluge-console.exe info
|
deluge-console.exe info
|
||||||
deluge-console.exe "add --help"
|
deluge-console.exe "add --help"
|
||||||
deluge-console.exe "add -p c:\\mytorrents c:\\new.torrent"
|
deluge-console.exe "add -p c:\\mytorrents c:\\new.torrent"
|
||||||
"""
|
""")
|
||||||
else:
|
else:
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
|
@ -452,7 +453,7 @@ Please use commands from the command line, eg:\n
|
||||||
component.get("LegacyUI").add_line(s, False)
|
component.get("LegacyUI").add_line(s, False)
|
||||||
self.events.append(s)
|
self.events.append(s)
|
||||||
else:
|
else:
|
||||||
print colors.strip_colors(s.encode(self.encoding))
|
print(colors.strip_colors(s.encode(self.encoding)))
|
||||||
|
|
||||||
def write_event(self, s):
|
def write_event(self, s):
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
|
@ -463,4 +464,4 @@ Please use commands from the command line, eg:\n
|
||||||
component.get("LegacyUI").add_line(s, False)
|
component.get("LegacyUI").add_line(s, False)
|
||||||
self.events.append(s)
|
self.events.append(s)
|
||||||
else:
|
else:
|
||||||
print colors.strip_colors(s.encode(self.encoding))
|
print(colors.strip_colors(s.encode(self.encoding)))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
@ -1560,7 +1561,7 @@ if __name__ == "__main__":
|
||||||
entry2.set_filechooser_button_enabled(False)
|
entry2.set_filechooser_button_enabled(False)
|
||||||
|
|
||||||
def list_value_added_event(widget, values):
|
def list_value_added_event(widget, values):
|
||||||
print "Current list values:", widget.get_values()
|
print("Current list values:", widget.get_values())
|
||||||
|
|
||||||
entry1.connect("list-value-added", list_value_added_event)
|
entry1.connect("list-value-added", list_value_added_event)
|
||||||
entry2.connect("list-value-added", list_value_added_event)
|
entry2.connect("list-value-added", list_value_added_event)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# torrentview_data_funcs.py
|
# torrentview_data_funcs.py
|
||||||
#
|
#
|
||||||
|
@ -184,7 +185,7 @@ def cell_data_speed(cell, model, row, data, cache_key):
|
||||||
try:
|
try:
|
||||||
speed = model.get_value(row, data)
|
speed = model.get_value(row, data)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print "AttributeError"
|
print("AttributeError")
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
if func_last_value[cache_key] == speed:
|
if func_last_value[cache_key] == speed:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
#
|
#
|
||||||
# ui.py
|
# ui.py
|
||||||
#
|
#
|
||||||
|
@ -49,10 +50,10 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
def version_callback(option, opt_str, value, parser):
|
def version_callback(option, opt_str, value, parser):
|
||||||
print os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version()
|
print(os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version())
|
||||||
try:
|
try:
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
print "libtorrent: %s" % lt.version
|
print("libtorrent: %s" % lt.version)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
|
@ -136,11 +137,11 @@ class Web(_UI):
|
||||||
# Twisted catches signals to terminate
|
# Twisted catches signals to terminate
|
||||||
def save_profile_stats():
|
def save_profile_stats():
|
||||||
profiler.dump_stats(profile_output)
|
profiler.dump_stats(profile_output)
|
||||||
print "Profile stats saved to %s" % profile_output
|
print("Profile stats saved to %s" % profile_output)
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
reactor.addSystemEventTrigger("before", "shutdown", save_profile_stats)
|
reactor.addSystemEventTrigger("before", "shutdown", save_profile_stats)
|
||||||
print "Running with profiler..."
|
print("Running with profiler...")
|
||||||
profiler.runcall(run_server)
|
profiler.runcall(run_server)
|
||||||
else:
|
else:
|
||||||
run_server()
|
run_server()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue