exit 1
end
-def query_system_info(ip, port)
- # HOST SYSTEM INFO
- puts "* SYSTEM INFO *"
+def query( ip, port, sym )
client = BuildCommClient.create( ip, port, nil, 0 )
- if not client.nil? then
- client.send "QUERY|SYSTEM"
- result0 = client.receive_data()
- if result0.nil? then
- client.terminate
- exit 1
- end
- result0 = result0[0].split(",").map { |x| x.strip }
- puts "HOST-OS: #{result0[0]}"
- puts "MAX_WORKING_JOBS: #{result0[1]}"
- client.terminate
- else
+ if client.nil? then
puts "Connection to server failed!"
- exit 1
+ return nil
end
+ client.send "QUERY|#{sym.strip}"
+ result = client.receive_data()
+ client.terminate
+ return result
+end
+
+def query_system_info(ip, port)
+ # HOST SYSTEM INFO
+ puts "* SYSTEM INFO *"
+ data = query( ip, port, "SYSTEM")
+ if data.nil? then exit 1 end
+
+ result = data[0].split(",").map { |x| x.strip }
+ puts "HOST-OS: #{result[0]}"
+ puts "MAX_WORKING_JOBS: #{result[1]}"
# FTP INFO
- puts ""
- puts "* FTP *"
- client = BuildCommClient.create( ip, port )
- if not client.nil? then
- client.send "QUERY|FTP"
- result0 = client.receive_data()
- if result0.nil? then
- client.terminate
- exit 1
- end
- result0 = result0[0].split(",").map { |x| x.strip }
- puts "FTP_ADDR: #{result0[0]}"
- puts "FTP_USERNAME: #{result0[1]}"
- client.terminate
- else
- puts "Connection to server failed!"
- exit 1
- end
+ puts "\n* FTP *"
+ data = query(ip, port, "FTP")
+ if data.nil? then exit 1 end
+
+ result = data[0].split(",").map { |x| x.strip }
+ puts "FTP_ADDR: #{result[0]}"
+ puts "FTP_USERNAME: #{result[1]}"
# SUPPORTED OS INFO
- puts ""
- puts "* SUPPORTED OS LIST *"
- client = BuildCommClient.create( ip, port )
- if not client.nil? then
- client.send "QUERY|OS"
- result0 = client.receive_data()
- if not result0.nil? then
- result0.each do |item|
- puts "#{item.strip}"
- end
- end
- client.terminate
- else
- puts "Connection to server failed!"
- exit 1
+ puts "\n* SUPPORTED OS LIST *"
+ data = query(ip, port, "OS")
+ if data.nil? then exit 1 end
+
+ data.each do |item|
+ puts "#{item.strip}"
+ end
+
+ # Friend lists
+ puts "\n* FRIEND SERVER LIST (WAIT|WORK/MAX) jobs [transfer count] *"
+ data = query(ip, port, "FRIEND")
+ if data.nil? then exit 1 end
+ i = 0
+ data.each do |item|
+ i = i + 1
+ info = item.split(",").map { |x| x.strip }
+ puts "#{i}. #{info[0]} server (#{info[1]}|#{info[2]}/#{info[3]}) [#{info[4]}]"
end
end
def query_project_list(ip, port)
puts "* PROJECT(S) *"
- client = BuildCommClient.create( ip, port, nil, 0 )
- if not client.nil? then
- client.send "QUERY|PROJECT"
- result1 = client.receive_data()
- if result1.nil? then
- client.terminate
- exit 1
- end
- result1.each do |item|
- tok = item.split(",").map { |x| x.strip }
- type = (tok[0]=="G" ? "NORMAL":"REMOTE")
- printf("%-25s %s\n",tok[1],type)
- end
- else
- puts "Connection to server failed!"
- exit 1
+ data = query( ip, port, "PROJECT")
+ data.each do |item|
+ tok = item.split(",").map { |x| x.strip }
+ type = (tok[0]=="G" ? "NORMAL":"REMOTE")
+ printf("%-25s %s\n",tok[1],type)
end
end
def query_job_list(ip, port)
puts "* JOB(S) *"
- client = BuildCommClient.create( ip, port, nil, 0 )
- if not client.nil? then
- client.send "QUERY|JOB"
- result1 = client.receive_data()
- if result1.nil? then
- client.terminate
- exit 1
- end
- result1.each do |item|
- tok = item.split(",").map { |x| x.strip }
- if tok[3].nil? then
- puts "#{tok[1]} #{tok[0]} #{tok[2]}"
- else
- puts "#{tok[1]} #{tok[0]} #{tok[2]} (#{tok[3]})"
- end
+ data = query(ip, port, "JOB")
+ data.each do |item|
+ tok = item.split(",").map { |x| x.strip }
+ if tok[3].nil? then
+ puts "#{tok[1]} #{tok[0]} #{tok[2]}"
+ else
+ puts "#{tok[1]} #{tok[0]} #{tok[2]} (#{tok[3]})"
end
- else
- puts "Connection to server failed!"
- exit 1
end
end