zillabyte-cli 0.9.36 → 0.9.37
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/zillabyte-cli/version.rb +1 -1
- data/lib/zillabyte/api/flows.rb +124 -0
- data/lib/zillabyte/cli.rb +2 -0
- data/lib/zillabyte/cli/apps.rb +28 -0
- data/lib/zillabyte/cli/data.rb +5 -6
- data/lib/zillabyte/cli/download.rb +1 -1
- data/lib/zillabyte/cli/flows.rb +212 -2
- data/lib/zillabyte/command.rb +59 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd191d13ac7c5d6d01086ece5b6d708ce181ca46
|
|
4
|
+
data.tar.gz: 7df48d7dd5cf14ff444460fae31dbdfdc8c7dfa0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c9a0577619d019f5f5135e0e2f55cd36cc940234d64f755d1b81c9d9acd393bcc09d3c4b9d86037f96848212b09e9aec9f7f1961d243b53c4b887a3f9d73812
|
|
7
|
+
data.tar.gz: 639ef72ed7257daa641b6f38aea8f8b820cfda6ea366570e69bc17333efba865983f6261e54206bb651475a88c700fe74dfdd7d3689d7d0259f342ef5ee53c6f
|
data/lib/zillabyte/api/flows.rb
CHANGED
|
@@ -49,6 +49,115 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
|
49
49
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
# POST /flows/id/scale
|
|
53
|
+
def create_scale(id, options = {})
|
|
54
|
+
|
|
55
|
+
options = {
|
|
56
|
+
# TODO
|
|
57
|
+
}.merge(options)
|
|
58
|
+
|
|
59
|
+
res = @api.request(
|
|
60
|
+
:expects => 200,
|
|
61
|
+
:method => :post,
|
|
62
|
+
:path => "/flows/#{id}/scale",
|
|
63
|
+
:body => options.to_json
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
res.body
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# GET /flows/id/scale
|
|
71
|
+
def poll_scale(id, options = {})
|
|
72
|
+
|
|
73
|
+
options = {
|
|
74
|
+
# TODO
|
|
75
|
+
}.merge(options)
|
|
76
|
+
|
|
77
|
+
res = @api.request(
|
|
78
|
+
:expects => 200,
|
|
79
|
+
:method => :get,
|
|
80
|
+
:path => "/flows/#{id}/scale",
|
|
81
|
+
:body => options.to_json
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
res.body
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# POST /flows/id/pause
|
|
90
|
+
def create_pause(id, options = {})
|
|
91
|
+
|
|
92
|
+
options = {
|
|
93
|
+
# TODO
|
|
94
|
+
}.merge(options)
|
|
95
|
+
|
|
96
|
+
res = @api.request(
|
|
97
|
+
:expects => 200,
|
|
98
|
+
:method => :post,
|
|
99
|
+
:path => "/flows/#{id}/pause",
|
|
100
|
+
:body => options.to_json
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
res.body
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# GET /flows/id/pause
|
|
108
|
+
def poll_pause(id, options = {})
|
|
109
|
+
|
|
110
|
+
options = {
|
|
111
|
+
# TODO
|
|
112
|
+
}.merge(options)
|
|
113
|
+
|
|
114
|
+
res = @api.request(
|
|
115
|
+
:expects => 200,
|
|
116
|
+
:method => :get,
|
|
117
|
+
:path => "/flows/#{id}/pause",
|
|
118
|
+
:body => options.to_json
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
res.body
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# POST /flows/id/kill
|
|
126
|
+
def create_resume(id, options = {})
|
|
127
|
+
|
|
128
|
+
options = {
|
|
129
|
+
# TODO
|
|
130
|
+
}.merge(options)
|
|
131
|
+
res = @api.request(
|
|
132
|
+
:expects => 200,
|
|
133
|
+
:method => :post,
|
|
134
|
+
:path => "/flows/#{id}/resume",
|
|
135
|
+
:body => options.to_json
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
res.body
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# GET /flows/id/kill
|
|
143
|
+
def poll_resume(id, options = {})
|
|
144
|
+
|
|
145
|
+
options = {
|
|
146
|
+
# TODO
|
|
147
|
+
}.merge(options)
|
|
148
|
+
|
|
149
|
+
res = @api.request(
|
|
150
|
+
:expects => 200,
|
|
151
|
+
:method => :get,
|
|
152
|
+
:path => "/flows/#{id}/resume",
|
|
153
|
+
:body => options.to_json
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
res.body
|
|
157
|
+
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
|
|
52
161
|
# POST /flows/id/delete
|
|
53
162
|
def create_delete(id, options = {})
|
|
54
163
|
|
|
@@ -85,6 +194,21 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
|
85
194
|
|
|
86
195
|
end
|
|
87
196
|
|
|
197
|
+
|
|
198
|
+
# GET /flows/id/config
|
|
199
|
+
def get_meta(id, options = {})
|
|
200
|
+
|
|
201
|
+
res = @api.request(
|
|
202
|
+
:expects => 200,
|
|
203
|
+
:method => :get,
|
|
204
|
+
:path => "/flows/#{id}/config",
|
|
205
|
+
:body => options.to_json
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
res.body
|
|
209
|
+
|
|
210
|
+
end
|
|
211
|
+
|
|
88
212
|
# GET /flows/id/download
|
|
89
213
|
def pull_to_directory(id, dir, session = nil, options = {})
|
|
90
214
|
require("zillabyte/common/tar")
|
data/lib/zillabyte/cli.rb
CHANGED
|
@@ -7,7 +7,9 @@ module Zillabyte; module CLI
|
|
|
7
7
|
command = args.shift().strip() rescue "help"
|
|
8
8
|
require("zillabyte/command")
|
|
9
9
|
Zillabyte::Command.load(command)
|
|
10
|
+
thr = Thread.new{Zillabyte::Command.tracker(command, args)}
|
|
10
11
|
Zillabyte::Command.run(command, args)
|
|
12
|
+
thr.join
|
|
11
13
|
rescue Interrupt
|
|
12
14
|
`stty icanon echo`
|
|
13
15
|
Zillabyte::Helpers.error("Command cancelled.")
|
data/lib/zillabyte/cli/apps.rb
CHANGED
|
@@ -289,6 +289,34 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
|
|
|
289
289
|
def test
|
|
290
290
|
super
|
|
291
291
|
end
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
# apps:pause [ID]
|
|
295
|
+
#
|
|
296
|
+
# Pause an app
|
|
297
|
+
#
|
|
298
|
+
#
|
|
299
|
+
def pause
|
|
300
|
+
super
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# apps:resume [ID]
|
|
304
|
+
#
|
|
305
|
+
# Resume a paused app
|
|
306
|
+
#
|
|
307
|
+
#
|
|
308
|
+
def resume
|
|
309
|
+
super
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
# apps:scale ID OPERATION_NAME PARALLELISM
|
|
314
|
+
#
|
|
315
|
+
# Change the parallelism of of app or operation
|
|
316
|
+
def scale
|
|
317
|
+
super
|
|
318
|
+
end
|
|
319
|
+
|
|
292
320
|
|
|
293
321
|
|
|
294
322
|
|
data/lib/zillabyte/cli/data.rb
CHANGED
|
@@ -280,7 +280,7 @@ class Zillabyte::Command::Data < Zillabyte::Command::Base
|
|
|
280
280
|
#
|
|
281
281
|
# Pulls dataset into OUTPUT.gz.
|
|
282
282
|
#
|
|
283
|
-
# --
|
|
283
|
+
# --version_id [version_id] # Retrieve data generated with a specific version of the app if the dataset is associated with an app [default: last version]
|
|
284
284
|
# --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
|
|
285
285
|
#
|
|
286
286
|
def pull
|
|
@@ -324,7 +324,7 @@ class Zillabyte::Command::Data < Zillabyte::Command::Base
|
|
|
324
324
|
# 2) s3://s3_bucket/s3_key: also supply --s3_access and --s3_secret OR set the environment variables S3_ACCESS and S3_SECRET
|
|
325
325
|
# 3) s3_key: also supply --s3_access, --s3_secret and --s3_bucket OR set the environment variables S3_ACCESS and S3_SECRET and supply --s3_bucket
|
|
326
326
|
#
|
|
327
|
-
# --
|
|
327
|
+
# --version_id [version_id] # Retrieve data generated with a specific version of the app if the dataset is associated with an app [default: last version]
|
|
328
328
|
# --s3_access [s3_access_key] # S3 access key
|
|
329
329
|
# --s3_secret [s3_secret_key] # S3 secret key
|
|
330
330
|
# --s3_bucket [s3_bucket] # S3 bucket to store data at
|
|
@@ -362,7 +362,7 @@ class Zillabyte::Command::Data < Zillabyte::Command::Base
|
|
|
362
362
|
|
|
363
363
|
s3_params = {:s3_access_key => s3_access, :s3_secret => s3_secret,
|
|
364
364
|
:s3_bucket => s3_bucket, :s3_file_key => s3_key}
|
|
365
|
-
s3_params[:
|
|
365
|
+
s3_params[:version_id] = options[:version_id] if options[:version_id]
|
|
366
366
|
|
|
367
367
|
res = self.api.data.pull_to_s3(id, s3_params)
|
|
368
368
|
|
|
@@ -382,10 +382,9 @@ class Zillabyte::Command::Data < Zillabyte::Command::Base
|
|
|
382
382
|
|
|
383
383
|
# data:show ID
|
|
384
384
|
#
|
|
385
|
-
# Shows a sample of the dataset.
|
|
386
|
-
# more elaborate functionality.
|
|
385
|
+
# Shows a sample of the dataset.
|
|
387
386
|
#
|
|
388
|
-
# --
|
|
387
|
+
# --version_id [version_id] # Retrieve data generated with a specific version of the app if the dataset is associated with an app [default: last version]
|
|
389
388
|
# --no_truncation # Don't truncate long strings
|
|
390
389
|
# --meta # Show metadata columns (since, confidence, source)
|
|
391
390
|
# --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
|
data/lib/zillabyte/cli/flows.rb
CHANGED
|
@@ -398,7 +398,7 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
|
398
398
|
heading1 = ["type", "name"]
|
|
399
399
|
|
|
400
400
|
# a level deeper
|
|
401
|
-
heading2 = ["consumed", "emitted", "errors"]
|
|
401
|
+
heading2 = ["consumed", "emitted", "errors", "parallelism"]
|
|
402
402
|
|
|
403
403
|
# for the table output
|
|
404
404
|
headings = heading1 + heading2
|
|
@@ -415,10 +415,13 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
|
415
415
|
# get the values for the headings
|
|
416
416
|
stats = instances.map do |instance|
|
|
417
417
|
|
|
418
|
+
|
|
418
419
|
heading2.map do |heading|
|
|
419
420
|
instance["stats"][heading]
|
|
420
421
|
end
|
|
421
422
|
|
|
423
|
+
|
|
424
|
+
|
|
422
425
|
end
|
|
423
426
|
|
|
424
427
|
# combine the arrays
|
|
@@ -456,7 +459,7 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
|
456
459
|
end
|
|
457
460
|
|
|
458
461
|
# rows to be output to the CLI
|
|
459
|
-
rows = rows.group_by{ |type, name, consumed, emitted, errors| name }.map{ |hashkey, array| [array[0][0], hashkey, array.inject(0){ |sum, i | sum + i[2].to_i }, array.inject(0){ |sum, i | sum + i[3].to_i },array.inject(0){ |sum, i | sum + i[4].to_i }]
|
|
462
|
+
rows = rows.group_by { |type, name, consumed, emitted, errors, parallelism| name }.map{ |hashkey, array| [array[0][0], hashkey, array.inject(0){ |sum, i | sum + i[2].to_i }, array.inject(0){ |sum, i | sum + i[3].to_i },array.inject(0){ |sum, i | sum + i[4].to_i }, array.inject(0){|value, i| i[5].to_i}]}
|
|
460
463
|
# example sums: [["sink", "has_facebook_likebox_and_vwo", 73, 0, 0], ["source", "sharder.1", 16, 10367872, 1], ["each", "each_3", 10367872, 73, 0]]
|
|
461
464
|
|
|
462
465
|
# calculate percentage for the user to see
|
|
@@ -829,6 +832,213 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
|
829
832
|
alias_command "local", "flows:local"
|
|
830
833
|
|
|
831
834
|
|
|
835
|
+
|
|
836
|
+
# flows:pause ID
|
|
837
|
+
#
|
|
838
|
+
# Pause a flow
|
|
839
|
+
#
|
|
840
|
+
def pause
|
|
841
|
+
id = options[:id] || shift_argument
|
|
842
|
+
type = options[:output_type]
|
|
843
|
+
|
|
844
|
+
if id.nil?
|
|
845
|
+
id = read_name_from_conf(options)
|
|
846
|
+
end
|
|
847
|
+
|
|
848
|
+
display "Pausing flow ##{id}...please wait..." if type.nil?
|
|
849
|
+
response = api.flows.create_pause(id, options)
|
|
850
|
+
|
|
851
|
+
if response["job_id"]
|
|
852
|
+
options[:job_id] = response["job_id"]
|
|
853
|
+
flow_id = response["flow_id"]
|
|
854
|
+
|
|
855
|
+
start = Time.now.utc
|
|
856
|
+
display "Pause request sent. Please wait..." if type.nil?
|
|
857
|
+
|
|
858
|
+
while(Time.now.utc < start + MAX_POLL_SECONDS) do
|
|
859
|
+
|
|
860
|
+
# Poll
|
|
861
|
+
res = self.api.flows.poll_pause(flow_id, options)
|
|
862
|
+
|
|
863
|
+
case res['status']
|
|
864
|
+
when 'completed'
|
|
865
|
+
if res['return']
|
|
866
|
+
if type == "json"
|
|
867
|
+
display "{}"
|
|
868
|
+
else
|
|
869
|
+
display "Flow ##{id} paused"
|
|
870
|
+
end
|
|
871
|
+
else
|
|
872
|
+
throw "something is wrong: #{res}"
|
|
873
|
+
end
|
|
874
|
+
# success! continue below
|
|
875
|
+
break
|
|
876
|
+
when 'running'
|
|
877
|
+
sleep(POLL_SLEEP)
|
|
878
|
+
# display ".", false
|
|
879
|
+
else
|
|
880
|
+
throw "unknown status: #{res}"
|
|
881
|
+
end
|
|
882
|
+
|
|
883
|
+
end
|
|
884
|
+
elsif response["error"]
|
|
885
|
+
error(response["error"], type)
|
|
886
|
+
else
|
|
887
|
+
error("remote server error (f569)", type)
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
end
|
|
891
|
+
alias_command "pause", "flows:pause"
|
|
892
|
+
|
|
893
|
+
# flows:resume
|
|
894
|
+
#
|
|
895
|
+
# Resume a paused flow ID
|
|
896
|
+
def resume
|
|
897
|
+
id = options[:id] || shift_argument
|
|
898
|
+
type = options[:output_type]
|
|
899
|
+
|
|
900
|
+
if id.nil?
|
|
901
|
+
id = read_name_from_conf(options)
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
display "Resume flow ##{id}...please wait..." if type.nil?
|
|
905
|
+
response = api.flows.create_resume(id, options)
|
|
906
|
+
|
|
907
|
+
if response["job_id"]
|
|
908
|
+
options[:job_id] = response["job_id"]
|
|
909
|
+
flow_id = response["flow_id"]
|
|
910
|
+
|
|
911
|
+
start = Time.now.utc
|
|
912
|
+
display "Resume request sent. Please wait..." if type.nil?
|
|
913
|
+
|
|
914
|
+
while(Time.now.utc < start + MAX_POLL_SECONDS) do
|
|
915
|
+
|
|
916
|
+
# Poll
|
|
917
|
+
res = self.api.flows.poll_resume(flow_id, options)
|
|
918
|
+
|
|
919
|
+
case res['status']
|
|
920
|
+
when 'completed'
|
|
921
|
+
if res['return']
|
|
922
|
+
if type == "json"
|
|
923
|
+
display "{}"
|
|
924
|
+
else
|
|
925
|
+
display "Flow ##{id} resumed"
|
|
926
|
+
end
|
|
927
|
+
else
|
|
928
|
+
throw "something is wrong: #{res}"
|
|
929
|
+
end
|
|
930
|
+
# success! continue below
|
|
931
|
+
break
|
|
932
|
+
when 'running'
|
|
933
|
+
sleep(POLL_SLEEP)
|
|
934
|
+
# display ".", false
|
|
935
|
+
else
|
|
936
|
+
throw "unknown status: #{res}"
|
|
937
|
+
end
|
|
938
|
+
|
|
939
|
+
end
|
|
940
|
+
elsif response["error"]
|
|
941
|
+
error(response["error"], type)
|
|
942
|
+
else
|
|
943
|
+
error("remote server error (f569)", type)
|
|
944
|
+
end
|
|
945
|
+
end
|
|
946
|
+
alias_command "resume", "flows:resume"
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
# apps:scale ID OPERATION_NAME PARALLELISM
|
|
953
|
+
#
|
|
954
|
+
# Change the parallelism of of app or operation
|
|
955
|
+
def scale
|
|
956
|
+
id = options[:id] || shift_argument
|
|
957
|
+
|
|
958
|
+
if id.nil?
|
|
959
|
+
id = read_name_from_conf(options)
|
|
960
|
+
end
|
|
961
|
+
|
|
962
|
+
name = options[:name] || shift_argument
|
|
963
|
+
parallelism = options[:parallelism] || shift_argument
|
|
964
|
+
type = options[:output_type]
|
|
965
|
+
|
|
966
|
+
# Read current metadata from API
|
|
967
|
+
display "Fetching configuration for flow ##{id}...please wait..." if type.nil?
|
|
968
|
+
options[:flow_id] = id
|
|
969
|
+
|
|
970
|
+
response = api.flows.get_meta(id, options)
|
|
971
|
+
if response["meta"]
|
|
972
|
+
meta = response["meta"]
|
|
973
|
+
nodes = meta["nodes"]
|
|
974
|
+
|
|
975
|
+
# Set new parallelism if necessary
|
|
976
|
+
scaling = false
|
|
977
|
+
nodes.each_with_index do |node, i|
|
|
978
|
+
|
|
979
|
+
if node["name"] == name && node["parallelism"] != parallelism
|
|
980
|
+
meta["nodes"][i]["parallelism"] = parallelism
|
|
981
|
+
scaling = true
|
|
982
|
+
break
|
|
983
|
+
end
|
|
984
|
+
end
|
|
985
|
+
|
|
986
|
+
if scaling
|
|
987
|
+
display "Scaling flow ##{id}...please wait..." if type.nil?
|
|
988
|
+
options[:flow_config] = meta
|
|
989
|
+
response = api.flows.create_scale(id, options)
|
|
990
|
+
|
|
991
|
+
if response["job_id"]
|
|
992
|
+
options[:job_id] = response["job_id"]
|
|
993
|
+
flow_id = response["flow_id"]
|
|
994
|
+
|
|
995
|
+
start = Time.now.utc
|
|
996
|
+
display "Scaling request sent. Please wait..." if type.nil?
|
|
997
|
+
|
|
998
|
+
while(Time.now.utc < start + MAX_POLL_SECONDS) do
|
|
999
|
+
|
|
1000
|
+
# Poll
|
|
1001
|
+
options.delete(:flow_config)
|
|
1002
|
+
res = self.api.flows.poll_scale(flow_id, options)
|
|
1003
|
+
|
|
1004
|
+
case res['status']
|
|
1005
|
+
when 'completed'
|
|
1006
|
+
if res['return']
|
|
1007
|
+
if type == "json"
|
|
1008
|
+
display "{}"
|
|
1009
|
+
else
|
|
1010
|
+
display "Flow ##{id} scaled"
|
|
1011
|
+
end
|
|
1012
|
+
else
|
|
1013
|
+
throw "something is wrong: #{res}"
|
|
1014
|
+
end
|
|
1015
|
+
# success! continue below
|
|
1016
|
+
break
|
|
1017
|
+
when 'running'
|
|
1018
|
+
sleep(POLL_SLEEP)
|
|
1019
|
+
# display ".", false
|
|
1020
|
+
else
|
|
1021
|
+
throw "unknown status: #{res}"
|
|
1022
|
+
end
|
|
1023
|
+
|
|
1024
|
+
end
|
|
1025
|
+
elsif response["error"]
|
|
1026
|
+
error(response["error"], type)
|
|
1027
|
+
else
|
|
1028
|
+
error("remote server error (f569)", type)
|
|
1029
|
+
end
|
|
1030
|
+
else
|
|
1031
|
+
error("Unable to find operation #{name}", type)
|
|
1032
|
+
end
|
|
1033
|
+
elsif response["error"]
|
|
1034
|
+
error(response["error"], type)
|
|
1035
|
+
end
|
|
1036
|
+
|
|
1037
|
+
end
|
|
1038
|
+
alias_command "scale", "flows:scale"
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
832
1042
|
# flows:kill ID
|
|
833
1043
|
#
|
|
834
1044
|
# Kills the given flow.
|
data/lib/zillabyte/command.rb
CHANGED
|
@@ -222,8 +222,66 @@ module Zillabyte
|
|
|
222
222
|
].compact.join("\n"))
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
|
+
|
|
226
|
+
def self.tracker(cmd,arguments=[])
|
|
227
|
+
# tell us what the user is doing so we can get better.
|
|
228
|
+
options = {}
|
|
229
|
+
|
|
230
|
+
# get user id AND/OR install id
|
|
231
|
+
## check for user id.
|
|
232
|
+
|
|
233
|
+
require("netrc")
|
|
234
|
+
|
|
235
|
+
default_path = Netrc.default_path
|
|
236
|
+
if File.exists?(default_path)
|
|
237
|
+
encrypted = default_path + ".gpg"
|
|
238
|
+
if File.exists?(encrypted)
|
|
239
|
+
default_path = encrypted
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
if Netrc.read(Netrc.default_path)["api.zillabyte.com"]
|
|
243
|
+
options[:user_id] = Netrc.read(Netrc.default_path)["api.zillabyte.com"][1]
|
|
244
|
+
options[:email] = Netrc.read(Netrc.default_path)["api.zillabyte.com"][0]
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
## check for install id.
|
|
249
|
+
location = "#{Dir.home}/.zillabyte/.install_id"
|
|
250
|
+
|
|
251
|
+
unless File.file?(location)
|
|
252
|
+
# it doesn't exist, so create one.
|
|
253
|
+
require "securerandom"
|
|
254
|
+
uuid_home = "#{Dir.home}/.zillabyte/"
|
|
255
|
+
FileUtils.mkdir_p(uuid_home)
|
|
256
|
+
File.open(location,'w') { |f| f.write(SecureRandom.uuid)}
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
options[:install_id] = File.read(location)
|
|
260
|
+
options[:cli_command] = cmd
|
|
261
|
+
options[:date] = Time.now
|
|
262
|
+
options[:args] = arguments.to_s
|
|
263
|
+
# hit our server
|
|
264
|
+
begin
|
|
265
|
+
require 'excon'
|
|
266
|
+
Excon.new(
|
|
267
|
+
"http://tracking.zillabyte.com",
|
|
268
|
+
:headers => {
|
|
269
|
+
'Content-Type' => "application/json",
|
|
270
|
+
}
|
|
271
|
+
).request(
|
|
272
|
+
:expects => 200,
|
|
273
|
+
:method => :post,
|
|
274
|
+
:path => "/track",
|
|
275
|
+
:body => options.to_json
|
|
276
|
+
)
|
|
277
|
+
rescue Exception => e
|
|
278
|
+
# do nothing
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
225
282
|
|
|
226
283
|
def self.run(cmd, arguments=[])
|
|
284
|
+
|
|
227
285
|
require("excon/errors")
|
|
228
286
|
require("zillabyte/helpers")
|
|
229
287
|
extend(Zillabyte::Helpers)
|
|
@@ -243,6 +301,7 @@ module Zillabyte
|
|
|
243
301
|
error "remote server error: #{e.message}"
|
|
244
302
|
end
|
|
245
303
|
end
|
|
304
|
+
|
|
246
305
|
end
|
|
247
306
|
|
|
248
307
|
def self.parse(cmd)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zillabyte-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.37
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- zillabyte
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-11-
|
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|