[Xfce4-commits] <eatmonkey:aria2-xml-rpc> Make the client work for aria 1.4

Mike Massonnet noreply at xfce.org
Mon Feb 8 21:50:01 CET 2010


Updating branch refs/heads/aria2-xml-rpc
         to a172abbe6f851c35f42a0851fb175c09490e4ccb (commit)
       from b433d58a5ba6e170ae8d8a07ce11d5342e71476d (commit)

commit a172abbe6f851c35f42a0851fb175c09490e4ccb
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Mon Feb 8 21:38:19 2010 +0100

    Make the client work for aria 1.4
    
    Add a new command to spawn for the local server without the option
    xml-rpc-listen-all so that it works for aria < 1.6.
    
    Also try with the XML-RPC method aria2.tellActive instead of getVersion
    (aria 1.4 doesn't support it) to notice if the server is responding
    properly.

 src/eataria2.rb |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/eataria2.rb b/src/eataria2.rb
index 28b2d55..c441b62 100644
--- a/src/eataria2.rb
+++ b/src/eataria2.rb
@@ -137,10 +137,17 @@ class Eat::Aria2 < GLib::Object
 						"--conf-path=#{@confdir}/aria2.conf --log=#{@confdir}/aria2.log --log-level=notice"
 					@@pid = spawn_server(command)
 				rescue Timeout::Error
+				begin
+					# Retry with even fewer arguments for aria2 < 1.5
+					command = "aria2c --enable-xml-rpc --xml-rpc-listen-port=#{@port} " \
+						"--conf-path=#{@confdir}/aria2.conf --log=#{@confdir}/aria2.log --log-level=notice"
+					@@pid = spawn_server(command)
+				rescue Timeout::Error
 					@@pid = 0
 					raise "Failed to get positive response from aria2"
 				end
 				end
+				end
 				# Store pid in a file
 				begin
 					File.open(@confdir+"/aria2.pid", "w").puts(@@pid)
@@ -166,7 +173,7 @@ class Eat::Aria2 < GLib::Object
 		Timeout::timeout(5) do
 			begin
 				begin
-					result = @@client.call("aria2.getVersion")
+					result = @@client.call("aria2.tellActive")
 				rescue
 				end
 				sleep 1 if result == nil
@@ -221,9 +228,11 @@ class Eat::Aria2 < GLib::Object
 				@@client = XMLRPC::Client.new3({:host => @hostname, :path => "/rpc",
 						:port => @port, :user => @user, :password => @password,
 						:timeout => 60})
-				result = call("aria2.getVersion")
+				result = call("aria2.tellActive")
 				raise Exception.new("Unable to connect to aria2 XML-RPC server") if result == nil
-				@version = result["version"]
+				# aria2 1.4 doesn't provide aria2.getVersion method
+				result = call("aria2.getVersion")
+				@version = result != nil ? result["version"] : "1.4"
 				@is_connected = true
 				signal_emit("connected")
 			rescue Exception => e



More information about the Xfce4-commits mailing list