Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Making it a bit more unix friendly #8

Closed
wants to merge 5 commits into from

1 participant

@dskim

Hi Ryan,

Would be nice to have it return an exit code as well as redirecting error massages to stderr.
It'd play more nicely as a cron job.

What do you think?

@dskim dskim closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2012
  1. @dskim
  2. @dskim
Commits on Aug 28, 2012
  1. @dskim

    bump version to 0.0.2

    dskim authored
Commits on Aug 30, 2012
  1. @dskim

    We need to predefine the dynamic exception classes if we want to resc…

    dskim authored
    …ue them properly, otherwise we would get an undefined class exception when any other exception is raised.
  2. @dskim

    bump version to 0.0.3

    dskim authored
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 6 deletions.
  1. +6 −0 lib/aws-s3-exceptions.rb
  2. +11 −6 lib/sir-sync-a-lot.rb
View
6 lib/aws-s3-exceptions.rb
@@ -0,0 +1,6 @@
+module AWS
+ module S3
+ class InvalidAccessKeyId < ResponseError; end
+ class NoSuchBucket < ResponseError; end
+ end
+end
View
17 lib/sir-sync-a-lot.rb
@@ -1,5 +1,6 @@
require 'aws/s3'
require 'yaml'
+require_relative 'aws-s3-exceptions'
class SirSyncalot
def self.run!(*args)
@@ -17,7 +18,7 @@ def run!
perform_action!
end
- VERSION = '0.0.1'
+ VERSION = '0.0.3'
private
@@ -244,7 +245,7 @@ def push_file(file)
display("Pushing #{file[:path]}...")
AWS::S3::S3Object.store(file[:path], open(file[:path]), read_config[:aws_dest_bucket])
rescue
- display("ERROR: Could not push '#{file[:path]}': #{$!.inspect}")
+ log_error("ERROR: Could not push '#{file[:path]}': #{$!.inspect}")
end
def aquire_lock!
@@ -267,12 +268,16 @@ def display_help!
end
def exit_with_error!(message)
- display("Gah! " + message)
- exit
+ log_error("Gah! " + message)
+ exit 1
end
- def display(message)
- puts("[#{Time.now}] #{message}")
+ def display(message, target=$stdout)
+ target.puts("[#{Time.now}] #{message}")
+ end
+
+ def log_error(message)
+ display(message, $stderr)
end
def ask(question)
Something went wrong with that request. Please try again.