jeeves-pvr 0.2.0

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGFhNzgzNDg1Y2ZhMDFmMjhhMGNiMTkzNzNkY2I0NTFhZGJhMDc5Nw==
5
+ data.tar.gz: !binary |-
6
+ YWFlMTgxMmYyYTgwYTU0MzMyNzIzMGViMTY5MmJjMjgwYzljNDRjZg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NGMyOTAyNGQ2YzBlOTk5ZTk5NjI1MjE1NjgxYjFjYWJkNjk3NGZkN2EyMzdh
10
+ ODBhYjkwY2FlMWI3NjFhYTJhMWJmNjQxZTBmNDExZDc2NmMxMWNhZjk3Njg1
11
+ MDFiYWM5ODdhYTdjYjY4ZjJjNDc4ZmVmYmJmMTk1MjQwZWJiYzQ=
12
+ data.tar.gz: !binary |-
13
+ MzAzYjliMDNiNGYzYjQ1ZTFlZTY2NjM0OTgyMzZiZWUzMzk2YzcxMGI5Yjg1
14
+ OGU3Yzg1MjVmOWY1MjRhN2VlNWQyODE0NzIwMGZjZTQwMjVjZWM3NWUzZjY4
15
+ ZjlkNjk3NzNmOGVkYmY4ODJhYjI0MzgwZjk1ZTQyMGI2ZWMzNGU=
@@ -0,0 +1,6 @@
1
+ == Bugs and Change Requests for Jeeves
2
+
3
+ [14-Feb-2014] Features and Changes Required
4
+ Use optplus for cli interface
5
+ Extend timeout when updating listings
6
+ *BUG* Make multiple disks work for allocating files!
@@ -0,0 +1,49 @@
1
+ == History
2
+
3
+ [jeeves-0.2.0 25-Mar-2014]
4
+
5
+ Update to optplus version of the command line, with a tidy up
6
+
7
+ [jeeves-0.1.6 22-Aug-2013]
8
+
9
+ Update to make it ruby 1.9/2.0 ready
10
+
11
+ [jeeves-0.1.5 19-Aug-2013]
12
+
13
+ Add a show command for videos to display tag info.
14
+
15
+ [jeeves-0.1.4 15-Aug-2013]
16
+
17
+ Removed extra dependencies from Gemfile
18
+
19
+ [jeeves-0.1.3 15-Aug-2013]
20
+
21
+ Added wrapper script to fix gem load issues
22
+
23
+ [jeeves-0.1.2 15-Aug-2013]
24
+
25
+ Change bin/jeeves to remove LOAD_PATH!
26
+
27
+ [jeeves-0.1.1 15-Aug-2013]
28
+
29
+ Correct copy error in jeni install script
30
+
31
+ [jeeves-0.1.0 15-Aug-2013]
32
+
33
+ New integrated jeeves first release (testing only)
34
+
35
+ [jeeves-0.0.3 15-Dec-2012]
36
+
37
+ Remove reference to install command
38
+
39
+ [jeeves-0.0.2 16-Oct-2012]
40
+
41
+ Update wrangle to create a proxy and delete it after loading
42
+
43
+ [jeeves-0.0.1 06-Sep-2012]
44
+
45
+ Basic gem that provides the jeeves command and pulls in all the other jeeves gems
46
+
47
+ [jeeves-0.0.0 24-Sep-2011]
48
+
49
+ Application generated.
@@ -0,0 +1,159 @@
1
+ Copyright (c) 2011 Robert Sharp
2
+
3
+ This software is licensed for use under the Open Software Licence v. 3.0
4
+ The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
5
+ and below. Under the terms of this licence, all derivative works
6
+ must themselves be licensed under the Open Software Licence v. 3.0
7
+
8
+ Open Source Initiative OSI - The Open Software Licence 3.0:Licensing
9
+ [OSI Approved Licence]
10
+ Open Software Licence ("OSL") v. 3.0
11
+
12
+ This Open Software Licence (the "Licence") applies to any original work of authorship
13
+ (the "Original Work") whose owner (the "Licensor") has placed the following licensing
14
+ notice adjacent to the copyright notice for the Original Work:
15
+
16
+ Licensed under the Open Software Licence version 3.0
17
+
18
+ 1) Grant of Copyright Licence. Licensor grants You a worldwide, royalty-free, non-exclusive,
19
+ sublicensable license, for the duration of the copyright, to do the following:
20
+
21
+ a) to reproduce the Original Work in copies, either alone or as part of a collective work;
22
+
23
+ b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby
24
+ creating derivative works ("Derivative Works") based upon the Original Work;
25
+
26
+ c) to distribute or communicate copies of the Original Work and Derivative Works to
27
+ the public, with the proviso that copies of Original Work or Derivative Works that
28
+ You distribute or communicate shall be licensed under this Open Software Licence;
29
+
30
+ d) to perform the Original Work publicly; and
31
+
32
+ e) to display the Original Work publicly.
33
+
34
+ 2) Grant of Patent Licence. Licensor grants You a worldwide, royalty-free, non-exclusive,
35
+ sublicensable license, under patent claims owned or controlled by the Licensor that are
36
+ embodied in the Original Work as furnished by the Licensor, for the duration of the
37
+ patents, to make, use, sell, offer for sale, have made, and import the Original Work
38
+ and Derivative Works.
39
+
40
+ 3) Grant of Source Code Licence. The term "Source Code" means the preferred form of
41
+ the Original Work for making modifications to it and all available documentation
42
+ describing how to modify the Original Work. Licensor agrees to provide a machine-readable
43
+ copy of the Source Code of the Original Work along with each copy of the Original Work
44
+ that Licensor distributes. Licensor reserves the right to satisfy this obligation by
45
+ placing a machine-readable copy of the Source Code in an information repository reasonably
46
+ calculated to permit inexpensive and convenient access by You for as long as Licensor
47
+ continues to distribute the Original Work.
48
+
49
+ 4) Exclusions From Licence Grant. Neither the names of Licensor, nor the names of
50
+ any contributors to the Original Work, nor any of their trademarks or service marks,
51
+ may be used to endorse or promote products derived from this Original Work without
52
+ express prior permission of the Licensor. Except as expressly stated herein, nothing
53
+ in this Licence grants any license to Licensor's trademarks, copyrights, patents,
54
+ trade secrets or any other intellectual property. No patent license is granted to
55
+ make, use, sell, offer for sale, have made, or import embodiments of any patent claims
56
+ other than the licensed claims defined in Section 2. No license is granted to the
57
+ trademarks of Licensor even if such marks are included in the Original Work. Nothing
58
+ in this Licence shall be interpreted to prohibit Licensor from licensing under terms
59
+ different from this Licence any Original Work that Licensor otherwise would have a
60
+ right to license.
61
+
62
+ 5) External Deployment. The term "External Deployment" means the use, distribution,
63
+ or communication of the Original Work or Derivative Works in any way such that the
64
+ Original Work or Derivative Works may be used by anyone other than You, whether those
65
+ works are distributed or communicated to those persons or made available as an application
66
+ intended for use over a network. As an express condition for the grants of license hereunder,
67
+ You must treat any External Deployment by You of the Original Work or a Derivative Work
68
+ as a distribution under section 1(c).
69
+
70
+ 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works
71
+ that You create, all copyright, patent, or trademark notices from the Source Code of
72
+ the Original Work, as well as any notices of licensing and any descriptive text identified
73
+ therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works
74
+ that You create to carry a prominent Attribution Notice reasonably calculated to inform
75
+ recipients that You have modified the Original Work.
76
+
77
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright
78
+ in and to the Original Work and the patent rights granted herein by Licensor are owned by
79
+ the Licensor or are sublicensed to You under the terms of this Licence with the permission
80
+ of the contributor(s) of those copyrights and patent rights. Except as expressly stated in
81
+ the immediately preceding sentence, the Original Work is provided under this Licence on an
82
+ "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation,
83
+ the warranties of non-infringement, merchantability or fitness for a particular purpose.
84
+ THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY
85
+ constitutes an essential part of this Licence. No license to the Original Work is granted
86
+ by this Licence except under this disclaimer.
87
+
88
+ 8) Limitation of Liability. Under no circumstances and under no legal theory, whether
89
+ in tort (including negligence), contract, or otherwise, shall the Licensor be liable
90
+ to anyone for any indirect, special, incidental, or consequential damages of any character
91
+ arising as a result of this Licence or the use of the Original Work including, without
92
+ limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction,
93
+ or any and all other commercial damages or losses. This limitation of liability shall not
94
+ apply to the extent applicable law prohibits such limitation.
95
+
96
+ 9) Acceptance and Termination. If, at any time, You expressly assented to this Licence,
97
+ that assent indicates your clear and irrevocable acceptance of this Licence and all of its
98
+ terms and conditions. If You distribute or communicate copies of the Original Work or a
99
+ Derivative Work, You must make a reasonable effort under the circumstances to obtain the
100
+ express assent of recipients to the terms of this Licence. This Licence conditions your
101
+ rights to undertake the activities listed in Section 1, including your right to create
102
+ Derivative Works based upon the Original Work, and doing so without honoring these
103
+ terms and conditions is prohibited by copyright law and international treaty. Nothing
104
+ in this Licence is intended to affect copyright exceptions and limitations (including
105
+ "fair use" or "fair dealing"). This Licence shall terminate immediately and You may no
106
+ longer exercise any of the rights granted to You by this Licence upon your failure to
107
+ honor the conditions in Section 1(c).
108
+
109
+ 10) Termination for Patent Action. This Licence shall terminate automatically and
110
+ You may no longer exercise any of the rights granted to You by this Licence as of
111
+ the date You commence an action, including a cross-claim or counterclaim, against
112
+ Licensor or any licensee alleging that the Original Work infringes a patent. This
113
+ termination provision shall not apply for an action alleging patent infringement
114
+ by combinations of the Original Work with other software or hardware.
115
+
116
+ 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this Licence
117
+ may be brought only in the courts of a jurisdiction wherein the Licensor resides or
118
+ in which Licensor conducts its primary business, and under the laws of that jurisdiction
119
+ excluding its conflict-of-law provisions. The application of the United Nations Convention
120
+ on Contracts for the International Sale of Goods is expressly excluded. Any use of
121
+ the Original Work outside the scope of this Licence or after its termination shall be
122
+ subject to the requirements and penalties of copyright or patent law in the appropriate
123
+ jurisdiction. This section shall survive the termination of this Licence.
124
+
125
+ 12) Attorneys' Fees. In any action to enforce the terms of this Licence or seeking
126
+ damages relating thereto, the prevailing party shall be entitled to recover its costs
127
+ and expenses, including, without limitation, reasonable attorneys' fees and costs
128
+ incurred in connection with such action, including any appeal of such action. This
129
+ section shall survive the termination of this Licence.
130
+
131
+ 13) Miscellaneous. If any provision of this Licence is held to be unenforceable,
132
+ such provision shall be reformed only to the extent necessary to make it enforceable.
133
+
134
+ 14) Definition of "You" in This Licence. "You" throughout this Licence, whether in
135
+ upper or lower case, means an individual or a legal entity exercising rights under,
136
+ and complying with all of the terms of, this Licence. For legal entities, "You" includes
137
+ any entity that controls, is controlled by, or is under common control with you. For
138
+ purposes of this definition, "control" means (i) the power, direct or indirect, to cause
139
+ the direction or management of such entity, whether by contract or otherwise, or (ii)
140
+ ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
141
+ ownership of such entity.
142
+
143
+ 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or
144
+ conditioned by this Licence or by law, and Licensor promises not to interfere with or be
145
+ responsible for such uses by You.
146
+
147
+ 16) Modification of This Licence. This Licence is Copyright © 2005 Lawrence Rosen.
148
+ Permission is granted to copy, distribute, or communicate this Licence without modification.
149
+ Nothing in this Licence permits You to modify this Licence as applied to the Original Work
150
+ or to Derivative Works. However, You may modify the text of this Licence and copy, distribute
151
+ or communicate your modified version (the "Modified Licence") and apply it to other original
152
+ works of authorship subject to the following conditions: (i) You may not indicate in any way
153
+ that your Modified Licence is the "Open Software Licence" or "OSL" and you may not use those
154
+ names in the name of your Modified Licence; (ii) You must replace the notice specified in the
155
+ first paragraph above with the notice "Licensed under <insert your license name here>" or
156
+ with a notice of your own that is not confusingly similar to the notice in this Licence;
157
+ and (iii) You may not claim that your original works are open source software unless your
158
+ Modified Licence has been approved by Open Source Initiative (OSI) and You comply with
159
+ its license review and certification process.
@@ -0,0 +1,60 @@
1
+ = JEEVES
2
+
3
+ == [Subtitle]
4
+
5
+ [Summary of what the project/gem does]
6
+
7
+ == Usage
8
+
9
+ [Describe how to use it]
10
+
11
+ == Examples
12
+
13
+ [And provide some examples of usage]
14
+
15
+ [This will be highlighted as a code box]
16
+
17
+ == Installation
18
+
19
+ [How to]
20
+
21
+ === Dependencies
22
+
23
+ [This list should include:]
24
+
25
+ ruby - ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux]
26
+ jeckyl - used to parse configuration files into a convenient options hash
27
+ jelly - a logger with syslog knobs on
28
+ jevoom - makes it easier to keep version info and git commit messages in harmony
29
+ git - to manage versioning
30
+ rdoc - to manage documentation
31
+
32
+ == Documentation
33
+
34
+ Documentation is available via rdoc. All files, including this one and the text files
35
+ in the project root should use rdoc markup.
36
+ {Details on rdoc markup are available here}[http://rdoc.rubyforge.org/RDoc/Markup.html]
37
+
38
+ == Testing/Modifying
39
+
40
+ [Describe the rspec tests that can be used to check the code]
41
+
42
+ == Bugs
43
+
44
+ Details of any unresolved bugs and change requests are in Bugs.txt.
45
+
46
+ == Changelog
47
+
48
+ This can be found in the History.txt file. This file is used by Jevoom to manage the
49
+ version info and create git commits.
50
+
51
+ == Copyright
52
+
53
+ See individual files and the LICENCE file.
54
+ The author may be contacted by email: robert(a)osburn-sharp.ath.cx
55
+
56
+ == Warranty
57
+
58
+ This software is provided "as is" and without any express or implied
59
+ warranties, including, without limitation, the implied warranties of
60
+ merchantibility and fitness for a particular purpose.
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ #
4
+ # = Jeeves CLI
5
+ #
6
+ # == Using optplus
7
+ #
8
+ # Author:: Robert Sharp
9
+ # Copyright:: Copyright (c) 2014 Robert Sharp
10
+ # License:: Open Software Licence v3.0
11
+ #
12
+ # This software is licensed for use under the Open Software Licence v. 3.0
13
+ # The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
14
+ # and in the file copyright.txt. Under the terms of this licence, all derivative works
15
+ # must themselves be licensed under the Open Software Licence v. 3.0
16
+ #
17
+ #
18
+ #
19
+
20
+ require 'optplus'
21
+
22
+ require 'jeeves'
23
+ require 'jeeves/config'
24
+ require 'jeeves/store'
25
+ require 'jeeves/partition'
26
+ require 'jeeves/video'
27
+ require 'jeckyl/errors'
28
+ require 'jellog/proxy'
29
+
30
+ require 'jeni/io'
31
+
32
+ require 'jeeves/parser/listings'
33
+ require 'jeeves/parser/store'
34
+ require 'jeeves/parser/videos'
35
+
36
+ class JeevesCLI < Optplus::Parser
37
+
38
+ usage "Usage: jeeves [actions] [options]"
39
+
40
+ description "support utilities for the Jeeves PVR system"
41
+
42
+ def options(opts)
43
+
44
+ opts.on('-c', '--config [FILE]', String, 'use the given config file') do |c|
45
+ set_option :config_file, c
46
+ end
47
+
48
+ opts.on('-f', '--force', 'force an init regardless of existing keys') do |c|
49
+ set_option :force_init, c
50
+ end
51
+
52
+ opts.on('-a', '--all', 'clean all files in the list regardless of status') do |c|
53
+ set_option :clean_all, c
54
+ end
55
+
56
+ opts.on('-d', '--delete', 'delete all possible file list data - use with care') do |c|
57
+ set_option :delete, c
58
+ end
59
+
60
+ opts.on('-T', '--timeout [VALUE]', Integer, 'set timeout for waiting on Jeeves applications') do |c|
61
+ set_option :timeout, c
62
+ end
63
+
64
+ opts.on('-E', '--errors [TYPE]', [:ignore, :warn, :fatal], 'set the way store errors are treated') do |c|
65
+ set_option :store_errors, c
66
+ end
67
+
68
+ opts.on('-u', '--update', 'update listings data regardless of when it was last downloaded') do |c|
69
+ set_option :update_listings, c
70
+ end
71
+
72
+ opts.on('-R', '--reset', 'reset listings data, clearing out all old listings') do |c|
73
+ set_option :reset_listings, c
74
+ end
75
+
76
+ debug_option(opts)
77
+
78
+ verbose_option(opts)
79
+
80
+ end
81
+
82
+ describe :info, 'Show information about Jeeves PVR'
83
+
84
+ help :info, "Show information about the current configured Jeeves"
85
+
86
+ def before_actions
87
+
88
+ jconfig = get_option(:config_file)
89
+
90
+ @jeeves_config = Jeeves.get_config(jconfig)
91
+
92
+ show_log = get_option(:debug) || get_option(:verbose)
93
+
94
+ @logger = Jellog::ProxyLogger.new("Jeeves", :suppress=>!show_log)
95
+
96
+ if get_option :debug then
97
+ @logger.log_level = :debug
98
+ @logger.debug "Setting logger to debug"
99
+ end
100
+ if get_option :verbose then
101
+ @logger.log_level = :verbose
102
+ @logger.verbose "Setting logger to verbose"
103
+ end
104
+ end
105
+
106
+ attr_reader :jeeves_config
107
+ attr_reader :logger
108
+
109
+ def info
110
+ puts "Hello World"
111
+
112
+ puts "Jeeves URL: #{@jeeves_config[:jeeves_url]}"
113
+ end
114
+
115
+ nest_parser :listings, ListingCLI, 'manage TV listings'
116
+ nest_parser :store, StoreCLI, 'manage Jeeves stores'
117
+ nest_parser :videos, VideosCLI, 'manage Jeeves videos'
118
+
119
+
120
+ end
121
+
122
+ JeevesCLI.run!
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Author:: R.J.Sharp
4
+ # Email:: robert(a)osburn-sharp.ath.cx
5
+ # Copyright:: Copyright (c) 2012
6
+ # License:: Open Software Licence v3.0
7
+ #
8
+ # This software is licensed for use under the Open Software Licence v. 3.0
9
+ # The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
10
+ # and in the file LICENCE. Under the terms of this licence, all derivative works
11
+ # must themselves be licensed under the Open Software Licence v. 3.0
12
+ #
13
+ #
14
+ require 'rubygems'
15
+
16
+ # a general client for the jemplayer service
17
+
18
+ require 'jeni'
19
+
20
+
21
+ Jeni::Installer.new_from_gem('jeeves-pvr') do |jenny|
22
+ jenny.optparse(ARGV)
23
+
24
+ jenny.file('etc/jerbil/jeeves.rb', '/etc/jerbil/jeeves.rb')
25
+ #jenny.file('bin/jeeves.wrapper', '/usr/bin/jeeves', :chmod=>0755)
26
+
27
+ end.run!
@@ -0,0 +1,375 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ #
4
+ # = Jeeves CLI
5
+ #
6
+ # == Command Line Interpreter for various Jeeves tasks
7
+ #
8
+ # Author:: Robert Sharp
9
+ # Copyright:: Copyright (c) 2013 Robert Sharp
10
+ # License:: Open Software Licence v3.0
11
+ #
12
+ # This software is licensed for use under the Open Software Licence v. 3.0
13
+ # The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
14
+ # and in the file copyright.txt. Under the terms of this licence, all derivative works
15
+ # must themselves be licensed under the Open Software Licence v. 3.0
16
+ #
17
+ # Based on Optparse
18
+ #
19
+
20
+ require 'rubygems'
21
+ require 'optparse'
22
+ require 'jeeves'
23
+ require 'jeeves/config'
24
+ require 'jeeves/store'
25
+ require 'jeeves/partition'
26
+ require 'jeeves/video'
27
+ require 'jeckyl/errors'
28
+ require 'jellog/proxy'
29
+ require 'jeni/io'
30
+ require 'colored'
31
+
32
+ include Jeni::IO
33
+
34
+ local_options = Hash.new
35
+ debug = false
36
+ verbose = false
37
+ config_file = nil
38
+ suppress = true
39
+
40
+
41
+ commands = Hash.new
42
+ # define global options
43
+ actions = OptionParser.new do |opts|
44
+
45
+ opts.banner = "Usage: jeeves [actions] [options]"
46
+
47
+ opts.separator ""
48
+ opts.separator "where actions are listed below"
49
+ opts.separator "and options can be global or specific to actions as shown below"
50
+ opts.separator ""
51
+ opts.separator "Actions can be one of the following:"
52
+ opts.separator ""
53
+ opts.separator " store - manage where jeeves stores videos"
54
+ opts.separator " listings - manage programme listings"
55
+ opts.separator " videos - do things with specific videos"
56
+ opts.separator ""
57
+ opts.separator "Global Options"
58
+ opts.separator ""
59
+
60
+ opts.on('-c', '--config [FILE]', String, 'use the given config file') do |c|
61
+ config_file = c
62
+ end
63
+
64
+
65
+ opts.separator ""
66
+ opts.separator "Actions for 'jeeves store':"
67
+ opts.separator ""
68
+ opts.separator " init - create a key file to initialise a store"
69
+ opts.separator " status - list specified stores and their status"
70
+ opts.separator " clean - clean up the file list"
71
+ opts.separator ""
72
+ opts.separator "Options for 'store init' command"
73
+ opts.separator ""
74
+
75
+ opts.on('-f', '--force', 'force an init regardless of existing keys') do |c|
76
+ local_options[:force_init] = c
77
+ end
78
+
79
+ opts.on('-a', '--all', 'clean all files in the list regardless of status') do |c|
80
+ local_options[:clean_all] = c
81
+ end
82
+
83
+ opts.on('-d', '--delete', 'delete all possible file list data - use with care') do |c|
84
+ local_options[:delete] = c
85
+ end
86
+
87
+ opts.on('-E', '--errors [TYPE]', [:ignore, :warn, :fatal], 'set the way store errors are treated') do |c|
88
+ local_options[:store_errors] = c
89
+ end
90
+
91
+ opts.separator ""
92
+ opts.separator "Actions for 'jeeves listings':"
93
+ opts.separator ""
94
+ opts.separator " update - download the lastest listings info and update Jeeves TV"
95
+ opts.separator " clean - clean out old listings"
96
+ opts.separator ""
97
+ opts.separator "Options for 'listings' command"
98
+ opts.separator ""
99
+
100
+ opts.on('-u', '--update', 'update listings data regardless of when it was last downloaded') do |c|
101
+ local_options[:update_listings] = c
102
+ end
103
+
104
+ opts.on('-R', '--reset', 'reset listings data, clearing out all old listings') do |c|
105
+ local_options[:reset_listings] = c
106
+ end
107
+
108
+ opts.separator ""
109
+ opts.separator "General options"
110
+ opts.separator ""
111
+
112
+ opts.on_tail('-D', '--debug', 'show debug information') do
113
+ debug = true
114
+ verbose = false
115
+ suppress = false
116
+ end
117
+
118
+ opts.on_tail('-V', '--verbose', 'show verbose information') do
119
+ verbose = true
120
+ debug = false
121
+ suppress = false
122
+ end
123
+
124
+ opts.on_tail('-h', '--help', 'you are looking at it') do
125
+ puts opts
126
+ #show_help(commands)
127
+ exit 0
128
+ end
129
+
130
+ end.permute(ARGV)
131
+
132
+ # start a logger
133
+ logger = Jellog::ProxyLogger.new("Jeeves", :suppress=>suppress)
134
+
135
+ if debug then
136
+ logger.log_level = :debug
137
+ logger.debug "Setting logger to debug"
138
+ end
139
+ if verbose then
140
+ logger.log_level = :verbose
141
+ logger.verbose "Setting logger to verbose"
142
+ puts "Running under ruby #{RUBY_VERSION}"
143
+ end
144
+
145
+
146
+ begin
147
+ options = Jeeves.get_config(config_file)
148
+ rescue Jeckyl::ConfigFileMissing
149
+ logger.error "No config file #{config_file ? config_file : '/etc/jerbil/jeeves.rb'}"
150
+ exit 1
151
+ end
152
+
153
+ options = options.merge(local_options)
154
+
155
+ begin
156
+ raise ArgumentError, "You must specify an action" unless actions.length > 0
157
+ case act = actions.shift.to_sym
158
+ when :store
159
+ actions.unshift('status') unless actions.length > 0
160
+ case act = actions.shift.to_sym
161
+ when :init
162
+ # jeeves store init path/to/store
163
+ #
164
+ # expect next argument to be a file
165
+ if actions.length > 0 then
166
+ new_store = actions.shift
167
+ else
168
+ logger.error "need to provide a path to initialise"
169
+ exit 1
170
+ end
171
+ unless FileTest.exists?(new_store)
172
+ logger.error "Error: path #{new_store} does not exist"
173
+ exit 1
174
+ end
175
+ forced = options[:force_init] # fudge due to bug in jeckyl(?)
176
+ force = options[:force_init]
177
+ part = Jeeves::Partition.new(new_store)
178
+ puts "Forcing a new key" if force
179
+ key = part.create_key(force)
180
+ puts "# add this line to your config file"
181
+ puts "add_store :path=>'#{part.path}', :key=>'#{key}'"
182
+ when :status
183
+ parts = Array.new
184
+ devices = Array.new
185
+ options[:add_partition].each_pair do |path, params|
186
+ part = Jeeves::Partition.new(path, params)
187
+ # if mounted = FileTest.exists?(path) ? 'OK' : 'No'then
188
+ # key_ok = Jeeves::Store.key_ok?(path, params[:key]) ? 'OK' : 'Error'
189
+ # end
190
+ if part.ready? then
191
+ if devices.include?(part.device) then
192
+ part.duplicate = true
193
+ else
194
+ devices << part.device
195
+ end
196
+
197
+ end
198
+ parts << part.to_a
199
+ end
200
+ Jeeves.tabulate(%w{* 4c 4c 4c 8r 8r},
201
+ %w{Path Mnt Rdy Dup Total Free},
202
+ parts
203
+ )
204
+ when :list
205
+ # jeeves store list
206
+ jestore = Jeeves::Store.new(logger, options)
207
+ if jestore.files <= 0 then
208
+ puts "There are no files to show"
209
+ else
210
+ entries = Array.new
211
+ jestore.each_file do |path, params|
212
+ entries << [path, Jeeves.human_size(params[:space]), params[:date].strftime("%Y-%b-%d %H:%M")]
213
+ end
214
+
215
+ Jeeves.tabulate(%w{* *r *c},
216
+ %w{Path Space Date},
217
+ entries)
218
+ end
219
+ when :clean
220
+ jestore = Jeeves::Store.new(logger, options)
221
+ if local_options[:delete] then
222
+ # going to get rid of all file lists
223
+ if ask('Delete all file lists?', :no, 'yn') == :yes then
224
+
225
+ jestore.each_partition do |part|
226
+ if FileTest.exists?(part.file_list) then
227
+ puts "Deleting #{part.file_list}"
228
+ FileUtils.rm_f(part.file_list)
229
+ end
230
+ end
231
+
232
+ else
233
+
234
+ puts "OK, no files have been deleted"
235
+
236
+ end
237
+ exit 0
238
+ end
239
+
240
+ # jeeves store clear
241
+ if jestore.files == 0 then
242
+ puts "The file list is already empty, nothing to clean"
243
+ exit 0
244
+ end
245
+ if local_options[:clean_all] then
246
+ if ask('Clean all files from the list?', :no, 'yn') != :no then
247
+ jestore.clean(true)
248
+ puts "The file list is now empty"
249
+ end
250
+ else
251
+ if ask('Clean files from the list?', :no, 'yn') != :no then
252
+ jestore.clean
253
+ puts "Cleaned file list"
254
+ end
255
+ end
256
+ else #case
257
+ raise ArgumentError, "Unknown action for store: #{act}"
258
+ end # case store actions
259
+
260
+ #
261
+ # listings actions
262
+ #
263
+
264
+ when :listings
265
+ # update
266
+ actions.unshift('status') unless actions.length > 0
267
+ case act = actions.shift.to_sym
268
+ when :update
269
+ begin
270
+ Jeeves.update_listings(options)
271
+ rescue Jeeves::ListingError => e
272
+ puts "Error while updating listings: #{e}"
273
+ exit 1
274
+ end
275
+
276
+ else
277
+ raise ArgumentError, "Unknown action for listings: #{act}"
278
+ end # case
279
+
280
+ #
281
+ # video actions
282
+ #
283
+
284
+ when :videos
285
+ # load, cleanup etc
286
+ actions.unshift('status') unless actions.length > 0
287
+ case act = actions.shift.to_sym
288
+ when :wrangle
289
+ begin
290
+ unless file = actions.shift
291
+ logger.error "Need to provide a file to wrangle"
292
+ exit 1
293
+ end
294
+ unless FileTest.exists?(file)
295
+ logger.error "File does not exist: #{file}"
296
+ exit 1
297
+ end
298
+ unless pid = actions.shift
299
+ logger.error "Need to provide a programme id to wrangle"
300
+ exit 1
301
+ end
302
+ vid = Jeeves::Video.new(file, logger, options)
303
+ vid.tag_from_prog_id(pid)
304
+ response = vid.upload_to_jeeves
305
+ vid.clean_up
306
+ if response.to_i == 0 then
307
+ puts "Jeeves OK"
308
+
309
+ else
310
+ logger.error "Jeeves returned unexpected response: #{response}"
311
+ end
312
+ rescue Jeeves::JeevesError => e
313
+ puts "Error while wrangling video: #{e}"
314
+ end
315
+ when :load
316
+ begin
317
+ unless file = actions.shift
318
+ logger.error "Need to provide a file to load"
319
+ exit 1
320
+ end
321
+ unless FileTest.exists?(file)
322
+ logger.error "File does not exist: #{file}"
323
+ exit 1
324
+ end
325
+ vid = Jeeves::Video.new(file, logger, options)
326
+ response = vid.upload_to_jeeves
327
+ vid.clean_up
328
+ if response.to_i == 0 then
329
+ puts "Jeeves OK"
330
+
331
+ else
332
+ logger.error "Jeeves returned unexpected response: #{response}"
333
+ end
334
+ rescue Jeeves::JeevesError => e
335
+ puts "Error while wrangling video: #{e}"
336
+ end
337
+
338
+ when :show
339
+ unless file = actions.shift
340
+ logger.error "Need to provide a file to load"
341
+ exit 1
342
+ end
343
+ unless FileTest.exists?(file)
344
+ logger.error "File does not exist: #{file}"
345
+ exit 1
346
+ end
347
+ vid = Jeeves::Video.new(file, logger, options)
348
+ tags = vid.get_tags
349
+ tags.each_tag do |key, value|
350
+ puts "#{key}: #{value}"
351
+ end
352
+
353
+ end # case for video subcommands
354
+
355
+ else
356
+ puts "Error: Unknown action #{act}"
357
+ exit 1
358
+ end # first level action
359
+ rescue ArgumentError => err
360
+ logger.error err
361
+ if debug then
362
+ err.backtrace.each do |bt|
363
+ puts bt
364
+ end
365
+ end
366
+ rescue Jeeves::JeevesError => err
367
+ logger.error "#{err}"
368
+ if debug then
369
+ err.backtrace.each do |bt|
370
+ puts bt
371
+ end
372
+ end
373
+ ensure
374
+ puts options if debug
375
+ end