td 0.10.95 → 0.10.96
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +8 -0
- data/lib/td/command/account.rb +1 -1
- data/lib/td/command/acl.rb +1 -1
- data/lib/td/command/aggr.rb +3 -3
- data/lib/td/command/bulk_import.rb +10 -8
- data/lib/td/command/common.rb +41 -1
- data/lib/td/command/db.rb +8 -4
- data/lib/td/command/export.rb +1 -1
- data/lib/td/command/import.rb +45 -2
- data/lib/td/command/job.rb +50 -20
- data/lib/td/command/list.rb +2 -1
- data/lib/td/command/query.rb +10 -2
- data/lib/td/command/result.rb +5 -4
- data/lib/td/command/runner.rb +8 -7
- data/lib/td/command/sample.rb +1 -1
- data/lib/td/command/sched.rb +11 -7
- data/lib/td/command/table.rb +11 -9
- data/lib/td/command/user.rb +13 -9
- data/lib/td/config.rb +17 -0
- data/lib/td/version.rb +1 -1
- metadata +19 -47
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4be1e9e6df99daff7484f415d97c0e07b1f8323b
|
4
|
+
data.tar.gz: e5a02f18e5ddc92ce3853064982dac0276c78b51
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84a6b09a04a928bc8cd07230fc21e041d451bb43d42614821623507d3bfcd55ffaa4d93bdc8372178d11937a5830df5cabef97a82bd53cd6992032b036e9331e
|
7
|
+
data.tar.gz: 6aa3f40c432bc25e2a8430595f071e92388f58ffb47f4e472d113100e58dc440ed49ebd1b3d9886ba36950979456791cf5e248d918e6e7fefffe29d3d4c689e9
|
data/ChangeLog
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 2013-12-04 version 0.10.96
|
2
|
+
|
3
|
+
* Add --format option to some subcommands to specify render format. json, csv and tsv.
|
4
|
+
* job:show and query subcommand now accept --format option without --output
|
5
|
+
* Show -k option in command result message if -k option is given.
|
6
|
+
* Support import:jar_update subcommand to update td-import seperately
|
7
|
+
|
8
|
+
|
1
9
|
== 2013-11-20 version 0.10.95
|
2
10
|
|
3
11
|
* Fix import:prepare command. It cannot parse time-format options that includes ',' charactor.
|
data/lib/td/command/account.rb
CHANGED
@@ -84,7 +84,7 @@ module Command
|
|
84
84
|
conf["account.apikey"] = client.apikey
|
85
85
|
conf.save
|
86
86
|
|
87
|
-
$stderr.puts "Use '#{$prog} db:create <db_name>' to create a database."
|
87
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "db:create <db_name>' to create a database."
|
88
88
|
end
|
89
89
|
|
90
90
|
def account_usage(op)
|
data/lib/td/command/acl.rb
CHANGED
@@ -18,7 +18,7 @@ module Command
|
|
18
18
|
|
19
19
|
if rows.empty?
|
20
20
|
$stderr.puts "There are no access controls."
|
21
|
-
$stderr.puts "Use '#{$prog} acl:grant <subject> <action> <scope>' to grant permissions."
|
21
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "acl:grant <subject> <action> <scope>' to grant permissions."
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/lib/td/command/aggr.rb
CHANGED
@@ -18,7 +18,7 @@ module Command
|
|
18
18
|
|
19
19
|
if rows.empty?
|
20
20
|
$stderr.puts "There are no aggregation schemas."
|
21
|
-
$stderr.puts "Use '#{$prog} aggr:create <name>' to create a aggregation schema."
|
21
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "aggr:create <name>' to create a aggregation schema."
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -130,7 +130,7 @@ module Command
|
|
130
130
|
rescue NotFoundError
|
131
131
|
cmd_debug_error $!
|
132
132
|
$stderr.puts "Aggregation schema '#{name}' does not exist."
|
133
|
-
$stderr.puts "Use '#{$prog} aggr:create #{name}' to create the aggregation schema."
|
133
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "aggr:create #{name}' to create the aggregation schema."
|
134
134
|
exit 1
|
135
135
|
rescue AlreadyExistsError
|
136
136
|
$stderr.puts "Aggregation log entry '#{entry_name}' already exists."
|
@@ -164,7 +164,7 @@ module Command
|
|
164
164
|
rescue NotFoundError
|
165
165
|
cmd_debug_error $!
|
166
166
|
$stderr.puts "Aggregation schema '#{name}' does not exist."
|
167
|
-
$stderr.puts "Use '#{$prog} aggr:create #{name}' to create the aggregation schema."
|
167
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "aggr:create #{name}' to create the aggregation schema."
|
168
168
|
exit 1
|
169
169
|
rescue AlreadyExistsError
|
170
170
|
$stderr.puts "Aggregation attribute entry '#{entry_name}' already exists."
|
@@ -3,6 +3,8 @@ module TreasureData
|
|
3
3
|
module Command
|
4
4
|
|
5
5
|
def bulk_import_list(op)
|
6
|
+
set_render_format_option(op)
|
7
|
+
|
6
8
|
op.cmd_parse
|
7
9
|
|
8
10
|
client = get_client
|
@@ -14,11 +16,11 @@ module Command
|
|
14
16
|
rows << {:Name=>bi.name, :Table=>"#{bi.database}.#{bi.table}", :Status=>bi.status.to_s.capitalize, :Frozen=>bi.upload_frozen? ? 'Frozen' : '', :JobID=>bi.job_id, :"Valid Parts"=>bi.valid_parts, :"Error Parts"=>bi.error_parts, :"Valid Records"=>bi.valid_records, :"Error Records"=>bi.error_records}
|
15
17
|
}
|
16
18
|
|
17
|
-
puts cmd_render_table(rows, :fields => [:Name, :Table, :Status, :Frozen, :JobID, :"Valid Parts", :"Error Parts", :"Valid Records", :"Error Records"], :max_width=>200)
|
19
|
+
puts cmd_render_table(rows, :fields => [:Name, :Table, :Status, :Frozen, :JobID, :"Valid Parts", :"Error Parts", :"Valid Records", :"Error Records"], :max_width=>200, :render_format => op.render_format)
|
18
20
|
|
19
21
|
if rows.empty?
|
20
22
|
$stderr.puts "There are no bulk import sessions."
|
21
|
-
$stderr.puts "Use '#{$prog} bulk_import:create <name> <db> <table>' to create a session."
|
23
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "bulk_import:create <name> <db> <table>' to create a session."
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -60,7 +62,7 @@ module Command
|
|
60
62
|
bi = bis.find {|bi| name == bi.name }
|
61
63
|
unless bi
|
62
64
|
$stderr.puts "Bulk import session '#{name}' does not exist."
|
63
|
-
$stderr.puts "Use '#{$prog} bulk_import:create <name> <db> <table>' to create a session."
|
65
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "bulk_import:create <name> <db> <table>' to create a session."
|
64
66
|
exit 1
|
65
67
|
end
|
66
68
|
|
@@ -183,7 +185,7 @@ module Command
|
|
183
185
|
job = client.perform_bulk_import(name)
|
184
186
|
|
185
187
|
$stderr.puts "Job #{job.job_id} is queued."
|
186
|
-
$stderr.puts "Use '#{$prog} job:show [-w] #{job.job_id}' to show the status."
|
188
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:show [-w] #{job.job_id}' to show the status."
|
187
189
|
end
|
188
190
|
end
|
189
191
|
|
@@ -245,7 +247,7 @@ module Command
|
|
245
247
|
if bi.status == 'performing'
|
246
248
|
$stderr.puts "Bulk import session '#{name}' is already performing."
|
247
249
|
$stderr.puts "Add '-f' option to force start."
|
248
|
-
$stderr.puts "Use '#{$prog} job:kill #{bi.job_id}' to cancel the last trial."
|
250
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:kill #{bi.job_id}' to cancel the last trial."
|
249
251
|
exit 1
|
250
252
|
elsif bi.status == 'ready'
|
251
253
|
$stderr.puts "Bulk import session '#{name}' is already ready to commit."
|
@@ -258,7 +260,7 @@ module Command
|
|
258
260
|
job = client.perform_bulk_import(name)
|
259
261
|
|
260
262
|
$stderr.puts "Job #{job.job_id} is queued."
|
261
|
-
$stderr.puts "Use '#{$prog} job:show [-w] #{job.job_id}' to show the status."
|
263
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:show [-w] #{job.job_id}' to show the status."
|
262
264
|
|
263
265
|
if wait
|
264
266
|
require 'td/command/job' # wait_job
|
@@ -285,13 +287,13 @@ module Command
|
|
285
287
|
bi = bis.find {|bi| name == bi.name }
|
286
288
|
unless bi
|
287
289
|
$stderr.puts "Bulk import session '#{name}' does not exist."
|
288
|
-
$stderr.puts "Use '#{$prog} bulk_import:create <name> <db> <table>' to create a session."
|
290
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "bulk_import:create <name> <db> <table>' to create a session."
|
289
291
|
exit 1
|
290
292
|
end
|
291
293
|
|
292
294
|
if bi.status == "uploading" || bi.status == "performing"
|
293
295
|
$stderr.puts "Bulk import session '#{name}' is not performed."
|
294
|
-
$stderr.puts "Use '#{$prog} bulk_import:perform <name>' to run."
|
296
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "bulk_import:perform <name>' to run."
|
295
297
|
exit 1
|
296
298
|
end
|
297
299
|
|
data/lib/td/command/common.rb
CHANGED
@@ -37,9 +37,49 @@ module Command
|
|
37
37
|
get_client(opts)
|
38
38
|
end
|
39
39
|
|
40
|
+
def set_render_format_option(op)
|
41
|
+
def op.render_format
|
42
|
+
@_render_format
|
43
|
+
end
|
44
|
+
op.on('-f', '--format FORMAT', 'format of the result rendering (tsv, csv, json or table. default is table)') {|s|
|
45
|
+
unless ['tsv', 'csv', 'json', 'table'].include?(s)
|
46
|
+
raise "Unknown format #{s.dump}. Supported format: tsv, csv, json, table"
|
47
|
+
end
|
48
|
+
op.instance_variable_set(:@_render_format, s)
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
40
52
|
def cmd_render_table(rows, *opts)
|
41
53
|
require 'hirb'
|
42
|
-
|
54
|
+
|
55
|
+
options = opts.first
|
56
|
+
format = options.delete(:render_format)
|
57
|
+
|
58
|
+
case format
|
59
|
+
when 'csv', 'tsv'
|
60
|
+
require 'csv'
|
61
|
+
headers = options[:fields]
|
62
|
+
csv_opts = {}
|
63
|
+
csv_opts[:col_sep] = "\t" if format == 'tsv'
|
64
|
+
CSV.generate('', csv_opts) { |csv|
|
65
|
+
csv << headers
|
66
|
+
rows.each { |row|
|
67
|
+
r = []
|
68
|
+
headers.each { |field|
|
69
|
+
r << row[field]
|
70
|
+
}
|
71
|
+
csv << r
|
72
|
+
}
|
73
|
+
}
|
74
|
+
when 'json'
|
75
|
+
require 'yajl'
|
76
|
+
|
77
|
+
Yajl.dump(rows)
|
78
|
+
when 'table'
|
79
|
+
Hirb::Helpers::Table.render(rows, *opts)
|
80
|
+
else
|
81
|
+
Hirb::Helpers::Table.render(rows, *opts)
|
82
|
+
end
|
43
83
|
end
|
44
84
|
|
45
85
|
def normalized_message
|
data/lib/td/command/db.rb
CHANGED
@@ -3,6 +3,8 @@ module TreasureData
|
|
3
3
|
module Command
|
4
4
|
|
5
5
|
def db_show(op)
|
6
|
+
set_render_format_option(op)
|
7
|
+
|
6
8
|
db_name = op.cmd_parse
|
7
9
|
|
8
10
|
client = get_client
|
@@ -20,10 +22,12 @@ module Command
|
|
20
22
|
[map[:Type].size, map[:Table]]
|
21
23
|
}
|
22
24
|
|
23
|
-
puts cmd_render_table(rows, :fields => [:Table, :Type, :Count, :Schema])
|
25
|
+
puts cmd_render_table(rows, :fields => [:Table, :Type, :Count, :Schema], :render_format => op.render_format)
|
24
26
|
end
|
25
27
|
|
26
28
|
def db_list(op)
|
29
|
+
set_render_format_option(op)
|
30
|
+
|
27
31
|
op.cmd_parse
|
28
32
|
|
29
33
|
client = get_client
|
@@ -33,11 +37,11 @@ module Command
|
|
33
37
|
dbs.each {|db|
|
34
38
|
rows << {:Name=>db.name, :Count=>db.count}
|
35
39
|
}
|
36
|
-
puts cmd_render_table(rows, :fields => [:Name, :Count])
|
40
|
+
puts cmd_render_table(rows, :fields => [:Name, :Count], :render_format => op.render_format)
|
37
41
|
|
38
42
|
if dbs.empty?
|
39
43
|
$stderr.puts "There are no databases."
|
40
|
-
$stderr.puts "Use '#{$prog} db:create <db_name>' to create a database."
|
44
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "db:create <db_name>' to create a database."
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -57,7 +61,7 @@ module Command
|
|
57
61
|
end
|
58
62
|
|
59
63
|
$stderr.puts "Database '#{db_name}' is created."
|
60
|
-
$stderr.puts "Use '#{$prog} table:create #{db_name} <table_name>' to create a table."
|
64
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "table:create #{db_name} <table_name>' to create a table."
|
61
65
|
end
|
62
66
|
|
63
67
|
def db_delete(op)
|
data/lib/td/command/export.rb
CHANGED
@@ -65,7 +65,7 @@ module Command
|
|
65
65
|
job = client.export(db_name, table_name, "s3", s3_opts)
|
66
66
|
|
67
67
|
$stderr.puts "Export job #{job.job_id} is queued."
|
68
|
-
$stderr.puts "Use '#{$prog} job:show #{job.job_id}' to show the status."
|
68
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:show #{job.job_id}' to show the status."
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
data/lib/td/command/import.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'td/updater'
|
1
2
|
|
2
3
|
module TreasureData
|
3
4
|
module Command
|
4
5
|
|
5
6
|
BASE_PATH = File.expand_path('../../..', File.dirname(__FILE__))
|
7
|
+
UPDATED_PATH = File.join(Updater.home_directory, ".td", "java")
|
6
8
|
|
7
9
|
JAVA_COMMAND = "java"
|
8
10
|
JAVA_MAIN_CLASS = "com.treasure_data.td_import.BulkImportCommand"
|
@@ -28,6 +30,34 @@ module Command
|
|
28
30
|
puts "td-import-java #{File.open(vfile, 'r').read}"
|
29
31
|
end
|
30
32
|
|
33
|
+
def import_jar_update(op)
|
34
|
+
last_updated = existence_jar_updated_time
|
35
|
+
|
36
|
+
require 'rexml/document'
|
37
|
+
require 'open-uri'
|
38
|
+
require 'fileutils'
|
39
|
+
|
40
|
+
doc = REXML::Document.new(open('http://maven.treasure-data.com/com/treasure_data/td-import/maven-metadata.xml') { |f| f.read })
|
41
|
+
updated = Time.strptime(REXML::XPath.match(doc, '/metadata/versioning/lastUpdated').first.text, "%Y%m%d%H%M%S")
|
42
|
+
version = REXML::XPath.match(doc, '/metadata/versioning/release').first.text
|
43
|
+
|
44
|
+
# Convert into UTF to compare time correctly
|
45
|
+
updated = (updated + updated.gmt_offset).utc unless updated.gmt?
|
46
|
+
last_updated = last_updated.utc unless last_updated.gmt?
|
47
|
+
|
48
|
+
if updated > last_updated
|
49
|
+
FileUtils.mkdir_p(UPDATED_PATH) unless File.exist?(UPDATED_PATH)
|
50
|
+
File.open(File.join(UPDATED_PATH, 'VERSION'), 'w') { |f| f.print "#{version} via import:jar_update" }
|
51
|
+
File.open(File.join(UPDATED_PATH, 'td-import-java.version'), 'w') { |f| f.print "#{version} #{updated}" }
|
52
|
+
File.open(File.join(UPDATED_PATH, 'td-import.jar'), 'wb') { |f|
|
53
|
+
f.print Updater.fetch("http://maven.treasure-data.com/com/treasure_data/td-import/#{version}/td-import-#{version}.jar")
|
54
|
+
}
|
55
|
+
puts "Installed td-import.jar #{version} into #{UPDATED_PATH}"
|
56
|
+
else
|
57
|
+
puts 'Installed td-import.jar is latest version'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
31
61
|
def import_prepare(op)
|
32
62
|
import_by_java('prepare')
|
33
63
|
end
|
@@ -113,7 +143,7 @@ module Command
|
|
113
143
|
|
114
144
|
private
|
115
145
|
def find_td_import_jar
|
116
|
-
libjars =
|
146
|
+
libjars = find_files('*.jar')
|
117
147
|
found = libjars.find { |path| File.basename(path) =~ /^td-import/ }
|
118
148
|
if found.nil?
|
119
149
|
$stderr.puts "td-import.jar is not found."
|
@@ -201,9 +231,22 @@ module Command
|
|
201
231
|
|
202
232
|
private
|
203
233
|
def find_version_file
|
204
|
-
vfile =
|
234
|
+
vfile = find_files('VERSION')
|
205
235
|
vfile
|
206
236
|
end
|
207
237
|
|
238
|
+
def existence_jar_updated_time
|
239
|
+
require 'time'
|
240
|
+
|
241
|
+
content = File.open(find_files("td-import-java.version").first).read
|
242
|
+
index = content.index(' ')
|
243
|
+
Time.parse(content[index + 1..-1].strip)
|
244
|
+
end
|
245
|
+
|
246
|
+
def find_files(target)
|
247
|
+
files = Dir.glob("#{UPDATED_PATH}/**/#{target}")
|
248
|
+
return files unless files.empty?
|
249
|
+
Dir.glob("#{BASE_PATH}/java/**/#{target}")
|
250
|
+
end
|
208
251
|
end
|
209
252
|
end
|
data/lib/td/command/job.rb
CHANGED
@@ -50,6 +50,7 @@ module Command
|
|
50
50
|
op.on('--slow [SECONDS]', 'show slow queries (default threshold: 3600 seconds)', Integer) { |i|
|
51
51
|
slower_than = i || 3600
|
52
52
|
}
|
53
|
+
set_render_format_option(op)
|
53
54
|
|
54
55
|
max = op.cmd_parse
|
55
56
|
|
@@ -76,14 +77,14 @@ module Command
|
|
76
77
|
rows << {:JobID => job.job_id, :Database => job.db_name, :Status => job.status, :Type => job.type, :Query => job.query.to_s, :Start => (start ? start.localtime : ''), :Elapsed => elapsed, :Priority => priority, :Result => job.result_url}
|
77
78
|
}
|
78
79
|
|
79
|
-
puts cmd_render_table(rows, :fields => [:JobID, :Status, :Start, :Elapsed, :Priority, :Result, :Type, :Database, :Query], :max_width => 140)
|
80
|
+
puts cmd_render_table(rows, :fields => [:JobID, :Status, :Start, :Elapsed, :Priority, :Result, :Type, :Database, :Query], :max_width => 140, :render_format => op.render_format)
|
80
81
|
end
|
81
82
|
|
82
83
|
def job_show(op)
|
83
84
|
verbose = nil
|
84
85
|
wait = false
|
85
86
|
output = nil
|
86
|
-
format =
|
87
|
+
format = nil
|
87
88
|
render_opts = {}
|
88
89
|
exclude = false
|
89
90
|
|
@@ -98,6 +99,7 @@ module Command
|
|
98
99
|
}
|
99
100
|
op.on('-o', '--output PATH', 'write result to the file') {|s|
|
100
101
|
output = s
|
102
|
+
format = 'tsv' if format.nil?
|
101
103
|
}
|
102
104
|
op.on('-f', '--format FORMAT', 'format of the result to write to the file (tsv, csv, json or msgpack)') {|s|
|
103
105
|
unless ['tsv', 'csv', 'json', 'msgpack', 'msgpack.gz'].include?(s)
|
@@ -111,6 +113,12 @@ module Command
|
|
111
113
|
|
112
114
|
job_id = op.cmd_parse
|
113
115
|
|
116
|
+
if output.nil? && format
|
117
|
+
unless ['tsv', 'csv', 'json'].include?(format)
|
118
|
+
raise "Supported formats are only tsv, csv and json without --output option"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
114
122
|
client = get_client
|
115
123
|
|
116
124
|
job = client.job(job_id)
|
@@ -222,7 +230,7 @@ module Command
|
|
222
230
|
write_result(job, output, format)
|
223
231
|
puts "written to #{output} in #{format} format"
|
224
232
|
else
|
225
|
-
render_result(job, render_opts)
|
233
|
+
render_result(job, render_opts, format)
|
226
234
|
end
|
227
235
|
end
|
228
236
|
|
@@ -231,7 +239,7 @@ module Command
|
|
231
239
|
when 'json'
|
232
240
|
require 'yajl'
|
233
241
|
first = true
|
234
|
-
|
242
|
+
open_file(output, "w") { |f|
|
235
243
|
f.write "["
|
236
244
|
job.result_each {|row|
|
237
245
|
if first
|
@@ -243,21 +251,24 @@ module Command
|
|
243
251
|
}
|
244
252
|
f.write "]"
|
245
253
|
}
|
254
|
+
puts if output.nil?
|
246
255
|
|
247
256
|
when 'msgpack'
|
248
|
-
|
257
|
+
open_file(output, "wb") { |f|
|
249
258
|
job.result_format('msgpack', f)
|
250
259
|
}
|
251
260
|
|
252
261
|
when 'msgpack.gz'
|
253
|
-
|
262
|
+
open_file(output, "wb") { |f|
|
254
263
|
job.result_format('msgpack.gz', f)
|
255
264
|
}
|
256
265
|
|
257
266
|
when 'csv'
|
258
267
|
require 'yajl'
|
259
268
|
require 'csv'
|
260
|
-
|
269
|
+
|
270
|
+
open_file(output, "w") { |f|
|
271
|
+
writer = CSV.new(f)
|
261
272
|
job.result_each {|row|
|
262
273
|
writer << row.map {|col| dump_column(col) }
|
263
274
|
}
|
@@ -265,7 +276,7 @@ module Command
|
|
265
276
|
|
266
277
|
when 'tsv'
|
267
278
|
require 'yajl'
|
268
|
-
|
279
|
+
open_file(output, "w") { |f|
|
269
280
|
job.result_each {|row|
|
270
281
|
first = true
|
271
282
|
row.each {|col|
|
@@ -285,22 +296,41 @@ module Command
|
|
285
296
|
end
|
286
297
|
end
|
287
298
|
|
288
|
-
def
|
299
|
+
def open_file(output, mode)
|
300
|
+
f = nil
|
301
|
+
if output.nil?
|
302
|
+
yield STDOUT
|
303
|
+
else
|
304
|
+
f = File.open(output, mode)
|
305
|
+
yield f
|
306
|
+
end
|
307
|
+
ensure
|
308
|
+
if f
|
309
|
+
f.close unless f.closed?
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def render_result(job, opts, format = nil)
|
289
314
|
require 'yajl'
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
315
|
+
|
316
|
+
if format.nil?
|
317
|
+
rows = []
|
318
|
+
job.result_each {|row|
|
319
|
+
# TODO limit number of rows to show
|
320
|
+
rows << row.map {|v|
|
321
|
+
dump_column(v)
|
322
|
+
}
|
295
323
|
}
|
296
|
-
}
|
297
324
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
325
|
+
opts[:max_width] = 10000
|
326
|
+
if job.hive_result_schema
|
327
|
+
opts[:change_fields] = job.hive_result_schema.map {|name,type| name }
|
328
|
+
end
|
302
329
|
|
303
|
-
|
330
|
+
puts cmd_render_table(rows, opts)
|
331
|
+
else
|
332
|
+
write_result(job, nil, format)
|
333
|
+
end
|
304
334
|
end
|
305
335
|
|
306
336
|
def dump_column(v)
|
data/lib/td/command/list.rb
CHANGED
@@ -249,6 +249,7 @@ module List
|
|
249
249
|
add_list 'import:show', %w[name], 'Show list of uploaded parts', 'import:show'
|
250
250
|
add_list 'import:create', %w[name db table], 'Create a new bulk import session to the the table', 'import:create logs_201201 example_db event_logs'
|
251
251
|
add_list 'import:java_version', %w[], 'Show version', 'import:java_version'
|
252
|
+
add_list 'import:jar_update', %w[], 'Update import jar', 'import:jar_update'
|
252
253
|
add_list 'import:prepare', %w[files_], 'Convert files into part file format', 'import:prepare logs/*.csv --format csv --columns time,uid,price,count --time-column "time" -o parts/'
|
253
254
|
add_list 'import:upload', %w[name files_], 'Upload or re-upload files into a bulk import session', 'import:upload parts/* --parallel 4'
|
254
255
|
add_list 'import:auto', %w[name files_], 'Upload files and automatically perform and commit the data', 'import:auto parts/* --parallel 4'
|
@@ -282,7 +283,7 @@ module List
|
|
282
283
|
add_list 'query', %w[sql?], 'Issue a query', 'query -d example_db -w -r rset1 "select count(*) from table1"',
|
283
284
|
'query -d example_db -w -r rset1 -q query.txt'
|
284
285
|
|
285
|
-
add_list 'job:show', %w[job_id], 'Show status and result of a job', 'job 1461'
|
286
|
+
add_list 'job:show', %w[job_id], 'Show status and result of a job', 'job:show 1461'
|
286
287
|
add_list 'job:status', %w[job_id], 'Show status progress of a job', 'job:status 1461'
|
287
288
|
add_list 'job:list', %w[max?], 'Show list of jobs', 'jobs', 'jobs --page 1'
|
288
289
|
add_list 'job:kill', %w[job_id], 'Kill or cancel a job', 'job:kill 1461'
|
data/lib/td/command/query.rb
CHANGED
@@ -6,7 +6,7 @@ module Command
|
|
6
6
|
db_name = nil
|
7
7
|
wait = false
|
8
8
|
output = nil
|
9
|
-
format =
|
9
|
+
format = nil
|
10
10
|
render_opts = {}
|
11
11
|
result_url = nil
|
12
12
|
result_user = nil
|
@@ -29,6 +29,7 @@ module Command
|
|
29
29
|
}
|
30
30
|
op.on('-o', '--output PATH', 'write result to the file') {|s|
|
31
31
|
output = s
|
32
|
+
format = 'tsv' if format.nil?
|
32
33
|
}
|
33
34
|
op.on('-f', '--format FORMAT', 'format of the result to write to the file (tsv, csv, json or msgpack)') {|s|
|
34
35
|
unless ['tsv', 'csv', 'json', 'msgpack'].include?(s)
|
@@ -69,6 +70,12 @@ module Command
|
|
69
70
|
|
70
71
|
sql = op.cmd_parse
|
71
72
|
|
73
|
+
if output.nil? && format
|
74
|
+
unless ['tsv', 'csv', 'json'].include?(format)
|
75
|
+
raise "Supported formats are only tsv, csv and json without --output option"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
72
79
|
unless db_name
|
73
80
|
$stderr.puts "-d, --database DB_NAME option is required."
|
74
81
|
exit 1
|
@@ -101,7 +108,7 @@ module Command
|
|
101
108
|
job = client.query(db_name, sql, result_url, priority, retry_limit, opts)
|
102
109
|
|
103
110
|
$stderr.puts "Job #{job.job_id} is queued."
|
104
|
-
$stderr.puts "Use '#{$prog} job:show #{job.job_id}' to show the status."
|
111
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:show #{job.job_id}' to show the status."
|
105
112
|
#$stderr.puts "See #{job.url} to see the progress."
|
106
113
|
|
107
114
|
if wait && !job.finished?
|
@@ -121,3 +128,4 @@ module Command
|
|
121
128
|
end
|
122
129
|
end
|
123
130
|
|
131
|
+
|
data/lib/td/command/result.rb
CHANGED
@@ -4,7 +4,6 @@ module Command
|
|
4
4
|
|
5
5
|
def result_show(op)
|
6
6
|
name = op.cmd_parse
|
7
|
-
|
8
7
|
client = get_client
|
9
8
|
|
10
9
|
rs = client.results
|
@@ -12,7 +11,7 @@ module Command
|
|
12
11
|
|
13
12
|
unless r
|
14
13
|
$stderr.puts "Result URL '#{name}' does not exist."
|
15
|
-
$stderr.puts "Use '#{$prog} result:create #{name} <URL>' to create the URL."
|
14
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "result:create #{name} <URL>' to create the URL."
|
16
15
|
exit 1
|
17
16
|
end
|
18
17
|
|
@@ -21,6 +20,8 @@ module Command
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def result_list(op)
|
23
|
+
set_render_format_option(op)
|
24
|
+
|
24
25
|
op.cmd_parse
|
25
26
|
|
26
27
|
client = get_client
|
@@ -35,11 +36,11 @@ module Command
|
|
35
36
|
map[:Name]
|
36
37
|
}
|
37
38
|
|
38
|
-
puts cmd_render_table(rows, :fields => [:Name, :URL])
|
39
|
+
puts cmd_render_table(rows, :fields => [:Name, :URL], :render_format => op.render_format)
|
39
40
|
|
40
41
|
if rs.empty?
|
41
42
|
$stderr.puts "There are no result URLs."
|
42
|
-
$stderr.puts "Use '#{$prog} result:create <name> <url>' to create a result URL."
|
43
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "result:create <name> <url>' to create a result URL."
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
data/lib/td/command/runner.rb
CHANGED
@@ -21,7 +21,7 @@ class Runner
|
|
21
21
|
$prog = @prog_name || File.basename($0)
|
22
22
|
|
23
23
|
op = OptionParser.new
|
24
|
-
op.version =
|
24
|
+
op.version = VERSION
|
25
25
|
op.banner = <<EOF
|
26
26
|
usage: #{$prog} [options] COMMAND [args]
|
27
27
|
|
@@ -109,13 +109,14 @@ EOF
|
|
109
109
|
|
110
110
|
require 'td/config'
|
111
111
|
if config_path
|
112
|
-
|
112
|
+
Config.path = config_path
|
113
113
|
end
|
114
114
|
if apikey
|
115
|
-
|
115
|
+
Config.apikey = apikey
|
116
|
+
Config.cl_apikey = true
|
116
117
|
end
|
117
118
|
if insecure
|
118
|
-
|
119
|
+
Config.secure = false
|
119
120
|
end
|
120
121
|
rescue
|
121
122
|
usage $!.to_s
|
@@ -127,16 +128,16 @@ EOF
|
|
127
128
|
Encoding.default_external = 'UTF-8' if Encoding.respond_to?(:default_external)
|
128
129
|
end
|
129
130
|
|
130
|
-
method =
|
131
|
+
method = Command::List.get_method(cmd)
|
131
132
|
unless method
|
132
133
|
$stderr.puts "'#{cmd}' is not a td command. Run '#{$prog}' to show the list."
|
133
|
-
|
134
|
+
Command::List.show_guess(cmd)
|
134
135
|
exit 1
|
135
136
|
end
|
136
137
|
|
137
138
|
begin
|
138
139
|
method.call(argv)
|
139
|
-
rescue
|
140
|
+
rescue ConfigError
|
140
141
|
$stderr.puts "TreasureData account is not configured yet."
|
141
142
|
$stderr.puts "Run '#{$prog} account' first."
|
142
143
|
rescue => e
|
data/lib/td/command/sample.rb
CHANGED
@@ -25,7 +25,7 @@ module Command
|
|
25
25
|
|
26
26
|
$stderr.puts "Create #{fname} with #{i} records whose time is"
|
27
27
|
$stderr.puts "from #{Time.at(last_time)} to #{Time.at(t)}."
|
28
|
-
$stderr.puts "Use '#{$prog} table:import <db> <table> --json #{fname}' to import this file."
|
28
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "table:import <db> <table> --json #{fname}' to import this file."
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
data/lib/td/command/sched.rb
CHANGED
@@ -5,6 +5,8 @@ module Command
|
|
5
5
|
def sched_list(op)
|
6
6
|
require 'td/command/job' # job_priority_name_of
|
7
7
|
|
8
|
+
set_render_format_option(op)
|
9
|
+
|
8
10
|
op.cmd_parse
|
9
11
|
|
10
12
|
client = get_client
|
@@ -19,7 +21,7 @@ module Command
|
|
19
21
|
map[:Name]
|
20
22
|
}
|
21
23
|
|
22
|
-
puts cmd_render_table(rows, :fields => [:Name, :Cron, :Timezone, :"Next schedule", :Delay, :Priority, :Result, :Database, :Query], :max_width=>500)
|
24
|
+
puts cmd_render_table(rows, :fields => [:Name, :Cron, :Timezone, :"Next schedule", :Delay, :Priority, :Result, :Database, :Query], :max_width=>500, :render_format => op.render_format)
|
23
25
|
end
|
24
26
|
|
25
27
|
def sched_create(op)
|
@@ -119,7 +121,7 @@ module Command
|
|
119
121
|
rescue NotFoundError
|
120
122
|
cmd_debug_error $!
|
121
123
|
$stderr.puts "Schedule '#{name}' does not exist."
|
122
|
-
$stderr.puts "Use '#{$prog} sched:list' to show list of the schedules."
|
124
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "sched:list' to show list of the schedules."
|
123
125
|
exit 1
|
124
126
|
end
|
125
127
|
|
@@ -196,7 +198,7 @@ module Command
|
|
196
198
|
rescue NotFoundError
|
197
199
|
cmd_debug_error $!
|
198
200
|
$stderr.puts "Schedule '#{name}' does not exist."
|
199
|
-
$stderr.puts "Use '#{$prog} sched:list' to show list of the schedules."
|
201
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "sched:list' to show list of the schedules."
|
200
202
|
exit 1
|
201
203
|
end
|
202
204
|
|
@@ -215,6 +217,7 @@ module Command
|
|
215
217
|
op.on('-s', '--skip N', 'skip N schedules', Integer) {|i|
|
216
218
|
skip = i
|
217
219
|
}
|
220
|
+
set_render_format_option(op)
|
218
221
|
|
219
222
|
name, max = op.cmd_parse
|
220
223
|
|
@@ -231,7 +234,7 @@ module Command
|
|
231
234
|
rescue NotFoundError
|
232
235
|
cmd_debug_error $!
|
233
236
|
$stderr.puts "Schedule '#{name}' does not exist."
|
234
|
-
$stderr.puts "Use '#{$prog} sched:list' to show list of the schedules."
|
237
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "sched:list' to show list of the schedules."
|
235
238
|
exit 1
|
236
239
|
end
|
237
240
|
|
@@ -254,7 +257,7 @@ module Command
|
|
254
257
|
rows << {:Time => j.scheduled_at.localtime, :JobID => j.job_id, :Status => j.status, :Priority => job_priority_name_of(j.priority), :Result=>j.result_url}
|
255
258
|
}
|
256
259
|
|
257
|
-
puts cmd_render_table(rows, :fields => [:JobID, :Time, :Status, :Priority, :Result])
|
260
|
+
puts cmd_render_table(rows, :fields => [:JobID, :Time, :Status, :Priority, :Result], :render_format => op.render_format)
|
258
261
|
end
|
259
262
|
|
260
263
|
def sched_run(op)
|
@@ -263,6 +266,7 @@ module Command
|
|
263
266
|
op.on('-n', '--num N', 'number of jobs to run', Integer) {|i|
|
264
267
|
num = i
|
265
268
|
}
|
269
|
+
set_render_format_option(op)
|
266
270
|
|
267
271
|
name, time = op.cmd_parse
|
268
272
|
|
@@ -286,7 +290,7 @@ module Command
|
|
286
290
|
rescue NotFoundError
|
287
291
|
cmd_debug_error $!
|
288
292
|
$stderr.puts "Schedule '#{name}' does not exist."
|
289
|
-
$stderr.puts "Use '#{$prog} sched:list' to show list of the schedules."
|
293
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "sched:list' to show list of the schedules."
|
290
294
|
exit 1
|
291
295
|
end
|
292
296
|
|
@@ -296,7 +300,7 @@ module Command
|
|
296
300
|
}
|
297
301
|
|
298
302
|
$stderr.puts "Scheduled #{num} jobs from #{t}."
|
299
|
-
puts cmd_render_table(rows, :fields => [:JobID, :Time], :max_width=>500)
|
303
|
+
puts cmd_render_table(rows, :fields => [:JobID, :Time], :max_width=>500, :render_format => op.render_format)
|
300
304
|
end
|
301
305
|
|
302
306
|
end
|
data/lib/td/command/table.rb
CHANGED
@@ -65,7 +65,7 @@ module Command
|
|
65
65
|
rescue NotFoundError
|
66
66
|
cmd_debug_error $!
|
67
67
|
$stderr.puts "Database '#{db_name}' does not exist."
|
68
|
-
$stderr.puts "Use '#{$prog} db:create #{db_name}' to create the database."
|
68
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "db:create #{db_name}' to create the database."
|
69
69
|
exit 1
|
70
70
|
rescue AlreadyExistsError
|
71
71
|
cmd_debug_error $!
|
@@ -111,7 +111,7 @@ module Command
|
|
111
111
|
rescue NotFoundError
|
112
112
|
cmd_debug_error $!
|
113
113
|
$stderr.puts "Table '#{db_name}.#{table_name}' does not exist."
|
114
|
-
$stderr.puts "Use '#{$prog} table:list #{db_name}' to show list of the tables."
|
114
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "table:list #{db_name}' to show list of the tables."
|
115
115
|
exit 1
|
116
116
|
end
|
117
117
|
|
@@ -121,6 +121,7 @@ module Command
|
|
121
121
|
def table_list(op)
|
122
122
|
require 'parallel'
|
123
123
|
|
124
|
+
format = 'table'
|
124
125
|
num_threads = 4
|
125
126
|
show_size_in_bytes = false
|
126
127
|
|
@@ -130,6 +131,7 @@ module Command
|
|
130
131
|
op.on('--show-bytes', 'show estimated table size in bytes') {
|
131
132
|
show_size_in_bytes = true
|
132
133
|
}
|
134
|
+
set_render_format_option(op)
|
133
135
|
|
134
136
|
db_name = op.cmd_parse
|
135
137
|
|
@@ -169,18 +171,18 @@ module Command
|
|
169
171
|
[map[:Database], map[:Type].size, map[:Table]]
|
170
172
|
}
|
171
173
|
|
172
|
-
puts cmd_render_table(rows, :fields => [:Database, :Table, :Type, :Count, :Size, 'Last import', 'Last log timestamp', :Schema], :max_width=>500)
|
174
|
+
puts cmd_render_table(rows, :fields => [:Database, :Table, :Type, :Count, :Size, 'Last import', 'Last log timestamp', :Schema], :max_width=>500, :render_format => op.render_format)
|
173
175
|
|
174
176
|
if rows.empty?
|
175
177
|
if db_name
|
176
178
|
$stderr.puts "Database '#{db_name}' has no tables."
|
177
|
-
$stderr.puts "Use '#{$prog} table:create <db> <table>' to create a table."
|
179
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "table:create <db> <table>' to create a table."
|
178
180
|
elsif databases.empty?
|
179
181
|
$stderr.puts "There are no databases."
|
180
|
-
$stderr.puts "Use '#{$prog} db:create <db>' to create a database."
|
182
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "db:create <db>' to create a database."
|
181
183
|
else
|
182
184
|
$stderr.puts "There are no tables."
|
183
|
-
$stderr.puts "Use '#{$prog} table:create <db> <table>' to create a table."
|
185
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "table:create <db> <table>' to create a table."
|
184
186
|
end
|
185
187
|
end
|
186
188
|
end
|
@@ -292,7 +294,7 @@ module Command
|
|
292
294
|
# from = Time.parse(s).to_i
|
293
295
|
# end
|
294
296
|
#}
|
295
|
-
op.on('-w', '--wait', 'wait
|
297
|
+
op.on('-w', '--wait', 'wait until the job is completed', TrueClass) {|b|
|
296
298
|
wait = b
|
297
299
|
}
|
298
300
|
op.on('--s3-bucket NAME', 'name of the s3 bucket to output') {|s|
|
@@ -319,7 +321,7 @@ module Command
|
|
319
321
|
job = table.export('s3', opts)
|
320
322
|
|
321
323
|
$stderr.puts "Export job #{job.job_id} is queued."
|
322
|
-
$stderr.puts "Use '#{$prog} job:show #{job.job_id}' to show the status."
|
324
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:show #{job.job_id}' to show the status."
|
323
325
|
|
324
326
|
if wait && !job.finished?
|
325
327
|
wait_job(job)
|
@@ -378,7 +380,7 @@ module Command
|
|
378
380
|
job = client.partial_delete(db_name, table_name, to, from, opts)
|
379
381
|
|
380
382
|
$stderr.puts "Partial delete job #{job.job_id} is queued."
|
381
|
-
$stderr.puts "Use '#{$prog} job:show #{job.job_id}' to show the status."
|
383
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "job:show #{job.job_id}' to show the status."
|
382
384
|
|
383
385
|
if wait && !job.finished?
|
384
386
|
wait_job(job)
|
data/lib/td/command/user.rb
CHANGED
@@ -11,7 +11,7 @@ module Command
|
|
11
11
|
user = users.find {|user| name == user.name }
|
12
12
|
unless user
|
13
13
|
$stderr.puts "User '#{name}' does not exist."
|
14
|
-
$stderr.puts "Use '#{$prog} user:create <name>' to create an user."
|
14
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "user:create <name>' to create an user."
|
15
15
|
exit 1
|
16
16
|
end
|
17
17
|
|
@@ -20,6 +20,8 @@ module Command
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def user_list(op)
|
23
|
+
set_render_format_option(op)
|
24
|
+
|
23
25
|
op.cmd_parse
|
24
26
|
|
25
27
|
client = get_client
|
@@ -31,11 +33,11 @@ module Command
|
|
31
33
|
rows << {:Name => user.name, :Email => user.email}
|
32
34
|
}
|
33
35
|
|
34
|
-
puts cmd_render_table(rows, :fields => [:Name, :Email])
|
36
|
+
puts cmd_render_table(rows, :fields => [:Name, :Email], :render_format => op.render_format)
|
35
37
|
|
36
38
|
if rows.empty?
|
37
39
|
$stderr.puts "There are no users."
|
38
|
-
$stderr.puts "Use '#{$prog} user:create <name>' to create an users."
|
40
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "user:create <name>' to create an users."
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -118,7 +120,7 @@ module Command
|
|
118
120
|
client.add_user(name, nil, email, password)
|
119
121
|
|
120
122
|
$stderr.puts "User '#{name}' is created."
|
121
|
-
$stderr.puts "Use '#{$prog} user:apikeys #{name}' to show the API key."
|
123
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "user:apikeys #{name}' to show the API key."
|
122
124
|
end
|
123
125
|
|
124
126
|
def user_delete(op)
|
@@ -144,12 +146,12 @@ module Command
|
|
144
146
|
client.add_apikey(name)
|
145
147
|
rescue TreasureData::NotFoundError
|
146
148
|
$stderr.puts "User '#{name}' does not exist."
|
147
|
-
$stderr.puts "Use '#{$prog} users' to show users."
|
149
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "users' to show users."
|
148
150
|
exit 1
|
149
151
|
end
|
150
152
|
|
151
153
|
$stderr.puts "Added an API key to user '#{name}'."
|
152
|
-
$stderr.puts "Use '#{$prog} user:apikeys #{name}' to show the API key"
|
154
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "user:apikeys #{name}' to show the API key"
|
153
155
|
end
|
154
156
|
|
155
157
|
def user_apikey_remove(op)
|
@@ -161,8 +163,8 @@ module Command
|
|
161
163
|
client.remove_apikey(name, key)
|
162
164
|
rescue TreasureData::NotFoundError
|
163
165
|
$stderr.puts "User '#{name}' or API key '#{key}' does not exist."
|
164
|
-
$stderr.puts "Use '#{$prog} users' to show users."
|
165
|
-
$stderr.puts "Use '#{$prog} user:apikeys '#{key}' to show API keys"
|
166
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "users' to show users."
|
167
|
+
$stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "user:apikeys '#{key}' to show API keys"
|
166
168
|
exit 1
|
167
169
|
end
|
168
170
|
|
@@ -170,6 +172,8 @@ module Command
|
|
170
172
|
end
|
171
173
|
|
172
174
|
def user_apikey_list(op)
|
175
|
+
set_render_format_option(op)
|
176
|
+
|
173
177
|
name = op.cmd_parse
|
174
178
|
|
175
179
|
client = get_client
|
@@ -181,7 +185,7 @@ module Command
|
|
181
185
|
rows << {:Key => key}
|
182
186
|
}
|
183
187
|
|
184
|
-
puts cmd_render_table(rows, :fields => [:Key])
|
188
|
+
puts cmd_render_table(rows, :fields => [:Key], :render_format => op.render_format)
|
185
189
|
end
|
186
190
|
|
187
191
|
def user_password_change(op)
|
data/lib/td/config.rb
CHANGED
@@ -91,6 +91,7 @@ class Config
|
|
91
91
|
@@path = ENV['TREASURE_DATA_CONFIG_PATH'] || ENV['TD_CONFIG_PATH'] || File.join(ENV['HOME'], '.td', 'td.conf')
|
92
92
|
@@apikey = ENV['TREASURE_DATA_API_KEY'] || ENV['TD_API_KEY']
|
93
93
|
@@apikey = nil if @@apikey == ""
|
94
|
+
@@cl_apikey = false # flag to indicate whether an apikey has been provided through the command-line
|
94
95
|
@@secure = true
|
95
96
|
|
96
97
|
def self.path
|
@@ -109,6 +110,22 @@ class Config
|
|
109
110
|
@@apikey = apikey
|
110
111
|
end
|
111
112
|
|
113
|
+
def self.cl_apikey
|
114
|
+
@@cl_apikey
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.cl_apikey=(flag)
|
118
|
+
@@cl_apikey = flag
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.cl_apikey_string
|
122
|
+
if @@cl_apikey
|
123
|
+
"-k #{@@apikey} "
|
124
|
+
else
|
125
|
+
""
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
112
129
|
def self.secure
|
113
130
|
@@secure
|
114
131
|
end
|
data/lib/td/version.rb
CHANGED
metadata
CHANGED
@@ -1,34 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
5
|
-
prerelease:
|
4
|
+
version: 0.10.96
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Treasure Data, Inc.
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: msgpack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.4.4
|
22
|
-
- -
|
20
|
+
- - '!='
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: 0.5.0
|
25
|
-
- -
|
23
|
+
- - '!='
|
26
24
|
- !ruby/object:Gem::Version
|
27
25
|
version: 0.5.1
|
28
|
-
- -
|
26
|
+
- - '!='
|
29
27
|
- !ruby/object:Gem::Version
|
30
28
|
version: 0.5.2
|
31
|
-
- -
|
29
|
+
- - '!='
|
32
30
|
- !ruby/object:Gem::Version
|
33
31
|
version: 0.5.3
|
34
32
|
- - <
|
@@ -37,21 +35,20 @@ dependencies:
|
|
37
35
|
type: :runtime
|
38
36
|
prerelease: false
|
39
37
|
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
38
|
requirements:
|
42
|
-
- -
|
39
|
+
- - '>='
|
43
40
|
- !ruby/object:Gem::Version
|
44
41
|
version: 0.4.4
|
45
|
-
- -
|
42
|
+
- - '!='
|
46
43
|
- !ruby/object:Gem::Version
|
47
44
|
version: 0.5.0
|
48
|
-
- -
|
45
|
+
- - '!='
|
49
46
|
- !ruby/object:Gem::Version
|
50
47
|
version: 0.5.1
|
51
|
-
- -
|
48
|
+
- - '!='
|
52
49
|
- !ruby/object:Gem::Version
|
53
50
|
version: 0.5.2
|
54
|
-
- -
|
51
|
+
- - '!='
|
55
52
|
- !ruby/object:Gem::Version
|
56
53
|
version: 0.5.3
|
57
54
|
- - <
|
@@ -60,7 +57,6 @@ dependencies:
|
|
60
57
|
- !ruby/object:Gem::Dependency
|
61
58
|
name: yajl-ruby
|
62
59
|
requirement: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
60
|
requirements:
|
65
61
|
- - ~>
|
66
62
|
- !ruby/object:Gem::Version
|
@@ -68,7 +64,6 @@ dependencies:
|
|
68
64
|
type: :runtime
|
69
65
|
prerelease: false
|
70
66
|
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
67
|
requirements:
|
73
68
|
- - ~>
|
74
69
|
- !ruby/object:Gem::Version
|
@@ -76,23 +71,20 @@ dependencies:
|
|
76
71
|
- !ruby/object:Gem::Dependency
|
77
72
|
name: hirb
|
78
73
|
requirement: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
74
|
requirements:
|
81
|
-
- -
|
75
|
+
- - '>='
|
82
76
|
- !ruby/object:Gem::Version
|
83
77
|
version: 0.4.5
|
84
78
|
type: :runtime
|
85
79
|
prerelease: false
|
86
80
|
version_requirements: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
81
|
requirements:
|
89
|
-
- -
|
82
|
+
- - '>='
|
90
83
|
- !ruby/object:Gem::Version
|
91
84
|
version: 0.4.5
|
92
85
|
- !ruby/object:Gem::Dependency
|
93
86
|
name: parallel
|
94
87
|
requirement: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
88
|
requirements:
|
97
89
|
- - ~>
|
98
90
|
- !ruby/object:Gem::Version
|
@@ -100,7 +92,6 @@ dependencies:
|
|
100
92
|
type: :runtime
|
101
93
|
prerelease: false
|
102
94
|
version_requirements: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
95
|
requirements:
|
105
96
|
- - ~>
|
106
97
|
- !ruby/object:Gem::Version
|
@@ -108,7 +99,6 @@ dependencies:
|
|
108
99
|
- !ruby/object:Gem::Dependency
|
109
100
|
name: td-client
|
110
101
|
requirement: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
102
|
requirements:
|
113
103
|
- - ~>
|
114
104
|
- !ruby/object:Gem::Version
|
@@ -116,7 +106,6 @@ dependencies:
|
|
116
106
|
type: :runtime
|
117
107
|
prerelease: false
|
118
108
|
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
109
|
requirements:
|
121
110
|
- - ~>
|
122
111
|
- !ruby/object:Gem::Version
|
@@ -124,7 +113,6 @@ dependencies:
|
|
124
113
|
- !ruby/object:Gem::Dependency
|
125
114
|
name: td-logger
|
126
115
|
requirement: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
116
|
requirements:
|
129
117
|
- - ~>
|
130
118
|
- !ruby/object:Gem::Version
|
@@ -132,7 +120,6 @@ dependencies:
|
|
132
120
|
type: :runtime
|
133
121
|
prerelease: false
|
134
122
|
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
123
|
requirements:
|
137
124
|
- - ~>
|
138
125
|
- !ruby/object:Gem::Version
|
@@ -140,7 +127,6 @@ dependencies:
|
|
140
127
|
- !ruby/object:Gem::Dependency
|
141
128
|
name: rubyzip
|
142
129
|
requirement: !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
130
|
requirements:
|
145
131
|
- - ~>
|
146
132
|
- !ruby/object:Gem::Version
|
@@ -148,7 +134,6 @@ dependencies:
|
|
148
134
|
type: :runtime
|
149
135
|
prerelease: false
|
150
136
|
version_requirements: !ruby/object:Gem::Requirement
|
151
|
-
none: false
|
152
137
|
requirements:
|
153
138
|
- - ~>
|
154
139
|
- !ruby/object:Gem::Version
|
@@ -156,7 +141,6 @@ dependencies:
|
|
156
141
|
- !ruby/object:Gem::Dependency
|
157
142
|
name: rake
|
158
143
|
requirement: !ruby/object:Gem::Requirement
|
159
|
-
none: false
|
160
144
|
requirements:
|
161
145
|
- - ~>
|
162
146
|
- !ruby/object:Gem::Version
|
@@ -164,7 +148,6 @@ dependencies:
|
|
164
148
|
type: :development
|
165
149
|
prerelease: false
|
166
150
|
version_requirements: !ruby/object:Gem::Requirement
|
167
|
-
none: false
|
168
151
|
requirements:
|
169
152
|
- - ~>
|
170
153
|
- !ruby/object:Gem::Version
|
@@ -172,7 +155,6 @@ dependencies:
|
|
172
155
|
- !ruby/object:Gem::Dependency
|
173
156
|
name: rspec
|
174
157
|
requirement: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
158
|
requirements:
|
177
159
|
- - ~>
|
178
160
|
- !ruby/object:Gem::Version
|
@@ -180,7 +162,6 @@ dependencies:
|
|
180
162
|
type: :development
|
181
163
|
prerelease: false
|
182
164
|
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
none: false
|
184
165
|
requirements:
|
185
166
|
- - ~>
|
186
167
|
- !ruby/object:Gem::Version
|
@@ -188,7 +169,6 @@ dependencies:
|
|
188
169
|
- !ruby/object:Gem::Dependency
|
189
170
|
name: simplecov
|
190
171
|
requirement: !ruby/object:Gem::Requirement
|
191
|
-
none: false
|
192
172
|
requirements:
|
193
173
|
- - ~>
|
194
174
|
- !ruby/object:Gem::Version
|
@@ -196,7 +176,6 @@ dependencies:
|
|
196
176
|
type: :development
|
197
177
|
prerelease: false
|
198
178
|
version_requirements: !ruby/object:Gem::Requirement
|
199
|
-
none: false
|
200
179
|
requirements:
|
201
180
|
- - ~>
|
202
181
|
- !ruby/object:Gem::Version
|
@@ -279,33 +258,26 @@ files:
|
|
279
258
|
- td.gemspec
|
280
259
|
homepage: http://treasure-data.com/
|
281
260
|
licenses: []
|
261
|
+
metadata: {}
|
282
262
|
post_install_message:
|
283
263
|
rdoc_options: []
|
284
264
|
require_paths:
|
285
265
|
- lib
|
286
266
|
required_ruby_version: !ruby/object:Gem::Requirement
|
287
|
-
none: false
|
288
267
|
requirements:
|
289
|
-
- -
|
268
|
+
- - '>='
|
290
269
|
- !ruby/object:Gem::Version
|
291
270
|
version: '0'
|
292
|
-
segments:
|
293
|
-
- 0
|
294
|
-
hash: -3232454928558496332
|
295
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
296
|
-
none: false
|
297
272
|
requirements:
|
298
|
-
- -
|
273
|
+
- - '>='
|
299
274
|
- !ruby/object:Gem::Version
|
300
275
|
version: '0'
|
301
|
-
segments:
|
302
|
-
- 0
|
303
|
-
hash: -3232454928558496332
|
304
276
|
requirements: []
|
305
277
|
rubyforge_project:
|
306
|
-
rubygems_version:
|
278
|
+
rubygems_version: 2.0.3
|
307
279
|
signing_key:
|
308
|
-
specification_version:
|
280
|
+
specification_version: 4
|
309
281
|
summary: CLI to manage data on Treasure Data, the Hadoop-based cloud data warehousing
|
310
282
|
test_files:
|
311
283
|
- spec/file_reader/filter_spec.rb
|