s3cp 1.1.39 → 1.1.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/bin/s3open +4 -0
- data/bin/s3open~ +4 -0
- data/lib/s3cp/s3cat.rb~ +144 -0
- data/lib/s3cp/utils.rb +1 -1
- data/lib/s3cp/version.rb +1 -1
- data/lib/s3cp/version.rb~ +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0290c1eaaabbc90626e8a996868953051a421e66
|
4
|
+
data.tar.gz: c122054dbd6b8dcaa3ae610027c84667d57c06b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe1d294a160d801372d7fa81590a037627033aaa2264644436598c258dd030e7abab6f2beca427e44f6588fa6288353a75b02071220e83af8aa3ac88951838b4
|
7
|
+
data.tar.gz: 4b98037c37e4d3a4e6fb4357204d20918cea037aac329c8dbcb3057c270c3618a17b94397e5d8f34589bf12e0f51a55f75b58c8a1b95b782f342f94b0d365ffb
|
data/History.txt
CHANGED
data/bin/s3open
ADDED
data/bin/s3open~
ADDED
data/lib/s3cp/s3cat.rb~
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# Copyright (C) 2010-2012 Alex Boisvert and Bizo Inc. / All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with this work for
|
5
|
+
# additional information regarding copyright ownership. The ASF licenses this
|
6
|
+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
7
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
8
|
+
# the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations under
|
16
|
+
# the License.
|
17
|
+
|
18
|
+
require 's3cp/utils'
|
19
|
+
require 'progressbar'
|
20
|
+
require 'tempfile'
|
21
|
+
|
22
|
+
# Parse arguments
|
23
|
+
options = {}
|
24
|
+
options[:tty] = $stdout.isatty
|
25
|
+
|
26
|
+
op = OptionParser.new do |opts|
|
27
|
+
opts.banner = "s3cat [path]"
|
28
|
+
opts.separator ''
|
29
|
+
|
30
|
+
opts.on("--debug", "Debug mode") do
|
31
|
+
options[:debug] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("--tty", "TTY mode") do |tty|
|
35
|
+
options[:tty] = tty
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on("--edit", "Edit mode") do |edit|
|
39
|
+
options[:edit] = edit
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("--head SIZE", "Download only 'head' part of the file, e.g. 4KB, 1024B, 2GB") do |size|
|
43
|
+
options[:head] = S3CP.size_in_bytes(size)
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("--tail SIZE", "Download only 'tail' part of the file, e.g. 4KB, 1024B, 2GB") do |size|
|
47
|
+
options[:tail] = S3CP.size_in_bytes(size)
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on("--range START-END", "Download only range (in absolute positions) portion, e.g. 1GB-2GB, 16K-128k, 128k-, -128k") do |range|
|
51
|
+
range_start, range_end = range.split("-")
|
52
|
+
options[:range_start] = S3CP.size_in_bytes(range_start) if range_start && (!range_start.empty?)
|
53
|
+
options[:range_end] = S3CP.size_in_bytes(range_end) - 1 if range_end && (!range_end.empty?)
|
54
|
+
range_start, range_end = range.split("-")
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
58
|
+
puts op
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
end
|
62
|
+
op.parse!(ARGV)
|
63
|
+
|
64
|
+
unless ARGV.size > 0
|
65
|
+
puts op
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
|
69
|
+
url = ARGV[0]
|
70
|
+
|
71
|
+
if options[:debug]
|
72
|
+
puts "URL: #{url}"
|
73
|
+
puts "Options: \n#{options.inspect}"
|
74
|
+
end
|
75
|
+
|
76
|
+
S3CP.standard_exception_handling(options) do
|
77
|
+
@bucket, @prefix = S3CP.bucket_and_key(url)
|
78
|
+
fail "Your URL looks funny, doesn't it?" unless @bucket
|
79
|
+
|
80
|
+
S3CP.load_config()
|
81
|
+
|
82
|
+
read_options = {}
|
83
|
+
read_options[:debug] = options[:debug]
|
84
|
+
read_options[:head] = options[:head] if options[:head]
|
85
|
+
read_options[:tail] = options[:tail] if options[:tail]
|
86
|
+
read_options[:range_start] = options[:range_start] if options[:range_start]
|
87
|
+
read_options[:range_end] = options[:range_end] if options[:range_end]
|
88
|
+
|
89
|
+
@s3 = S3CP.connect().buckets[@bucket]
|
90
|
+
|
91
|
+
|
92
|
+
if options[:edit] && (options[:head] || options[:tail] || options[:range_start] || options[:range_end])
|
93
|
+
fail "--edit option is not intended to be used with --head, --tail nor --range"
|
94
|
+
end
|
95
|
+
|
96
|
+
if options[:tty] || options[:edit]
|
97
|
+
# store contents to file to display with PAGER
|
98
|
+
size = @s3.objects[@prefix].content_length
|
99
|
+
|
100
|
+
progress_bar = ProgressBar.new(File.basename(@prefix), size).tap do |p|
|
101
|
+
p.file_transfer_mode
|
102
|
+
end
|
103
|
+
|
104
|
+
file = Tempfile.new(File.basename(@prefix) + '_')
|
105
|
+
out = File.new(file.path, "wb")
|
106
|
+
begin
|
107
|
+
@s3.objects[@prefix].read_as_stream(read_options) do |chunk|
|
108
|
+
out.write(chunk)
|
109
|
+
progress_bar.inc chunk.size
|
110
|
+
end
|
111
|
+
progress_bar.finish
|
112
|
+
ensure
|
113
|
+
out.close()
|
114
|
+
end
|
115
|
+
if options[:edit]
|
116
|
+
before_md5 = S3CP.md5(file.path)
|
117
|
+
system "#{ENV['EDITOR'] || 'vi'} #{file.path}"
|
118
|
+
if ($? == 0)
|
119
|
+
if (S3CP.md5(file.path) != before_md5)
|
120
|
+
ARGV.clear
|
121
|
+
ARGV << file.path
|
122
|
+
ARGV << url
|
123
|
+
load "s3cp/s3cp.rb"
|
124
|
+
else
|
125
|
+
puts "File unchanged."
|
126
|
+
end
|
127
|
+
else
|
128
|
+
puts "Edit aborted (result code #{$?})."
|
129
|
+
end
|
130
|
+
else
|
131
|
+
system "#{ENV['PAGER'] || 'less'} #{file.path}"
|
132
|
+
end
|
133
|
+
file.delete()
|
134
|
+
else
|
135
|
+
@s3.objects[@prefix].read_as_stream(read_options) do |chunk|
|
136
|
+
begin
|
137
|
+
$stdout.print(chunk)
|
138
|
+
rescue Errno::EPIPE
|
139
|
+
break
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
data/lib/s3cp/utils.rb
CHANGED
data/lib/s3cp/version.rb
CHANGED
data/lib/s3cp/version.rb~
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3cp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Boisvert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: extensions
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/s3cp/completion.rb
|
138
138
|
- lib/s3cp/s3buckets.rb
|
139
139
|
- lib/s3cp/s3cat.rb
|
140
|
+
- lib/s3cp/s3cat.rb~
|
140
141
|
- lib/s3cp/s3cp.rb
|
141
142
|
- lib/s3cp/s3du.rb
|
142
143
|
- lib/s3cp/s3lifecycle.rb
|
@@ -164,6 +165,8 @@ files:
|
|
164
165
|
- bin/s3ls
|
165
166
|
- bin/s3mod
|
166
167
|
- bin/s3mv
|
168
|
+
- bin/s3open
|
169
|
+
- bin/s3open~
|
167
170
|
- bin/s3rm
|
168
171
|
- bin/s3stat
|
169
172
|
- bin/s3tree
|