envoi-mam-agent 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87aae76f05847dd0841872249db7841cd0ed1a48
4
+ data.tar.gz: 598e977aaebf41e231ac89f3cb8f67a2cafbde2f
5
+ SHA512:
6
+ metadata.gz: b8a75310a3a12544fadbc8f7aa3c7cec1c684c8d9666b604a4136f09d1b16c83507961517ebb02e376f33cc2f1ae8b7d768028d3f831f2c487ac14fe0971a39d
7
+ data.tar.gz: f869a550600737e3c9cb87fa88c041abf47d5f28e794755505d68b61603806bfa6df25aac8cb2ec2841fa79e677099eabba5b519ac9e18e45ea57e15a76e7885
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,3 @@
1
+ .gems
2
+ envoi-mam-agent
3
+ -global
@@ -0,0 +1 @@
1
+ 2.3.3
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ local_gemfile_name = 'Gemfile.local'
4
+ eval(IO.read(local_gemfile_name), binding) if File.exist? local_gemfile_name
5
+
6
+ # Specify your gem's dependencies in envoi-mam-agent.gemspec
7
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Envoi::Mam::Agent
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/envoi/mam/agent`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'envoi-mam-agent'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install envoi-mam-agent
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/XPlatform-Consulting/envoi-mam-agent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Envoi::Mam::Agent project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/envoi-mam-agent/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'envoi/mam/agent'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ begin
11
+ require 'pry'
12
+ Pry.start
13
+ rescue LoadError => e
14
+ require 'irb'
15
+ IRB.start(__FILE__)
16
+ end
17
+
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'envoi/mam/agent/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'envoi-mam-agent'
8
+ spec.version = Envoi::Mam::Agent::VERSION
9
+ spec.authors = ['John Whitson']
10
+ spec.email = ['john.whitson@gmail.com']
11
+
12
+ spec.summary = 'Library for interacting with MAMs.'
13
+ spec.description = ''
14
+ spec.homepage = 'http://www.github.com/XPlatform-Consulting/envoi-mam-agent'
15
+ spec.license = 'MIT'
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency 'adobe_media_encoder', '~> 0.0.1'
26
+ spec.add_runtime_dependency 'aws-sdk-s3', '~> 1'
27
+ spec.add_runtime_dependency 'daemons', '~> 0'
28
+ spec.add_runtime_dependency 'faraday', '~> 0.15'
29
+ spec.add_runtime_dependency 'ubiquity-envoi', '~> 1'
30
+ spec.add_runtime_dependency 'ubiquity-iconik', '~> 1'
31
+ spec.add_runtime_dependency 'ubiquity-mediasilo-api-v3', '~> 1'
32
+ spec.add_runtime_dependency 'ubiquity-vdms', '~> 1'
33
+ spec.add_runtime_dependency 'ubiquity-wiredrive', '~> 1'
34
+ # spec.add_runtime_dependency 'vantage', '~> 1'
35
+ spec.add_runtime_dependency 'vidispine', '~> 1'
36
+
37
+
38
+ spec.add_development_dependency 'bundler', '~> 1.16'
39
+ spec.add_development_dependency 'minitest', '~> 5.0'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # require 'envoi/mam/agent/cli'
3
+ should_retry = true
4
+ begin
5
+ require 'envoi/mam/agent/cli/commands'
6
+ rescue LoadError => e
7
+ lib_path = __FILE__ == '(irb)' ? File.join(Dir.cwd, 'lib') : File.expand_path('../../lib', __FILE__)
8
+ $:.unshift(lib_path) unless $:.include?(lib_path) or !File.exist?(lib_path)
9
+ if should_retry
10
+ should_retry = false
11
+ retry
12
+ end
13
+ end
14
+
15
+
@@ -0,0 +1,119 @@
1
+ require 'logger'
2
+ require 'open3'
3
+
4
+ require 'envoi/mam/agent/version'
5
+ require 'envoi/mam/agent/config_service_client'
6
+
7
+ module Envoi
8
+ module Mam
9
+ class Agent
10
+
11
+ attr_accessor :logger, :initial_args, :config, :api_client
12
+
13
+ def initialize(args = { })
14
+ @initial_args = args.clone
15
+ @config = args[:config]
16
+ @notifiers = args[:notifiers] || [ ]
17
+
18
+ @dry_run = args.fetch(:dry_run, false)
19
+
20
+ initialize_logger(args)
21
+ initialize_api_client(args) # if self.respond_to?(:initialize_api_client)
22
+ after_initialize
23
+ end
24
+
25
+ def after_initialize
26
+
27
+ end
28
+
29
+ def initialize_logger(args = { })
30
+ @logger = args[:logger] || Logger.new(STDOUT)
31
+ end
32
+
33
+ def dry_run?; @dry_run end
34
+
35
+ def notify(message, args = { })
36
+ return if @notifiers.empty?
37
+ args[:level] ||= :info
38
+ args[:message] ||= message
39
+ @notifiers.each { |notifier| notifier.notify(args) }
40
+ end
41
+
42
+ # @param [Hash] args {}
43
+ # @option args [Object] :api_client
44
+ # Will usually be overridden by child class
45
+ def initialize_api_client(args = { })
46
+ @api_client = args[:api_client] || begin
47
+
48
+ end
49
+ end
50
+
51
+ def shell_execute(command, dry_run = @dry_run)
52
+ if dry_run
53
+ logger.debug { "Skipping Execution of Command: '#{command}' " }
54
+ return
55
+ end
56
+ logger.debug { "Executing Command: '#{command}'" }
57
+
58
+ Open3.popen3(command) do |stdin, stdout, stderr, thread|
59
+ # stdin.sync = true
60
+ # stdout.sync = true
61
+ # stderr.sync = true
62
+
63
+ output = ''
64
+ until thread.stop?
65
+ output << stdout.read #rescue nil
66
+ output << stderr.read # rescue nil
67
+ unless output.empty?
68
+ print output
69
+ output.clear
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ def self.load_from_config_file(args)
76
+ config_file_path = args[:config_file_path]
77
+ config_file_path = config_file_path.find { |v| File.exists?(v) } if config_file_path.is_a?(Array)
78
+ abort("Missing Config File. '#{config_file_path}'") unless config_file_path && !config_file_path.empty? && File.exists?(config_file_path)
79
+
80
+ begin
81
+ config = JSON.parse(File.read(config_file_path))
82
+ rescue => e
83
+ abort("Config File Failed to Load. '#{$!}'")
84
+ end
85
+ args[:config] = config
86
+
87
+ self.new(args.merge({ :config => config }))
88
+ end
89
+
90
+ def self.load_from_config_service(args)
91
+ args_out = { }
92
+ args_out[:app_id] = args[:config_service_app_id]
93
+ args_out[:token] = args[:config_service_app_token]
94
+ args_out[:api_url] = args[:config_service_app_url]
95
+ config = Envoi::Mam::Agent::ConfigServiceClient.config_get(args_out)
96
+ args[:config] = config
97
+
98
+ self.new(args.merge({ :config => config }))
99
+ end
100
+
101
+ def self.load_config_and_init(args)
102
+ if args[:config_service_app_id] && args[:config_service_app_token]
103
+ load_from_config_service(args)
104
+ else args[:config_file_path]
105
+ load_from_config_file(args)
106
+ end
107
+ end
108
+
109
+
110
+ def run_operation
111
+ case initial_args[:operation]
112
+ when :upload; upload(initial_args) if self.respond_to?(:upload)
113
+ when :download; download(initial_args) if self.respond_to?(:download)
114
+ end
115
+ end
116
+
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,37 @@
1
+ require 'optparse'
2
+
3
+ require 'envoi/mam/agent'
4
+
5
+ module Envoi
6
+ module Mam
7
+ class Agent
8
+
9
+ class Cli
10
+
11
+ CONFIG_FILE_PATHS = [
12
+ "./envoi-mam-agent-config.json",
13
+ "~/envoi-mam-agent-config.json",
14
+ ]
15
+ CONFIG_FILE_PATHS.map! { |v| File.expand_path(v) }
16
+
17
+ attr_accessor :logger, :initial_args
18
+
19
+ def initialize(*args)
20
+ @initial_args = args
21
+ end
22
+
23
+ def parse_arguments
24
+
25
+ end
26
+
27
+
28
+ end
29
+
30
+ # Agent
31
+ end
32
+
33
+ # Mam
34
+ end
35
+
36
+ # Envoi
37
+ end
@@ -0,0 +1,89 @@
1
+ #Command Loader
2
+ #
3
+
4
+ # module Envoi
5
+ # module Mam
6
+ # class Agent
7
+ # class CLI
8
+ # class Commands
9
+ #
10
+ #
11
+ # # Commands
12
+ # end
13
+ #
14
+ # # CLI
15
+ # end
16
+ #
17
+ # # Agent
18
+ # end
19
+ #
20
+ # # Mam
21
+ # end
22
+ #
23
+ # # Envoi
24
+ # end
25
+
26
+ def usage
27
+ command_list_str = ''
28
+ Dir.glob(File.join(@commands_dir, "*#{@command_ext}")).each do |fn|
29
+ command_list_str += "\n\t - #{File.basename(fn, @command_ext)}"
30
+ end
31
+
32
+ <<-EOT
33
+ Usage: #{File.basename($0)} COMMAND [ARGS]
34
+
35
+ Available Commands:
36
+ #{command_list_str}
37
+
38
+ All commands can be run with -h (or --help) for more information.
39
+ EOT
40
+ end
41
+
42
+ @commands_dir = File.join(File.dirname(__FILE__), 'commands')
43
+ @command_ext = '.rb'
44
+
45
+ command_aliases = {
46
+ }
47
+
48
+ if ARGV.empty?
49
+ should_show_usage = true
50
+ else
51
+ command_name = ARGV[0].clone
52
+ command_name = command_aliases[command_name] || command_name
53
+ should_show_usage = %w(-h --help).include?(command_name.downcase)
54
+ end
55
+ if should_show_usage
56
+ puts usage
57
+ exit(true)
58
+ end
59
+
60
+ command_file_path = File.join(@commands_dir, command_name)
61
+ abort(usage) unless File.exist?("#{command_file_path}#{@command_ext}")
62
+
63
+ require 'envoi/mam/agent/cli'
64
+
65
+ begin
66
+ require "#{command_file_path}#{@command_ext}"
67
+ rescue LoadError => e
68
+ abort(e.message)
69
+ end
70
+
71
+
72
+ # Execute the command if it is in object form, otherwise it's just a script and executed when we required it
73
+ if Envoi::Mam::Agent::Cli.const_defined?('Commands')
74
+ command_class_name = command_name.to_s.capitalize
75
+ if Envoi::Mam::Agent::Cli::Commands.const_defined?(command_class_name)
76
+ command_object = Envoi::Mam::Agent::Cli::Commands.const_get( command_class_name.capitalize ) rescue nil
77
+ end
78
+ command_object ||= begin
79
+ command_class_name = command_class_name.upcase
80
+ Envoi::Mam::Agent::Cli::Commands.const_defined?(command_class_name) ? Envoi::Mam::Agent::Cli::Commands.const_get( command_class_name ) : false
81
+ end
82
+ if command_object
83
+ command_instance = command_object.new if command_object.respond_to?(:new)
84
+ command_instance.execute if command_instance.respond_to?(:execute)
85
+ end
86
+ end
87
+
88
+
89
+