td 0.11.2 → 0.11.3
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 +8 -8
- data/ChangeLog +45 -14
- data/README.rdoc +50 -28
- data/dist/exe.rake +2 -2
- data/dist/pkg.rake +2 -2
- data/lib/td/command/bulk_import.rb +1 -5
- data/lib/td/command/common.rb +116 -20
- data/lib/td/command/help.rb +1 -1
- data/lib/td/command/import.rb +50 -5
- data/lib/td/command/job.rb +57 -15
- data/lib/td/command/list.rb +90 -87
- data/lib/td/command/runner.rb +33 -21
- data/lib/td/command/sched.rb +13 -5
- data/lib/td/command/server.rb +6 -3
- data/lib/td/command/table.rb +75 -61
- data/lib/td/updater.rb +31 -62
- data/lib/td/version.rb +1 -1
- data/spec/td/common_spec.rb +192 -0
- data/spec/td/updater_spec.rb +9 -3
- data/td.gemspec +2 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTZmYjMxNzU1OTk3MzQ0MzcyMGU5NzRhNzdkZjZhM2Q4ZTFlNDEyMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzFhNTY5YjIyNmRlYTUzNzk1YWIxY2Q1MzMxMzc1YjFhODkxZmY4ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTZkZGQyMWFkYjcxMDE2NWI2ZWEwZTVjNDQ5ODQ4YzYxMjMwOTJmZTI1Njc4
|
10
|
+
MGI4YWU1NzgzOTRmNjQ3ZDE5YjUxMTY2ZjhlMDM5Y2MxMmFjMWE4ZTEwNWM3
|
11
|
+
ZmZlYzM5ODRmYTQ0MTE0ZmRkMmFmNTNmNGYyMDU5MDhjNzRhOGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWI1OGZjYTE4ODBjZDc4YWFiMDJhZWNmYmVlNjg3OTdkODA4Y2FlMjkyMDY5
|
14
|
+
OGY3M2M1N2QzYTMwMGFiZDhhM2RhZTQ3ODVkMjgxNWE0MGYzZjFhM2Y3Y2Ux
|
15
|
+
OGZiYTU0ZTFiOWEyZGYzZTgyMmRmMTFhOTY0Mzc2ZDM4Y2NlN2Q=
|
data/ChangeLog
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
== 2014-07-31 version 0.11.3
|
2
|
+
|
3
|
+
* Support name updates for schedules using sched:update command
|
4
|
+
* Update Bulk Import JAR file repository to Central Maven Repository where
|
5
|
+
the Bulk Import JAR file is now hosted
|
6
|
+
* Require Ruby v1.9 or superior for td to work ==> deprecated Ruby v1.8
|
7
|
+
* Limit the number of keys in the input file (JSON, Msgoack) that can be
|
8
|
+
imported in one import to 512 as per the backend's limitations
|
9
|
+
* Fixed import:create to work with import-only permissions and write-only API
|
10
|
+
keys
|
11
|
+
* Handle NotFoundError, AuthError, and ForbiddenError to suppress printing of
|
12
|
+
the exception stack traces but yet show the exception class name for reference
|
13
|
+
back to the actual HTTP error code
|
14
|
+
* validate the endpoints provided by -e / --endpoint using the Health-check
|
15
|
+
REST API /v3/system/server_status. Validation is avoided for any command
|
16
|
+
that does not require connectivity with the Treasure Data REST API server
|
17
|
+
* JAR update errors are ignored when running import:prepare. This command
|
18
|
+
does not require connectivity and can be ran even when the machine is not
|
19
|
+
connected to the internet
|
20
|
+
* Fixed Time based progress indicator to reflect the update interval exactly
|
21
|
+
* Read logging.properties Logging configuration file from ~/.td/java first,
|
22
|
+
then the td repository's location (default). This allows customization of
|
23
|
+
the logging for the Java Bulk Import CLI (td-import-java).
|
24
|
+
* Improve job result downloading by showing the total downloaded size and
|
25
|
+
percentage progress (Size based progress indicator). This is done when
|
26
|
+
printing the result in tabular format or writing the result on file in csv,
|
27
|
+
tsv, json, msgpack, or msgpack.gz formats. When displaying the result in csv,
|
28
|
+
tsv, and json format on stdout, the progress indicator is not used since the
|
29
|
+
data is progressively streamed in as it's received from the API server
|
30
|
+
|
1
31
|
== 2014-06-18 version 0.11.2
|
2
32
|
|
3
33
|
* Improve the update experience by showing a download progress indicator
|
@@ -7,7 +37,7 @@
|
|
7
37
|
* Add support for other/alternative backends using the -e / --endpoint
|
8
38
|
option. The backend can be also saved on the configuration file of use
|
9
39
|
via the 'td server:endpoint' or when running 'td -e <newendpoint> account'
|
10
|
-
command. The TD_API_SERVER environment variable still takes
|
40
|
+
command. The TD_API_SERVER environment variable still takes precedence
|
11
41
|
over all these settings
|
12
42
|
* Removed Treasure Data Result Output database and table name client side
|
13
43
|
validation since it's performed in the API backend
|
@@ -82,7 +112,7 @@
|
|
82
112
|
* Add --format option to some subcommands to specify render format. json, csv and tsv.
|
83
113
|
* job:show and query subcommand now accept --format option without --output
|
84
114
|
* Show -k option in command result message if -k option is given.
|
85
|
-
* Support import:jar_update subcommand to update td-import
|
115
|
+
* Support import:jar_update subcommand to update td-import separately
|
86
116
|
|
87
117
|
|
88
118
|
== 2013-11-20 version 0.10.95
|
@@ -109,10 +139,10 @@
|
|
109
139
|
|
110
140
|
== 2013-11-05 version 0.10.92
|
111
141
|
|
112
|
-
* Improve import commands. It can parse string values of 'HH:mm:ss' time format automatically without specifying '%T' and transfer into long
|
113
|
-
* Improve import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss' time format automatically without specifying 'time-format' and transfer into long
|
114
|
-
* Improve import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss Z' time format automatically without specifying 'time-format' and transfer into long
|
115
|
-
* Add '
|
142
|
+
* Improve import commands. It can parse string values of 'HH:mm:ss' time format automatically without specifying '%T' and transfer into long Unix timestamp.
|
143
|
+
* Improve import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss' time format automatically without specifying 'time-format' and transfer into long Unix timestamp.
|
144
|
+
* Improve import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss Z' time format automatically without specifying 'time-format' and transfer into long Unix timestamp.
|
145
|
+
* Add 'regexp' to source file format option of import:prepare command.
|
116
146
|
* Fix import:upload command. NullPointerException often occurs when data files are uploaded.
|
117
147
|
|
118
148
|
|
@@ -205,7 +235,7 @@
|
|
205
235
|
== 2013-05-27 version 0.10.78
|
206
236
|
|
207
237
|
* Add -q(--query) option to sched:create command
|
208
|
-
* Add -x option to job:show,
|
238
|
+
* Add -x option to job:show, exclude result from automatically being downloaded
|
209
239
|
* Update parallel gem dependency to 0.6.1 or later
|
210
240
|
* user:add now requires email and password
|
211
241
|
* td-client v0.8.50
|
@@ -214,8 +244,8 @@
|
|
214
244
|
== 2013-05-06 version 0.10.77
|
215
245
|
|
216
246
|
* Fix 'invalid byte sequence in UTF-8' at job result writing to CSV
|
217
|
-
* Fix installed version check
|
218
|
-
* Remove using curses to detect terminal height for Windows unexpected
|
247
|
+
* Fix installed version check mechanism of auto updater
|
248
|
+
* Remove using curses to detect terminal height for Windows unexpected behavior
|
219
249
|
* Set User-Agent header
|
220
250
|
|
221
251
|
|
@@ -280,7 +310,8 @@
|
|
280
310
|
|
281
311
|
== 2013-01-22 version 0.10.68
|
282
312
|
|
283
|
-
* Fixed
|
313
|
+
* Fixed command-line argument handling problems of
|
314
|
+
bulk_import:prepare_parts2 subcommand
|
284
315
|
|
285
316
|
|
286
317
|
== 2013-01-18 version 0.10.67
|
@@ -412,7 +443,7 @@ results on console
|
|
412
443
|
|
413
444
|
* bulk_import:prepare_parts supports --true and --false type conversion options
|
414
445
|
* bulk_import:prepare_parts supports --time-value option
|
415
|
-
* bulk_import:prepare_parts
|
446
|
+
* bulk_import:prepare_parts converts /null/i to NULL by default
|
416
447
|
|
417
448
|
|
418
449
|
== 2012-09-04 version 0.10.44
|
@@ -432,7 +463,7 @@ results on console
|
|
432
463
|
|
433
464
|
== 2012-08-30 version 0.10.41
|
434
465
|
|
435
|
-
* Supports HTTP_PROXY
|
466
|
+
* Supports HTTP_PROXY environment variable to use a proxy server
|
436
467
|
|
437
468
|
|
438
469
|
== 2012-08-07 version 0.10.40
|
@@ -662,7 +693,7 @@ results on console
|
|
662
693
|
* Added new feature: status
|
663
694
|
* Refined usage message
|
664
695
|
* Fixed argument length check
|
665
|
-
* help subcommand shows
|
696
|
+
* help subcommand shows command-line examples
|
666
697
|
* table:tail subcommand reduced default max row number
|
667
698
|
* job:list subcommand supports --running and --error options
|
668
699
|
|
@@ -759,7 +790,7 @@ results on console
|
|
759
790
|
|
760
791
|
== 2011-09-08 version 0.9.0
|
761
792
|
|
762
|
-
* Changed subcommands
|
793
|
+
* Changed subcommands grammar: action-group -> group:action
|
763
794
|
* Fixed import subcommand to strip \n
|
764
795
|
|
765
796
|
|
data/README.rdoc
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
= Treasure Data command line tool
|
2
2
|
|
3
|
-
This CUI utility wraps the td-client-ruby
|
4
|
-
the REST API
|
3
|
+
This CUI utility wraps the {Ruby Client Library td-client-ruby}[https://github.com/treasure-data/td-client-ruby]
|
4
|
+
to interact with the REST API in managing databases and jobs on the Treasure Data Cloud.
|
5
5
|
|
6
|
-
For more about Treasure Data, see <http://treasure-data.com/>.
|
6
|
+
For more info about Treasure Data, see <http://treasure-data.com/>.
|
7
7
|
|
8
8
|
For full documentation see <http://docs.treasure-data.com/>.
|
9
9
|
|
@@ -57,6 +57,24 @@ Then run following commands on MinGW Shell:
|
|
57
57
|
$ bundle install # don't use "--path" option
|
58
58
|
$ rake exe:build # don't use "bundle exec"
|
59
59
|
|
60
|
+
== Bulk Import
|
61
|
+
|
62
|
+
Some of the +td+ commands prefixed with +td+ +import+ leverages the {Java Bulk Import CLI td-import-java}[https://github.com/treasure-data/td-import-java]
|
63
|
+
to process and Bulk load data in the Treasure Data Cloud.
|
64
|
+
|
65
|
+
The Bulk Import CLI is downloaded automatically at the first call to any of the command that require it; the use will
|
66
|
+
need internet connectivity in order to fetch the Bulk Import CLI JAR file from the
|
67
|
+
{Central Maven repository}[http://central.maven.org/maven2/com/treasuredata/td-import/]
|
68
|
+
and take advantage of these advanced features. If you need to setup a proxy, please consult this
|
69
|
+
{documentation}[http://docs.treasuredata.com/articles/faq#how-can-i-use-the-td-command-through-a-proxy] page.
|
70
|
+
|
71
|
+
The log levels and properties of the Bulk Import CLI can be configured in a +logging.properties+ file. A default
|
72
|
+
configuration is provided in a file within the gem or Toolbelt folder root, in the +java/+ folder. If you wish to
|
73
|
+
customize it, please make a copy of this file and store it in the:
|
74
|
+
|
75
|
+
~/.td/java folder on Mac OSX or Linux
|
76
|
+
%USERPROFILE%\.td\java folder on Windows
|
77
|
+
|
60
78
|
== Testing Hooks
|
61
79
|
|
62
80
|
The CLI implements several hooks to enable/disable/trigger special behaviors.
|
@@ -66,61 +84,65 @@ These hooks are expressed as environment variables and can therefore be provided
|
|
66
84
|
|
67
85
|
* Unix / Linux / MacOSX
|
68
86
|
* environment variable export in the shell the command is executed. The setting remains active until the shell is closed. E.g.:
|
69
|
-
|
87
|
+
|
70
88
|
$ export TD_TOOLBELT_DEBUG=1
|
71
|
-
|
89
|
+
|
72
90
|
* in the shell configuration file, to be active in any new shell that is opened. E.g.: add
|
73
|
-
|
91
|
+
|
74
92
|
export TD_TOOLBELT_DEBUG=1
|
75
|
-
|
93
|
+
|
76
94
|
to <tt>~/.bashrc</tt> or equivalent shell configuration file.
|
77
95
|
To make the setting active in the current shell, source the configuration file, e.g.:
|
78
|
-
|
96
|
+
|
79
97
|
$ source ~/.bashrc
|
80
|
-
|
98
|
+
|
81
99
|
* on the command line at runtime (active only for the duration of the command). E.g.:
|
82
|
-
|
100
|
+
|
83
101
|
$ TD_TOOLBELT_DEBUG=1 td ....
|
84
|
-
|
102
|
+
|
85
103
|
* as alias on in the current shell. The setting remains active until the shell is closed. E.g.:
|
86
|
-
|
104
|
+
|
87
105
|
$ alias td='TD_TOOLBELT_DEBUG=1 td'
|
88
|
-
|
106
|
+
|
89
107
|
* as alias in configuration file, to be active in any new shell that is opened. E.g.:
|
90
|
-
|
108
|
+
|
91
109
|
alias td='TD_TOOLBELT_DEBUG=1 td'`
|
92
|
-
|
110
|
+
|
93
111
|
to <tt>~/.bashrc</tt> or equivalent shell configuration file.
|
94
112
|
To make the setting active in the current shell, source the configuration file, e.g.:
|
95
|
-
|
113
|
+
|
96
114
|
$ source ~/.bashrc
|
97
|
-
|
115
|
+
|
98
116
|
* Windows
|
99
117
|
* in the command prompt the command is executed. The setting remains active until the command prompt window is closed. E.g.:
|
100
|
-
|
118
|
+
|
101
119
|
cmd> set TD_TOOLBELT_DEBUG=1
|
102
|
-
|
120
|
+
|
103
121
|
* as a global environment variable in the system settings. It will be active for all new command prompt windows.
|
104
122
|
|
105
123
|
These are the available hooks:
|
106
124
|
|
107
125
|
* Enable debugging mode:
|
108
|
-
|
126
|
+
|
109
127
|
$ TD_TOOLBELT_DEBUG=1
|
110
|
-
|
128
|
+
|
111
129
|
* JAR auto update (enabled by default is not specified). This setting does not affect <tt>import:jar_update</tt>:
|
112
130
|
* Enable:
|
113
|
-
|
131
|
+
|
114
132
|
$ TD_TOOLBELT_JAR_UPDATE=1
|
115
|
-
|
133
|
+
|
116
134
|
* Disable:
|
117
|
-
|
135
|
+
|
118
136
|
$ TD_TOOLBELT_JAR_UPDATE=0
|
119
|
-
|
120
|
-
* Specify an alternative endpoint to use
|
121
|
-
|
137
|
+
|
138
|
+
* Specify an alternative endpoint to use updating the toolbelt (default: http://toolbelt.treasuredata.com):
|
139
|
+
|
122
140
|
$ TD_TOOLBELT_UPDATE_ROOT="http://toolbelt.treasuredata.com"
|
123
|
-
|
141
|
+
|
142
|
+
* Specify an alternative endpoint to use updating the JAR file (default: http://central.maven.org):
|
143
|
+
|
144
|
+
$ TD_TOOLBELT_JARUPDATE_ROOT="http://central.maven.org"
|
145
|
+
|
124
146
|
|
125
147
|
= Copyright
|
126
148
|
|
data/dist/exe.rake
CHANGED
@@ -23,7 +23,7 @@ task 'exe:build' => :build do
|
|
23
23
|
install_resource 'exe/td-cmd.bat', 'td-cmd.bat', 0755
|
24
24
|
end
|
25
25
|
|
26
|
-
zip_files(project_root_path(
|
26
|
+
zip_files(project_root_path("pkg/td-update-exe-#{version}.zip"), 'td')
|
27
27
|
|
28
28
|
# create td.iss and run Inno Setup
|
29
29
|
install_erb_resource 'exe/td.iss', 'td.iss', 0644, variables
|
@@ -41,6 +41,6 @@ desc "clean Windows exe package"
|
|
41
41
|
task "exe:clean" do
|
42
42
|
FileUtils.rm_rf build_dir_path('exe')
|
43
43
|
FileUtils.rm_rf project_root_path("pkg/td-#{version}.exe")
|
44
|
-
FileUtils.rm_rf project_root_path("pkg/td-update-exe.zip")
|
44
|
+
FileUtils.rm_rf project_root_path("pkg/td-update-exe-#{version}.zip")
|
45
45
|
end
|
46
46
|
|
data/dist/pkg.rake
CHANGED
@@ -16,7 +16,7 @@ task 'pkg:build' => :build do
|
|
16
16
|
sh "pax -wz -x cpio . > ../bundle/td-client.pkg/Payload"
|
17
17
|
end
|
18
18
|
|
19
|
-
zip_files(project_root_path(
|
19
|
+
zip_files(project_root_path("pkg/td-update-pkg-#{version}.zip"), 'td-client.build')
|
20
20
|
|
21
21
|
# create ./bundle/td-client.pkg/Bom
|
22
22
|
sh "mkbom -s td-client.build bundle/td-client.pkg/Bom"
|
@@ -49,6 +49,6 @@ desc "clean Mac OS X pkg package"
|
|
49
49
|
task "pkg:clean" do
|
50
50
|
FileUtils.rm_rf build_dir_path('pkg')
|
51
51
|
FileUtils.rm_rf project_root_path("pkg/td-#{version}.pkg")
|
52
|
-
FileUtils.rm_rf project_root_path("pkg/td-update-pkg.zip")
|
52
|
+
FileUtils.rm_rf project_root_path("pkg/td-update-pkg-#{version}.zip")
|
53
53
|
end
|
54
54
|
|
@@ -28,11 +28,7 @@ module Command
|
|
28
28
|
name, db_name, table_name = op.cmd_parse
|
29
29
|
|
30
30
|
client = get_client
|
31
|
-
|
32
|
-
table = get_table(client, db_name, table_name)
|
33
|
-
|
34
|
-
opts = {}
|
35
|
-
client.create_bulk_import(name, db_name, table_name, opts)
|
31
|
+
client.create_bulk_import(name, db_name, table_name, {})
|
36
32
|
|
37
33
|
$stderr.puts "Bulk import session '#{name}' is created."
|
38
34
|
end
|
data/lib/td/command/common.rb
CHANGED
@@ -20,6 +20,9 @@ module Command
|
|
20
20
|
class UpdateError < ArgumentError
|
21
21
|
end
|
22
22
|
|
23
|
+
class ImportError < RuntimeError
|
24
|
+
end
|
25
|
+
|
23
26
|
private
|
24
27
|
def initialize
|
25
28
|
@render_indent = ''
|
@@ -108,9 +111,9 @@ module Command
|
|
108
111
|
|
109
112
|
def normalized_message
|
110
113
|
<<EOS
|
111
|
-
Your event has
|
114
|
+
Your event has numbers larger than 2^64.
|
112
115
|
These numbers are converted into string type.
|
113
|
-
|
116
|
+
You should consider using the cast operator in your query: e.g. cast(v['key'] as decimal).
|
114
117
|
EOS
|
115
118
|
end
|
116
119
|
|
@@ -125,8 +128,42 @@ EOS
|
|
125
128
|
$!.backtrace.each {|b|
|
126
129
|
$stderr.puts " #{b}"
|
127
130
|
}
|
128
|
-
|
131
|
+
$stderr.puts ""
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.humanize_bytesize(size, fractional_digits = 1)
|
136
|
+
labels = ["B", "kB", "MB", "GB", "TB"]
|
137
|
+
max_power = labels.length - 1
|
138
|
+
|
139
|
+
size = size.to_i
|
140
|
+
|
141
|
+
if size == 0
|
142
|
+
return "0 B"
|
143
|
+
end
|
144
|
+
|
145
|
+
# integer part
|
146
|
+
value = size
|
147
|
+
power = 0
|
148
|
+
while value > 0 do
|
149
|
+
value /= 1024
|
150
|
+
power += 1
|
129
151
|
end
|
152
|
+
power -= 1
|
153
|
+
power = power > max_power ? max_power : power # limit to TB display
|
154
|
+
integer = size / (1024 ** power)
|
155
|
+
out = integer.to_s
|
156
|
+
|
157
|
+
# fractional part - remove the integer part to avoid running into floating
|
158
|
+
# point precision problems
|
159
|
+
value = size % ((1024 ** power) * integer)
|
160
|
+
if value > 0 and fractional_digits > 0
|
161
|
+
fractional = value.to_f / (1024 ** power)
|
162
|
+
fractional *= 10 ** fractional_digits
|
163
|
+
out += sprintf ".%0*d", fractional_digits, fractional.to_i
|
164
|
+
end
|
165
|
+
out += " " + labels[power.to_i]
|
166
|
+
out
|
130
167
|
end
|
131
168
|
|
132
169
|
def self.humanize_time(time, is_ms = false)
|
@@ -237,6 +274,10 @@ EOS
|
|
237
274
|
raise ParameterConfigurationError,
|
238
275
|
"API server endpoint URL must use 'http' or 'https' protocol. Example format: 'https://api.treasuredata.com'"
|
239
276
|
end
|
277
|
+
unless uri.path =~ /^\/*$/
|
278
|
+
raise ParameterConfigurationError,
|
279
|
+
"API server path must be empty ('#{uri.path}' provided). Example format: 'https://api.treasuredata.com'"
|
280
|
+
end
|
240
281
|
|
241
282
|
if !(md = /(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})/.match(uri.host)).nil? # IP address
|
242
283
|
md[1..-1].each { |v|
|
@@ -245,15 +286,17 @@ EOS
|
|
245
286
|
"API server IP address must a 4 integers tuple, with every integer in the [0,255] range. Example format: 'https://1.2.3.4'"
|
246
287
|
end
|
247
288
|
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def self.test_api_endpoint(endpoint)
|
293
|
+
begin
|
294
|
+
# although the API may return 'Server is down' that is a good enough
|
295
|
+
# indication that we hit a valid TD endpoint to accept it
|
296
|
+
Client.server_status(:endpoint => endpoint)
|
297
|
+
rescue
|
298
|
+
raise ParameterConfigurationError,
|
299
|
+
"The specified API server endpoint (#{endpoint}) does not respond."
|
257
300
|
end
|
258
301
|
end
|
259
302
|
|
@@ -270,24 +313,39 @@ EOS
|
|
270
313
|
end
|
271
314
|
end
|
272
315
|
|
316
|
+
def self.find_files(glob, locations)
|
317
|
+
files = []
|
318
|
+
locations.each {|loc|
|
319
|
+
files = Dir.glob("#{loc}/#{glob}")
|
320
|
+
break unless files.empty?
|
321
|
+
}
|
322
|
+
files
|
323
|
+
end
|
324
|
+
|
273
325
|
class DownloadProgressIndicator
|
274
|
-
def initialize(msg
|
326
|
+
def initialize(msg)
|
275
327
|
@base_msg = msg
|
276
|
-
@start_time = start_time
|
277
|
-
@last_time = start_time
|
278
|
-
@periodicity = periodicity
|
279
|
-
|
280
328
|
print @base_msg + " " * 10
|
281
329
|
end
|
282
330
|
end
|
283
331
|
|
284
332
|
class TimeBasedDownloadProgressIndicator < DownloadProgressIndicator
|
333
|
+
def initialize(msg, start_time, periodicity = 2)
|
334
|
+
@start_time = start_time
|
335
|
+
@last_time = start_time
|
336
|
+
@periodicity = periodicity
|
337
|
+
super(msg)
|
338
|
+
end
|
339
|
+
|
285
340
|
def update
|
286
|
-
|
287
|
-
if (time = Time.now.to_i) - @last_time > @periodicity
|
341
|
+
if (time = Time.now.to_i) - @last_time >= @periodicity
|
288
342
|
msg = "\r#{@base_msg}: #{Command.humanize_elapsed_time(@start_time, time)} elapsed"
|
289
|
-
print
|
343
|
+
print "\r" + " " * (msg.length + 10)
|
344
|
+
print msg
|
290
345
|
@last_time = time
|
346
|
+
true
|
347
|
+
else
|
348
|
+
false
|
291
349
|
end
|
292
350
|
end
|
293
351
|
|
@@ -296,5 +354,43 @@ EOS
|
|
296
354
|
end
|
297
355
|
end
|
298
356
|
|
357
|
+
class SizeBasedDownloadProgressIndicator < DownloadProgressIndicator
|
358
|
+
def initialize(msg, size, perc_step = 1, min_periodicity = nil)
|
359
|
+
@size = size
|
360
|
+
|
361
|
+
# perc_step is how small a percentage increment can be shown
|
362
|
+
@perc_step = perc_step
|
363
|
+
|
364
|
+
# min_periodicity=X limits updates to one every X second
|
365
|
+
@start_time = Time.now.to_i
|
366
|
+
@min_periodicity = min_periodicity
|
367
|
+
|
368
|
+
# track progress
|
369
|
+
@last_perc_step = 0
|
370
|
+
@last_time = @start_time
|
371
|
+
|
372
|
+
super(msg)
|
373
|
+
end
|
374
|
+
|
375
|
+
def update(curr_size)
|
376
|
+
ratio = (curr_size.to_f * 100 / @size).round(1)
|
377
|
+
if ratio >= (@last_perc_step + @perc_step) &&
|
378
|
+
(!@min_periodicity || (time = Time.now.to_i) - @last_time >= @min_periodicity)
|
379
|
+
msg = "\r#{@base_msg}: #{Command.humanize_bytesize(curr_size)} / #{ratio}%"
|
380
|
+
print "\r" + " " * (msg.length + 10)
|
381
|
+
print msg
|
382
|
+
@last_perc_step = ratio
|
383
|
+
@last_time = time
|
384
|
+
true
|
385
|
+
else
|
386
|
+
false
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
def finish
|
391
|
+
print "\r#{@base_msg}...done" + " " * 20
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
299
395
|
end # module Command
|
300
396
|
end # module TrasureData
|
data/lib/td/command/help.rb
CHANGED
data/lib/td/command/import.rb
CHANGED
@@ -34,15 +34,15 @@ module Command
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def import_prepare(op)
|
37
|
-
import_by_java(
|
37
|
+
import_by_java(op)
|
38
38
|
end
|
39
39
|
|
40
40
|
def import_upload(op)
|
41
|
-
import_by_java(
|
41
|
+
import_by_java(op)
|
42
42
|
end
|
43
43
|
|
44
44
|
def import_auto(op)
|
45
|
-
import_by_java(
|
45
|
+
import_by_java(op)
|
46
46
|
end
|
47
47
|
|
48
48
|
def import_perform(op)
|
@@ -80,8 +80,17 @@ module Command
|
|
80
80
|
#
|
81
81
|
|
82
82
|
private
|
83
|
-
def import_by_java(
|
84
|
-
|
83
|
+
def import_by_java(op)
|
84
|
+
subcmd = op.name.split(/:/)[1]
|
85
|
+
begin
|
86
|
+
check_n_update_jar(true)
|
87
|
+
rescue UpdateError => e
|
88
|
+
if op.cmd_requires_connectivity
|
89
|
+
raise e
|
90
|
+
else
|
91
|
+
puts "Warning: JAR update skipped for connectivity issues"
|
92
|
+
end
|
93
|
+
end
|
85
94
|
|
86
95
|
# check java runtime exists or not
|
87
96
|
check_java
|
@@ -227,5 +236,41 @@ module Command
|
|
227
236
|
sysprops << "-Dhttp.proxyPort=#{proxy_port}" if proxy_port
|
228
237
|
end
|
229
238
|
|
239
|
+
#
|
240
|
+
# Helpers
|
241
|
+
#
|
242
|
+
|
243
|
+
# find logging.properties file, first in the jarfile_dest_path, then in the
|
244
|
+
# installed_path
|
245
|
+
def find_logging_property
|
246
|
+
installed_path = File.join(File.expand_path('../../..', File.dirname(__FILE__)), 'java')
|
247
|
+
config = Command.find_files("logging.properties", [Updater.jarfile_dest_path, installed_path])
|
248
|
+
if config.empty?
|
249
|
+
puts "Cannot find 'logging.properties' file in '#{Updater.jarfile_dest_path}' or " +
|
250
|
+
"'#{installed_path}'." unless ENV['TD_TOOLBELT_DEBUG'].nil?
|
251
|
+
[]
|
252
|
+
else
|
253
|
+
config.first
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
def find_td_import_jar
|
258
|
+
jar = Command.find_files('td-import.jar', [Updater.jarfile_dest_path])
|
259
|
+
if jar.empty?
|
260
|
+
$stderr.puts "Cannot find td-import.jar in '#{Updater.jarfile_dest_path}'."
|
261
|
+
exit 10
|
262
|
+
end
|
263
|
+
jar.first
|
264
|
+
end
|
265
|
+
|
266
|
+
def find_version_file
|
267
|
+
version = Command.find_files('VERSION', [Updater.jarfile_dest_path])
|
268
|
+
if version.empty?
|
269
|
+
$stderr.puts "Cannot find VERSION file in '#{Updater.jarfile_dest_path}'."
|
270
|
+
exit 10
|
271
|
+
end
|
272
|
+
version.first
|
273
|
+
end
|
274
|
+
|
230
275
|
end
|
231
276
|
end
|