marty 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/marty/rpc_call.rb +30 -14
- data/lib/marty/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb347975c0c4442e6466f8cbcbd72d431c85f45f
|
|
4
|
+
data.tar.gz: 4c7de97777049441bbf43ea5d324ed1a4c858315
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc0b688584580e74b519a04559d0c3dd6bcbc0d3fc2e00949403a32c54ef25f78380573238f8d80d048ce434d3c936a6c455db94c1a2945065ea4c39525b277d
|
|
7
|
+
data.tar.gz: 7318c212db79212f25ad3fcfc3f27d28e666f1948d333b93f7ab5d5689e5eb4f16f54873a02d016eff9678bd607a7edce244d3234b94e2229c05b7313149197b
|
data/lib/marty/rpc_call.rb
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
class Marty::RpcCall
|
|
2
|
-
|
|
2
|
+
# POST to a remote marty
|
|
3
|
+
def self.marty_post(host, port, path, script, node, attrs, params, options={})
|
|
3
4
|
http = Net::HTTP.new(host, port)
|
|
4
5
|
request = Net::HTTP::Post.new(path)
|
|
5
6
|
request.add_field('Content-Type', 'application/json')
|
|
6
|
-
request.body = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
request.body = (options + {
|
|
8
|
+
"script" => script,
|
|
9
|
+
"node" => node,
|
|
10
|
+
"attrs" => attrs.to_json,
|
|
11
|
+
"params" => params.to_json,
|
|
12
|
+
}).to_json
|
|
12
13
|
begin
|
|
13
|
-
|
|
14
|
+
response = http.request(request)
|
|
14
15
|
rescue => e
|
|
15
16
|
raise "#{e.message} during RPC call to #{host}:#{port}"
|
|
16
17
|
end
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
res = JSON.parse(response.body)
|
|
18
20
|
raise res["error"] if res.is_a?(Hash) && !res["error"].blank?
|
|
19
21
|
res
|
|
20
22
|
end
|
|
21
23
|
|
|
24
|
+
def self.marty_download(host, port, path, job_id)
|
|
25
|
+
params = {job_id: job_id}
|
|
26
|
+
url = path + '?' + URI.encode(URI.encode_www_form(params))
|
|
27
|
+
|
|
28
|
+
http = Net::HTTP.new(host, port)
|
|
29
|
+
request = Net::HTTP::Get.new(url)
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
http.request(request)
|
|
33
|
+
rescue => e
|
|
34
|
+
raise "#{e.message} during download call to #{host}:#{port}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
22
38
|
def self.xml_call(host, port, path, body, use_ssl)
|
|
23
39
|
http = Net::HTTP.new(host, port)
|
|
24
40
|
request = Net::HTTP::Post.new(path)
|
|
@@ -26,14 +42,14 @@ class Marty::RpcCall
|
|
|
26
42
|
request.add_field('Content-Type', 'xml')
|
|
27
43
|
request.add_field('Accept', 'xml')
|
|
28
44
|
request.body = body
|
|
45
|
+
|
|
29
46
|
begin
|
|
30
|
-
|
|
31
|
-
if
|
|
32
|
-
raise "got #{resraw} during XML call"
|
|
33
|
-
end
|
|
47
|
+
response = http.request(request)
|
|
48
|
+
raise "got #{response} during XML call" if response.class != Net::HTTPOK
|
|
34
49
|
rescue => e
|
|
35
50
|
raise "#{e.message} during RPC call to #{host}:#{port}#{path}"
|
|
36
51
|
end
|
|
37
|
-
|
|
52
|
+
|
|
53
|
+
response.body
|
|
38
54
|
end
|
|
39
55
|
end
|
data/lib/marty/version.rb
CHANGED