zillabyte-cli 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjAzZDgxMjBiY2M0NDU3ODEyNjEyMmJhZjA4MWQ1MjU2NjE0Zjk2YQ==
4
+ M2YyYjcyMWJlMGExNmUzOGI3NjE1N2UzMThiZjU4ZjZkYzc4ZDgyYg==
5
5
  data.tar.gz: !binary |-
6
- ZjM2ZjY2NTRiZGU3ZmMwMzI1ZDQ5NjNkOTZmMTEzMzAxMzJmZmZkYw==
6
+ MWIyNjZmMjVlYWJhYzM2OTdhOGU2NzlhY2U2NTg4YTRkMjJjMjJkMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmJhYzkwZWZiMGNkMGJlNzY1N2NlNzdkMjA0ZTU4NzhmNGM3YTBhZjFkZWMz
10
- Nzc0ZmJlOGQ3NjQ3NTM3YzE5NDIwNTYxZGI5ZDI4NWY2NjZiOTRkMTY0ZmYz
11
- NGI2YjljM2RjNzc0ZGQ3ZTc5N2Y2YmMxYTZiNTkwNjQ5MWExMWY=
9
+ MWFmY2FiMzUzNjM0MmY3OGE2NzA3YjEwYTY4MzQ2NWMwZTdmNGE4NDA5ZDgy
10
+ NjdmNDI4YjllMjQyMGFiNDY1ZGQzYzY1OTliY2Y1YTRkMGJlMzQyM2VkZDA4
11
+ NzY5ZWFmMThkNjFjNDhmYzZmODM3Yzk3ZjQ0OGRkMDZkNjE1Njg=
12
12
  data.tar.gz: !binary |-
13
- MjIxYjU5Mzg3MTYzYTA5OGNkZTNlOGI5ZTFhMjVjNWY2YjE2ZDg1MmQ0YjRl
14
- NWFmZTNhNmJhODY5ODgzOTM4YzhjYTI1ZmMyMTRjMjM5ZWJjNTk5YTcyMDc1
15
- Yzk0ZTEzZTNkMzY0M2JhMTI2OTBhNDQ2YzY0Yjg0ZjgyNzEyNWI=
13
+ YjA3ZGIxNDU4NjVkNDViZGNmN2M5MTg5YmNkYTQ0YzQzODU3NDJkMTNmMzZi
14
+ MDNjZTI3YmViMDhiM2JlNzA4NGFiNDVhZjk3MTg2ZmY0NmI1NDYzMmNlNDNi
15
+ YmIzYWY2ZjcyNGZjYTI0NmVkNzdhM2ZhMDEyNTY1OGYyNWI2YjA=
@@ -203,6 +203,7 @@ class Zillabyte::API::Apps < Zillabyte::API::Base
203
203
  :body => options.to_json
204
204
  )
205
205
 
206
+
206
207
  if(res.body['uri'])
207
208
  uri = URI(res.body['uri'])
208
209
  try_again = 1
@@ -246,9 +247,11 @@ class Zillabyte::API::Apps < Zillabyte::API::Base
246
247
  full_script = File.join(dir, hash['script'])
247
248
  command = nil
248
249
 
250
+
249
251
  info_file = "#{dir}/#{SecureRandom.uuid}"
250
252
  arg = "--info --file #{info_file}"
251
-
253
+
254
+
252
255
  case hash["language"]
253
256
  when "ruby"
254
257
  command = "cd \"#{dir}\"; unset BUNDLE_GEMFILE; ZILLABYTE_HARNESS=1 bundle exec ruby \"#{full_script}\" #{arg}"
@@ -267,7 +270,7 @@ class Zillabyte::API::Apps < Zillabyte::API::Base
267
270
  return nil
268
271
  end
269
272
 
270
- results = Zillabyte::Command::Apps.get_info(command, info_file, options)
273
+ results = Zillabyte::Command::Apps.get_info(command, info_file, dir, options)
271
274
 
272
275
  begin
273
276
  meta = JSON.parse(results.split("\n").first.strip) # Throws error if invalid json
data/lib/zillabyte/api.rb CHANGED
@@ -87,6 +87,9 @@ class Zillabyte::API
87
87
  # Executed on each chunk excon bubbles up
88
88
  params[:response_block] = lambda do |chunk, remaining_bytes, total_bytes|
89
89
 
90
+ # Debug helper
91
+ puts chunk if ENV["ZB_DEBUG"]
92
+
90
93
  # assume single-line json, split by '\n'
91
94
  last_string += chunk
92
95
  ary = last_string.split("\n", -1)
@@ -23,6 +23,8 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
23
23
  def index
24
24
  self.list
25
25
  end
26
+
27
+
26
28
 
27
29
  # apps
28
30
  #
@@ -37,15 +39,143 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
37
39
  headings = row.keys
38
40
  headings.delete("rel_dir")
39
41
  end
42
+
40
43
  v = row.values_at *headings
41
44
  v
42
45
  end
43
46
 
44
47
  display "apps:\n" if type.nil?
45
48
  display TableOutputBuilder.build_table(headings, rows, type)
46
- display "Total number of apps: "+rows.length.to_s if type.nil?
49
+ display "Total number of apps: " + rows.length.to_s if type.nil?
47
50
  end
48
51
 
52
+ # apps:details ID
53
+ #
54
+ # list details for an app, including percentage complete
55
+ # if the source is an existing relation
56
+ def details
57
+
58
+ app_id = options[:id] || shift_argument
59
+ type = options[:type]
60
+
61
+ if app_id.nil?
62
+ app_id = read_name_from_conf(options)
63
+ options[:is_name] = true
64
+ elsif !(app_id =~ /^\d*$/)
65
+ options[:is_name] = true
66
+ end
67
+
68
+ res = api.request(
69
+ :expects => 200,
70
+ :method => :get,
71
+ :path => "/flows/#{app_id}/details",
72
+ :body => options.to_json
73
+ )
74
+ res.body
75
+
76
+ # a nested hash so can't map directly
77
+ # instead i'll map separately and then merge the arrays
78
+ heading1 = ["type", "name"]
79
+
80
+ # a level deeper
81
+ heading2 = ["consumed", "emitted", "errors"]
82
+
83
+ # for the table output
84
+ headings = heading1 + heading2
85
+
86
+ # get the values for the headings
87
+ type_name = res.body.map do |instance|
88
+
89
+ heading1.map do |heading|
90
+ instance[heading]
91
+ end
92
+
93
+ end
94
+
95
+ # get the values for the headings
96
+ stats = res.body.map do |instance|
97
+
98
+ heading2.map do |heading|
99
+ instance["stats"][heading]
100
+ end
101
+
102
+ end
103
+
104
+ # combine the arrays
105
+ rows = type_name.zip(stats).map{|x,y| x.concat y}
106
+
107
+ # check if it's from a relation.
108
+ # if the source is a relation, there's a sharder.
109
+ # remove source types, and hardcode sharder-named instances as source
110
+
111
+ from_relation = false
112
+
113
+ rows.each do | row |
114
+ if row[1].scan("sharder").length != 0
115
+ from_relation = true
116
+ break
117
+ end
118
+ end
119
+
120
+ if from_relation == true
121
+
122
+ rows = rows.each do |row|
123
+ if row[0].scan("source").length != 0
124
+ rows.delete(row)
125
+ end
126
+
127
+ end
128
+
129
+
130
+ rows = rows.each do |row|
131
+ if row[1].scan("sharder").length != 0
132
+ row[0] = "source"
133
+ end
134
+ end
135
+
136
+ end
137
+
138
+ # rows to be output to the CLI
139
+ 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 }] }
140
+ # example sums: [["sink", "has_facebook_likebox_and_vwo", 73, 0, 0], ["source", "sharder.1", 16, 10367872, 1], ["each", "each_3", 10367872, 73, 0]]
141
+
142
+ # calculate percentage for the user to see
143
+
144
+ attempts = 0
145
+ total = 0
146
+
147
+ if from_relation == true
148
+
149
+ rows.each do |instance|
150
+ if instance[0] == "source"
151
+ total = instance[3]
152
+ end
153
+ end
154
+
155
+
156
+ rows.each do |instance|
157
+ if instance[0] == "each"
158
+ attempts = instance[2]
159
+ end
160
+ end
161
+ end
162
+
163
+ if attempts > 0 && total > 0
164
+ completion = attempts/total*100
165
+ else
166
+ completion = 0
167
+ end
168
+
169
+ # output on the CLI
170
+ display "details:"
171
+ display TableOutputBuilder.build_table(headings, rows, type)
172
+ if from_relation == true
173
+ display "percent complete: #{completion}%\n"
174
+ end
175
+ end
176
+
177
+
178
+
49
179
 
50
180
  # apps:push [DIR]
51
181
  #
@@ -62,7 +192,13 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
62
192
  def push
63
193
 
64
194
  since = Time.now.utc.to_s
65
- dir = options[:directory] || shift_argument || Dir.pwd
195
+ dir = options[:directory] || shift_argument
196
+ if dir.nil?
197
+ dir = Dir.pwd
198
+ else
199
+ dir = File.expand_path(dir)
200
+ end
201
+ options[:directory] = dir
66
202
  type = options[:type]
67
203
 
68
204
  res = api.apps.push_directory dir, session, options
@@ -89,8 +225,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
89
225
  # exit(0) if (hash['line'] || '').downcase.include?("app deployed")
90
226
 
91
227
  end
92
-
93
- display {}.to_json if type == "json"
228
+ display "{}" if type == "json"
94
229
 
95
230
  end
96
231
  alias_command "push", "apps:push"
@@ -103,8 +238,9 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
103
238
  #
104
239
  # --force # pulls even if the directory exists
105
240
  # --type TYPE # specify an output type i.e. json
241
+ # --directory DIR # Directory of the app
106
242
  #
107
- #Examples:
243
+ # Examples:
108
244
  #
109
245
  # $ zillabyte apps:pull .
110
246
  #
@@ -117,10 +253,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
117
253
  end
118
254
 
119
255
  dir = options[:directory] || shift_argument
256
+ error("no directory given", type) if dir.nil?
257
+ dir = File.expand_path(dir)
258
+
120
259
  type = options[:type]
121
260
 
122
261
  error("no id given", type) if app_id.nil?
123
- error("no directory given", type) if dir.nil?
124
262
 
125
263
  # Create if not exists..
126
264
  if File.exists?(dir)
@@ -137,7 +275,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
137
275
  error("error: #{res['error_message']}", type)
138
276
  else
139
277
  if type == "json"
140
- display {}.to_json
278
+ display "{}"
141
279
  else
142
280
  display "app ##{res['id']} pulled to #{dir}"
143
281
  end
@@ -186,7 +324,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
186
324
  if confirmed
187
325
  response = api.apps.delete(app_id, options)
188
326
  if type == "json"
189
- display {}.to_json
327
+ display "{}"
190
328
  else
191
329
  display response["body"]
192
330
  end
@@ -196,23 +334,31 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
196
334
 
197
335
 
198
336
  # apps:prep [DIR]
199
- #
200
- # prepares an app for execution
337
+ #
338
+ # performs any necessary initialization for the app
339
+ #
201
340
  # --directory DIR # app directory
202
341
  # --type TYPE # specify an output type i.e. json
203
- #
342
+ #
204
343
  def prep
205
-
206
- type = options[:type]
207
- dir = options[:directory] || shift_argument || Dir.pwd
344
+
345
+ type = options[:type]
346
+ dir = options[:directory] || shift_argument
347
+ if dir.nil?
348
+ dir = Dir.pwd
349
+ else
350
+ dir = File.expand_path(dir)
351
+ end
352
+ options[:directory] = dir
208
353
  meta = Zillabyte::CLI::Config.get_config_info(dir)
354
+
209
355
  if meta.nil?
210
356
  error("The specified directory (#{dir}) does not appear to contain a valid Zillabyte configuration file.", type)
211
357
  end
212
358
 
213
359
  case meta["language"]
214
360
  when "ruby"
215
-
361
+
216
362
  # Execute in the bundler context
217
363
  full_script = File.join(dir, meta["script"])
218
364
  cmd = "cd \"#{meta['home_dir']}\"; unset BUNDLE_GEMFILE; unset RUBYOPT; bundle install"
@@ -247,6 +393,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
247
393
  # [LANG] defaults to ruby, and [DIR] to the current directory
248
394
  #
249
395
  # --type TYPE # specify an output type i.e. json
396
+ # --directory DIR # Directory of the app
250
397
  #
251
398
  #Examples:
252
399
  #
@@ -255,7 +402,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
255
402
  def init
256
403
 
257
404
  lang = options[:lang] || shift_argument || "ruby"
258
- dir = options[:dir] || shift_argument || Dir.pwd
405
+ dir = options[:directory] || shift_argument
406
+ if dir.nil?
407
+ dir = Dir.pwd
408
+ else
409
+ dir = File.expand_path(dir)
410
+ end
259
411
  type = options[:type]
260
412
 
261
413
  languages = ["ruby","python", "js"]
@@ -311,7 +463,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
311
463
 
312
464
  # apps:errors ID
313
465
  #
314
- # Show recent errors generated by the app
466
+ # show recent errors generated by the app
315
467
  # --type TYPE # specify an output type i.e. json
316
468
  #
317
469
  def errors
@@ -432,7 +584,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
432
584
  when 'completed'
433
585
  if res['return']
434
586
  if type == "json"
435
- return {}.to_json
587
+ return "{}"
436
588
  else
437
589
  display res['return']
438
590
  end
@@ -521,8 +673,15 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
521
673
  end
522
674
 
523
675
 
676
+
524
677
  # INIT
525
- dir = options[:directory] || shift_argument || Dir.pwd
678
+ dir = options[:directory] || shift_argument
679
+ if dir.nil?
680
+ dir = Dir.pwd
681
+ else
682
+ dir = File.expand_path(dir)
683
+ end
684
+ options[:directory] = dir
526
685
 
527
686
  meta = Zillabyte::API::Apps.get_rich_meta_info_from_script(dir, self, {:test => true})
528
687
  if meta.nil?
@@ -598,7 +757,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
598
757
  next
599
758
 
600
759
  else
601
-
760
+
602
761
  # A regular source..
603
762
  stream_messages[default_stream] ||= []
604
763
  stream_messages[default_stream] << "{\"command\": \"begin_cycle\"}\n"
@@ -705,6 +864,8 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
705
864
  handshake stdin, stdout, node, color
706
865
  write_queue = []
707
866
  read_queue = []
867
+ mutex = Mutex.new
868
+ signal = ConditionVariable.new
708
869
 
709
870
  if consumes.nil?
710
871
  # Assume default stream (this should only happen for the source)
@@ -716,7 +877,6 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
716
877
  stream_messages.delete(stream_name)
717
878
 
718
879
  # Start writing the messages...
719
- stuff_to_read = false
720
880
  writing_thread = Thread.start do
721
881
 
722
882
  while(true)
@@ -733,8 +893,10 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
733
893
  end
734
894
 
735
895
  # Make sure we're not reading anything...
736
- while(stuff_to_read) # TODO: semaphores
737
- sleep 0.5 # spin wait
896
+ while(write_queue.size == 0)
897
+ mutex.synchronize do
898
+ signal.wait(mutex)
899
+ end
738
900
  end
739
901
 
740
902
  # Get next mesage
@@ -749,13 +911,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
749
911
  last_call_next_tuple = true
750
912
  op_display.call "getting next set of tuples in the batch"
751
913
  else
752
- puts write_json
914
+ # puts write_json
753
915
  end
754
916
 
755
917
  # Actually send it to the process
756
918
  begin
757
919
  write_message stdin, write_msg
758
- stuff_to_read = true
759
920
  sleep 0.1
760
921
  rescue Exception => e
761
922
  puts "Error running #{cmd}: #{e}"
@@ -771,25 +932,30 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
771
932
  # If the end cycle command is received, we either trigger the next cycle if the number of emitted
772
933
  # cycles is less than what the user requested, or we break
773
934
  if type == "source" and end_cycle_received
774
- write_queue << "{\"command\": \"begin_cycle\"}\n"
935
+
936
+ mutex.synchronize do
937
+ write_queue << "{\"command\": \"begin_cycle\"}\n"
938
+ signal.signal()
939
+ end
940
+
775
941
  n_batches_emitted += 1
776
942
  end_cycle_received = false
777
943
  last_call_next_tuple = false
778
- stuff_to_read = false
779
944
  break if n_batches_emitted > batches
780
945
  sleep 0.5
781
946
  next
782
947
  end
783
948
 
784
949
  # Get next message
785
- read_msg = read_message(stdout, color)
950
+ read_msg = read_message(stdout, color);
951
+
786
952
  if read_msg == "done" || read_msg.nil?
787
- stuff_to_read = false
788
953
 
789
954
  # For sources, if we receive a "done", check to see if any of the streams emitted by the source has
790
955
  # increased in size since the last call to next_tuple. If so, the cycle isn't over, otherwise, the
791
956
  # current call to next_tuple emitted nothing and if the end_cycle_policy is set to null_emit, this
792
957
  # should end the current cycle.
958
+
793
959
  if type == "source"
794
960
  if last_call_next_tuple and node["end_cycle_policy"] == "null_emit"
795
961
  end_cycle_received = true
@@ -801,7 +967,11 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
801
967
  end
802
968
 
803
969
  # If the policy isn't "null_emit", then just request next_tuple again
804
- write_queue << "{\"command\": \"next\"}\n"
970
+ mutex.synchronize do
971
+ write_queue << "{\"command\": \"next\"}\n"
972
+ signal.signal()
973
+ end
974
+
805
975
  end
806
976
 
807
977
  # For other operations, if the queue is empty then we're done
@@ -812,7 +982,6 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
812
982
  next
813
983
  end
814
984
  end
815
- stuff_to_read = true
816
985
 
817
986
  # Process message
818
987
  obj = JSON.parse(read_msg)
@@ -859,6 +1028,13 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
859
1028
  elsif obj['command'] == 'fail'
860
1029
  op_display.call "error: #{obj['msg']}", :red
861
1030
  exit(1)
1031
+ elsif obj['ping']
1032
+
1033
+ mutex.synchronize do
1034
+ write_queue << "{\"pong\": \"#{Time.now.utc.to_f}\"}\n"
1035
+ signal.signal()
1036
+ end
1037
+
862
1038
  else
863
1039
  error "unknown message: #{read_msg}"
864
1040
  end
@@ -924,7 +1100,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
924
1100
  api.apps.kill(id, options)
925
1101
 
926
1102
  if type == "json"
927
- display {}.to_json
1103
+ display "{}"
928
1104
  else
929
1105
  display "App ##{id} killed"
930
1106
  end
@@ -938,7 +1114,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
938
1114
  #
939
1115
  # --config CONFIG_FILE # use the given config file
940
1116
  # --type TYPE # specify an output type i.e. json
941
- # --directory DIR # directory of app
1117
+ # --directory DIR # Directory of the app
942
1118
  #
943
1119
  # HIDDEN:
944
1120
  def live_run
@@ -947,22 +1123,68 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
947
1123
  type = options[:type]
948
1124
 
949
1125
  thread_id = options[:thread] || shift_argument || ""
950
- dir = options[:directory] || shift_argument || Dir.pwd
951
- meta = Zillabyte::CLI::Config.get_config_info(dir)
1126
+ dir = options[:directory] || shift_argument
1127
+ if dir.nil?
1128
+ dir = Dir.pwd
1129
+ else
1130
+ dir = File.expand_path(dir)
1131
+ end
1132
+ options[:directory] = dir
1133
+
1134
+ meta = Zillabyte::CLI::Config.get_config_info(dir, options)
952
1135
 
953
1136
  if meta.nil?
954
1137
  error("could not find meta information for: #{dir}", type)
955
1138
  end
956
1139
 
957
1140
  if(thread_id == "")
958
- exec(command("--execute_live --name #{name.to_s}", type, dir))
1141
+ exec(command("--execute_live --name #{name.to_s}",type, dir))
959
1142
  else
960
- exec(command("--execute_live --name #{name.to_s} --pipe #{thread_id}", type, dir))
1143
+ exec(command("--execute_live --name #{name.to_s} --pipe #{dir}/#{thread_id}",type, dir))
961
1144
  end
962
1145
  end
963
1146
  alias_command "live_run", "apps:live_run"
964
1147
 
965
1148
 
1149
+
1150
+ # apps:status [DIR]
1151
+ #
1152
+ # fetches detailed status of the app
1153
+ #
1154
+ # --type TYPE # specify an output type i.e. json
1155
+ # --directory DIR # Directory of the app
1156
+ #
1157
+ def status
1158
+
1159
+ id = options[:id] || shift_argument
1160
+ type = options[:type]
1161
+
1162
+ if id.nil?
1163
+ id = read_name_from_conf(options)
1164
+ options[:is_name] = true
1165
+ elsif !(id =~ /^\d*$/)
1166
+ options[:is_name] = true
1167
+ end
1168
+
1169
+ res = api.request(
1170
+ :expects => 200,
1171
+ :method => :get,
1172
+ :path => "/flows/#{id}"
1173
+ )
1174
+ res.body
1175
+
1176
+ if type == "json"
1177
+ display res.body.to_json
1178
+ else
1179
+ # TODO
1180
+ display res.body.to_json
1181
+ end
1182
+
1183
+ end
1184
+
1185
+
1186
+
1187
+
966
1188
  # apps:info [DIR]
967
1189
  #
968
1190
  # outputs the info for the app in the dir.
@@ -972,12 +1194,20 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
972
1194
  # --directory DIR # Directory of the app
973
1195
  #
974
1196
  def info
975
- dir = options[:directory] || shift_argument || Dir.pwd
976
- type = options[:type]
1197
+
1198
+ dir = options[:directory] || shift_argument
1199
+ if dir.nil?
1200
+ dir = Dir.pwd
1201
+ else
1202
+ dir = File.expand_path(dir)
1203
+ end
1204
+ options[:directory] = dir
1205
+
977
1206
  info_file = "#{dir}/#{SecureRandom.uuid}"
1207
+ type = options[:type]
978
1208
 
979
1209
  cmd = command("--info --file #{info_file}", type, dir)
980
- app_info = Zillabyte::Command::Apps.get_info(cmd, info_file)
1210
+ app_info = Zillabyte::Command::Apps.get_info(cmd, info_file, dir, options)
981
1211
 
982
1212
  if type == "json"
983
1213
  puts app_info
@@ -997,11 +1227,14 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
997
1227
  #
998
1228
  # --type TYPE # specify an output type i.e. json
999
1229
  #
1000
- def self.get_info(cmd, info_file, options = {})
1230
+ def self.get_info(cmd, info_file, dir, options = {})
1001
1231
  type = options[:type]
1232
+
1002
1233
  response = `#{cmd}`
1003
1234
  if($?.exitstatus == 1)
1235
+
1004
1236
  File.delete("#{info_file}") if File.exists?(info_file)
1237
+
1005
1238
  if options[:type].nil?
1006
1239
  exit(1)
1007
1240
  else
@@ -1022,8 +1255,8 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
1022
1255
  File.delete("#{info_file}")
1023
1256
 
1024
1257
  app_info = app_info.to_json
1025
- if(File.exists?("info_to_java.in"))
1026
- java_pipe = open("info_to_java.in","w+")
1258
+ if(File.exists?("#{dir}/info_to_java.in"))
1259
+ java_pipe = open("#{dir}/info_to_java.in","w+")
1027
1260
  java_pipe.puts(app_info+"\n")
1028
1261
  java_pipe.flush
1029
1262
  java_pipe.close()
@@ -1035,13 +1268,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Base
1035
1268
 
1036
1269
  private
1037
1270
 
1038
- #
1039
1271
  #
1040
1272
  # --type TYPE # specify an output type i.e. json
1041
1273
  #
1042
1274
  def command(arg="--execute_live", type = nil, dir = Dir.pwd, ignore_stderr = false)
1043
-
1044
1275
  meta = Zillabyte::CLI::Config.get_config_info(dir, self, options)
1276
+
1045
1277
  #meta = Zillabyte::API::Functions.get_rich_meta_info_from_script(dir, self)
1046
1278
  error("could not extract meta information. missing zillabyte.conf.yml?", type) if meta.nil?
1047
1279
  error(meta["error_message"], type) if meta['status'] == "error"