oode 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/oode +15 -6
- data/lib/oode.rb +1 -0
- data/lib/oode/helper.rb +7 -0
- data/lib/oode/queue.rb +62 -28
- data/lib/oode/version.rb +1 -1
- data/man/oode.1 +62 -1
- data/man/oode.1.html +46 -1
- data/man/oode.1.ronn +44 -1
- metadata +4 -3
data/bin/oode
CHANGED
@@ -21,6 +21,7 @@ end
|
|
21
21
|
|
22
22
|
optparse = OptionParser.new do |opts|
|
23
23
|
opts.banner = "Usage: oode [options] filename"
|
24
|
+
options[:options] = {}
|
24
25
|
|
25
26
|
opts.on( "-h", "--help", "Display this screen." ) do
|
26
27
|
puts opts
|
@@ -32,7 +33,10 @@ optparse = OptionParser.new do |opts|
|
|
32
33
|
options[:printer] = printer
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
+
opts.on( "-f", "--force", "Force the print job no matter what state the printer is in." ) do |force|
|
37
|
+
options[:options][:force] = true
|
38
|
+
end
|
39
|
+
|
36
40
|
opts.on( "-n", "--number COPIES", "The number of copies of FILE you would like to print." ) do |copies|
|
37
41
|
options[:options][:copies] = copies
|
38
42
|
end
|
@@ -43,18 +47,23 @@ optparse = OptionParser.new do |opts|
|
|
43
47
|
end
|
44
48
|
|
45
49
|
options[:password] = config[:password]
|
46
|
-
opts.on( "-a", "--password PASSWORD",
|
47
|
-
"The password to log into DICE with." ) do |password|
|
50
|
+
opts.on( "-a", "--password PASSWORD", "The password to log into DICE with." ) do |password|
|
48
51
|
options[:password] = password
|
49
52
|
end
|
53
|
+
|
54
|
+
opts.on( "-4", "--four-up", "Print the document as four pages to a sheet." ) do |opt|
|
55
|
+
options[:options][:four] = true
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on( "-2", "--two-up", "Print the document as two pages to a sheet." ) do |opt|
|
59
|
+
options[:options][:two] = true
|
60
|
+
end
|
50
61
|
end
|
51
62
|
|
52
63
|
optparse.parse!
|
53
64
|
|
54
65
|
if options[:printer].nil?
|
55
|
-
|
56
|
-
puts "Please specify one with the '--printer' or '-p' flags."
|
57
|
-
exit
|
66
|
+
error "No printer was specified.\nPlease specify one with the '--printer' or '-p' flags."
|
58
67
|
end
|
59
68
|
|
60
69
|
if options[:user].nil?
|
data/lib/oode.rb
CHANGED
data/lib/oode/helper.rb
ADDED
data/lib/oode/queue.rb
CHANGED
@@ -7,34 +7,48 @@ module Oode
|
|
7
7
|
@user = user
|
8
8
|
@password = password
|
9
9
|
@printer = printer
|
10
|
+
@options = options
|
10
11
|
|
11
|
-
args_from_options options
|
12
|
+
args_from_options @options
|
13
|
+
|
14
|
+
begin
|
15
|
+
notify "Connecting to remote server..."
|
16
|
+
@ssh = Net::SSH.start('ssh.inf.ed.ac.uk', @user, :password => @password)
|
17
|
+
@sftp = @ssh.sftp
|
18
|
+
rescue Net::SSH::AuthenticationFailed
|
19
|
+
error "Your login credentials were incorrect. Please fix this and try again."
|
20
|
+
rescue Net::SSH::Exception
|
21
|
+
error "Something went wrong with your SSH connection. Please file a bug report at:\nhttp://github.com/xoebus/oode/issues"
|
22
|
+
end
|
12
23
|
end
|
13
24
|
|
14
25
|
def print
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
check_server
|
27
|
+
check_printer
|
28
|
+
upload_files
|
29
|
+
|
30
|
+
notify "Printing files on #{@printer.red}..."
|
31
|
+
@queue.each do |file|
|
32
|
+
file.print @ssh, remote_oode_path, @printer, @args
|
33
|
+
end
|
34
|
+
|
35
|
+
# Make sure the job has been sent to the printer.
|
36
|
+
sleep 1
|
37
|
+
|
38
|
+
clean @ssh
|
39
|
+
end
|
40
|
+
|
41
|
+
def upload_files
|
42
|
+
notify "Uploading files for printing..."
|
43
|
+
@queue.each do |file|
|
44
|
+
file.upload @sftp, remote_oode_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def check_server
|
49
|
+
notify "Checking remote server..."
|
50
|
+
unless @sftp.dir.entries(remote_user_path).map { |d| d.name }.include? ".oode"
|
51
|
+
@sftp.mkdir! remote_oode_path
|
38
52
|
end
|
39
53
|
end
|
40
54
|
|
@@ -45,16 +59,36 @@ module Oode
|
|
45
59
|
if options.has_key? :copies
|
46
60
|
@args << "-# #{options[:copies]} "
|
47
61
|
end
|
48
|
-
|
49
|
-
|
62
|
+
|
63
|
+
if options.has_key? :four
|
64
|
+
@args << "-Z 4up "
|
65
|
+
elsif options.has_key? :two
|
66
|
+
@args << "-Z 2up "
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def check_printer
|
71
|
+
unless @options.has_key? :force
|
72
|
+
notify "Checking your printer is working..."
|
73
|
+
|
74
|
+
command = "lpq -P #{@printer}"
|
75
|
+
output = @ssh.exec!("ssh student.login #{command}")
|
76
|
+
print_jobs = output.split("\n").length - 2
|
77
|
+
|
78
|
+
if (print_jobs > 5) || !(output =~ /is not ready/).nil?
|
79
|
+
error "#{@printer} isn't doing too well at the moment. Try another printer."
|
80
|
+
end
|
81
|
+
end
|
50
82
|
end
|
51
83
|
|
52
84
|
def remote_user_path
|
53
85
|
"/home/#{@user}"
|
54
86
|
end
|
55
87
|
|
56
|
-
def clean session
|
57
|
-
|
88
|
+
def clean session
|
89
|
+
notify "Cleaning up this mess..."
|
90
|
+
|
91
|
+
command = "rm -r /home/#{@user}/.oode"
|
58
92
|
session.exec!("ssh student.login #{command}")
|
59
93
|
#puts command.blue
|
60
94
|
end
|
data/lib/oode/version.rb
CHANGED
data/man/oode.1
CHANGED
@@ -7,11 +7,72 @@
|
|
7
7
|
\fBoode\fR \-\- print from a laptop to an AT printer
|
8
8
|
.
|
9
9
|
.SH "SYNOPSIS"
|
10
|
-
\fBoode\fR \fIOPTIONS\fR \
|
10
|
+
\fBoode\fR [\fIOPTIONS\fR] \fIFILE\fR...
|
11
|
+
.
|
12
|
+
.br
|
11
13
|
.
|
12
14
|
.SH "DESCRIPTION"
|
15
|
+
\fBoode\fR makes printing to the printers in Appleton Tower much easier
|
16
|
+
from laptops by automating some of the tediousness from the sequence
|
17
|
+
of tasks required.
|
13
18
|
.
|
14
19
|
.SH "CONFIGURATION"
|
20
|
+
\fBoode\fR can read SSH authentication usernames and passwords from a
|
21
|
+
configuration file so you don't have to type them in every time. A
|
22
|
+
file called \fB.ooderc\fR should be placed in your home directory with
|
23
|
+
the following contents:
|
24
|
+
.
|
25
|
+
.IP "" 4
|
26
|
+
.
|
27
|
+
.nf
|
28
|
+
|
29
|
+
:user: <username>
|
30
|
+
:password: <password>
|
31
|
+
.
|
32
|
+
.fi
|
33
|
+
.
|
34
|
+
.IP "" 0
|
35
|
+
.
|
36
|
+
.P
|
37
|
+
Either of these can be missed if you would rather enter them yourself
|
38
|
+
each time.
|
39
|
+
.
|
40
|
+
.SH "OPTIONS"
|
41
|
+
The following options and flags can be used with \fBoode\fR:
|
42
|
+
.
|
43
|
+
.SS "Authentication"
|
44
|
+
.
|
45
|
+
.TP
|
46
|
+
\fB\-u\fR, \fB\-\-user\fR=\fIUSERNAME\fR
|
47
|
+
Your DICE username so that \fBoode\fR can authenticate.
|
48
|
+
.
|
49
|
+
.TP
|
50
|
+
\fB\-a\fR, \fB\-\-password\fR=\fIPASSWORD\fR
|
51
|
+
Your DICE password so that \fBoode\fR can authenticate.
|
52
|
+
.
|
53
|
+
.SS "Miscellaneous"
|
54
|
+
.
|
55
|
+
.TP
|
56
|
+
\fB\-p\fR, \fB\-\-printer\fR=\fIPRINTER\fR
|
57
|
+
Use the printer, \fIPRINTER\fR, to print the \fIFILES\fR.
|
58
|
+
.
|
59
|
+
.TP
|
60
|
+
\fB\-f\fR, \fB\-\-force\fR
|
61
|
+
Force \fBoode\fR to use a certain printer even if it is not desired.
|
62
|
+
.
|
63
|
+
.SS "Printing"
|
64
|
+
.
|
65
|
+
.TP
|
66
|
+
\fB\-n\fR, \fB\-\-number\fR=\fINUMBER\fR
|
67
|
+
Print \fINUMBER\fR copies of the \fIFILES\fR.
|
68
|
+
.
|
69
|
+
.TP
|
70
|
+
\fB\-2\fR, \fB\-\-two\-up\fR
|
71
|
+
Print the files in the 2\-up style.
|
72
|
+
.
|
73
|
+
.TP
|
74
|
+
\fB\-4\fR, \fB\-\-four\-up\fR
|
75
|
+
Print the files in the 4\-up style.
|
15
76
|
.
|
16
77
|
.SH "BUGS"
|
17
78
|
\fIhttp://github.com/xoebus/oode/issues\fR
|
data/man/oode.1.html
CHANGED
@@ -67,12 +67,57 @@
|
|
67
67
|
|
68
68
|
<h2>SYNOPSIS</h2>
|
69
69
|
|
70
|
-
<p><code>oode</code> <var>OPTIONS</var> <var>
|
70
|
+
<p><code>oode</code> [<var>OPTIONS</var>] <var>FILE</var>...<br /></p>
|
71
71
|
|
72
72
|
<h2>DESCRIPTION</h2>
|
73
73
|
|
74
|
+
<p><code>oode</code> makes printing to the printers in Appleton Tower much easier
|
75
|
+
from laptops by automating some of the tediousness from the sequence
|
76
|
+
of tasks required.</p>
|
77
|
+
|
74
78
|
<h2>CONFIGURATION</h2>
|
75
79
|
|
80
|
+
<p><code>oode</code> can read SSH authentication usernames and passwords from a
|
81
|
+
configuration file so you don't have to type them in every time. A
|
82
|
+
file called <code>.ooderc</code> should be placed in your home directory with
|
83
|
+
the following contents:</p>
|
84
|
+
|
85
|
+
<pre><code>:user: <username>
|
86
|
+
:password: <password>
|
87
|
+
</code></pre>
|
88
|
+
|
89
|
+
<p>Either of these can be missed if you would rather enter them yourself
|
90
|
+
each time.</p>
|
91
|
+
|
92
|
+
<h2>OPTIONS</h2>
|
93
|
+
|
94
|
+
<p>The following options and flags can be used with <code>oode</code>:</p>
|
95
|
+
|
96
|
+
<h3>Authentication</h3>
|
97
|
+
|
98
|
+
<dl>
|
99
|
+
<dt><code>-u</code>, <code>--user</code>=<var>USERNAME</var></dt><dd><p> Your DICE username so that <code>oode</code> can authenticate.</p></dd>
|
100
|
+
<dt><code>-a</code>, <code>--password</code>=<var>PASSWORD</var></dt><dd><p> Your DICE password so that <code>oode</code> can authenticate.</p></dd>
|
101
|
+
</dl>
|
102
|
+
|
103
|
+
|
104
|
+
<h3>Miscellaneous</h3>
|
105
|
+
|
106
|
+
<dl>
|
107
|
+
<dt><code>-p</code>, <code>--printer</code>=<var>PRINTER</var></dt><dd><p> Use the printer, <var>PRINTER</var>, to print the <var>FILES</var>.</p></dd>
|
108
|
+
<dt><code>-f</code>, <code>--force</code></dt><dd><p> Force <code>oode</code> to use a certain printer even if it is not desired.</p></dd>
|
109
|
+
</dl>
|
110
|
+
|
111
|
+
|
112
|
+
<h3>Printing</h3>
|
113
|
+
|
114
|
+
<dl>
|
115
|
+
<dt><code>-n</code>, <code>--number</code>=<var>NUMBER</var></dt><dd><p> Print <var>NUMBER</var> copies of the <var>FILES</var>.</p></dd>
|
116
|
+
<dt><code>-2</code>, <code>--two-up</code></dt><dd><p> Print the files in the 2-up style.</p></dd>
|
117
|
+
<dt><code>-4</code>, <code>--four-up</code></dt><dd><p> Print the files in the 4-up style.</p></dd>
|
118
|
+
</dl>
|
119
|
+
|
120
|
+
|
76
121
|
<h2>BUGS</h2>
|
77
122
|
|
78
123
|
<p><a href="http://github.com/xoebus/oode/issues">http://github.com/xoebus/oode/issues</a></p>
|
data/man/oode.1.ronn
CHANGED
@@ -3,13 +3,56 @@ oode(1) -- print from a laptop to an AT printer
|
|
3
3
|
|
4
4
|
## SYNOPSIS
|
5
5
|
|
6
|
-
`oode` <OPTIONS> <
|
6
|
+
`oode` [<OPTIONS>] <FILE>...<br>
|
7
7
|
|
8
8
|
## DESCRIPTION
|
9
9
|
|
10
|
+
`oode` makes printing to the printers in Appleton Tower much easier
|
11
|
+
from laptops by automating some of the tediousness from the sequence
|
12
|
+
of tasks required.
|
10
13
|
|
11
14
|
## CONFIGURATION
|
12
15
|
|
16
|
+
`oode` can read SSH authentication usernames and passwords from a
|
17
|
+
configuration file so you don't have to type them in every time. A
|
18
|
+
file called `.ooderc` should be placed in your home directory with
|
19
|
+
the following contents:
|
20
|
+
|
21
|
+
:user: <username>
|
22
|
+
:password: <password>
|
23
|
+
|
24
|
+
Either of these can be missed if you would rather enter them yourself
|
25
|
+
each time.
|
26
|
+
|
27
|
+
## OPTIONS
|
28
|
+
The following options and flags can be used with `oode`:
|
29
|
+
|
30
|
+
### Authentication
|
31
|
+
|
32
|
+
* `-u`, `--user`=<USERNAME>:
|
33
|
+
Your DICE username so that `oode` can authenticate.
|
34
|
+
|
35
|
+
* `-a`, `--password`=<PASSWORD>:
|
36
|
+
Your DICE password so that `oode` can authenticate.
|
37
|
+
|
38
|
+
### Miscellaneous
|
39
|
+
|
40
|
+
* `-p`, `--printer`=<PRINTER>:
|
41
|
+
Use the printer, <PRINTER>, to print the <FILES>.
|
42
|
+
|
43
|
+
* `-f`, `--force`:
|
44
|
+
Force `oode` to use a certain printer even if it is not desired.
|
45
|
+
|
46
|
+
### Printing
|
47
|
+
|
48
|
+
* `-n`, `--number`=<NUMBER>:
|
49
|
+
Print <NUMBER> copies of the <FILES>.
|
50
|
+
|
51
|
+
* `-2`, `--two-up`:
|
52
|
+
Print the files in the 2-up style.
|
53
|
+
|
54
|
+
* `-4`, `--four-up`:
|
55
|
+
Print the files in the 4-up style.
|
13
56
|
|
14
57
|
## BUGS
|
15
58
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chris Brown
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-30 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- LICENSE
|
68
68
|
- lib/oode/colour.rb
|
69
69
|
- lib/oode/file.rb
|
70
|
+
- lib/oode/helper.rb
|
70
71
|
- lib/oode/queue.rb
|
71
72
|
- lib/oode/version.rb
|
72
73
|
- lib/oode.rb
|