s3_download_by_date 0.1.2 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/bin/s3download +13 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTA1ZWNkY2JlNzk2Y2Y2MzBmYjIzMDFhMmFkODQ4MjM3Zjc1NDRkOA==
4
+ N2MzMDM4N2Y5NGJhZjEwY2U4MWRiZmRmNWI1NDljNjkyNzdiN2Y2Yg==
5
5
  data.tar.gz: !binary |-
6
- MjAyOGVkNDhiMmE2MzYzN2MzOTMyMzc3MDJmNjM0ODgxNDBjMzJkZg==
6
+ MjgwOThiMGQ1MmEzNjJkZGE5ZDRlMDY0YzNjNzY0ZTQ4MWEyZDg1NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWZkZTJhMDRiMDlmNDVjM2EwOTBmN2VjMTAzYjI0NjQxYWRkMWQ1ZGZiYjU4
10
- MDhhZGY1NTBiNjFlNzQ5MjA3OTZiNDEyMTYzZTM5YmIyMDA2NTFiODA0ODJi
11
- OWM0OTNmYWJiYWQ1NWQ4NTk4NDFmMjdiN2IzZWQ1NThmYmI5N2E=
9
+ NzFjODU0ZGUzYWFmZTNkZTNjZGQxMzJkOWZmMmY5N2EyZTQ2NDcxNDY3ZGI4
10
+ NzkzZTE1N2QzYWUyNmFjMTkzMjRhYTFkZjhkYmI1NmM5NDBkNjM2N2FhYThl
11
+ YzFmMTgyYWQxMjlmMjdiMTZkYTE3MTI4ZDg1MThkMTU3M2YxMjc=
12
12
  data.tar.gz: !binary |-
13
- MTkzMGMxYTIxZGJhOTRjMzFlZDhkOTI2YjE3OTdiNjRjMzUyNjAxNDEwYTVl
14
- YjBkYTgxOTFjNzgwODg1ODg2ZjQ3MWYxZTU4YzFmZGNmNWM0MjBlMWM4ZGE1
15
- MTk0MThjYzI3MzY2ODkzNTcyNDNkZjBmZDc0MTlhZjE5MzFmMTE=
13
+ ZGQ4NTE2Nzg0NjUwNzE0ZWYzMTljY2FjNmNmYWU4ZDllMDcwOTE3Mzc2OGQ2
14
+ MjJiY2E5MDQ1NTc1OGUzZjA1N2M5NDg1YmEyYTU2NzMyNWVjNzRmMzUyZjJj
15
+ NGYwYjNjMTQ1YTI0YmNhZDNjNDQ1MzZkMDZhYzk5NDU2MjEwN2Y=
data/bin/s3download CHANGED
@@ -29,7 +29,7 @@ class S3Downloader < Thor
29
29
  Download S3 files by range (date)
30
30
 
31
31
  Usage:
32
- s3download range --bucket=S3 Bucket Name --prefix=folder inside the specified bucket --save-to=Location of downloaded files
32
+ s3download range --timezone='Eastern Time (US & Canada)' --bucket=S3 Bucket Name --prefix=folder inside the specified bucket --save-to=Location of downloaded files
33
33
 
34
34
  Options:
35
35
  --bucket=S3 Bucket Name # S3 Bucket Name
@@ -38,10 +38,10 @@ Options:
38
38
  # Default: 2014-08-04 00:00:00 +0300
39
39
  [--to=To in a natural language date/time like yesterday, last week, etc...]
40
40
  # Default: 2014-08-04 23:59:59 +0300
41
+ --timezone filter files by date [defaults to UTC] ex: "Eastern Time (US & Canada)
41
42
  --save-to=Location of downloaded files # The target directory where download files be stored
42
- --debug, [--no-debug]
43
43
 
44
- Utility:
44
+ Utility (Get a list of timezones strings):
45
45
  s3download list_timezones
46
46
  {
47
47
  "International Date Line West": "Pacific/Midway",
@@ -80,16 +80,24 @@ Utility:
80
80
  say("Range: #{range}", color=:green) if options[:debug]
81
81
 
82
82
  ProgressBar.new("Filter Files", bucket.count) do |pbar|
83
+ FileUtils.mkdir_p "#{target}"
84
+ File.open("#{target}/download_info.txt", "w") {|f| f.write("#{Time.now} - Downloaded bucket #{options[:bucket]}/#{options[:prefix]} from: #{from} - to #{to}")}
85
+
83
86
  bucket.each do |object|
87
+ # puts "timezone: #{timezone}" if options[:debug]
88
+ # puts "object last modified: #{object.last_modified}" if options[:debug]
89
+ # puts "object last modified in timezone: #{object.last_modified.in_time_zone(timezone)}" if options[:debug]
90
+ # puts "object falls in range: #{range}? => #{range.cover?(object.last_modified.in_time_zone(timezone))}"
84
91
  if range.cover?(object.last_modified.in_time_zone(timezone))
85
92
  say("Downloading #{object.key} #{object.last_modified.in_time_zone(timezone)}\n", color=:white) if options[:debug]
86
- FileUtils.mkdir_p "#{target}/#{range}/#{object.key.match(/(.+)\//)[1]}"
93
+ FileUtils.mkdir_p "#{target}/#{object.key.match(/(.+)\//)[1]}"
87
94
 
88
95
  begin
89
- File.open("#{target}/#{range.gsub('/', ':')}/#{object.key}", "w") do |f|
96
+ File.open("#{target}/#{object.key}", "w") do |f|
90
97
  f.write(object.read)
91
98
  end
92
99
  rescue Exception => e
100
+ puts "Unable to save file: #{e}"
93
101
  end
94
102
  end
95
103
  pbar.inc
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_download_by_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ami Mahloof
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor