rjobs 0.2.0.alpha → 0.3.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,23 +9,27 @@ require "rjobs/job_handler"
9
9
  require 'rjobs/cli_helper'
10
10
  include Rjobs::CliHelper
11
11
 
12
- p = Trollop::Parser.new do
13
- banner <<-EOS
12
+ banner = "================
14
13
  Harvest all finished jobs described in the jobs file.
15
-
14
+ ================
16
15
  Usage:
17
16
  rjharvest [options] <filename>
18
17
  where [options] are:
19
- EOS
20
-
21
- end
18
+ "
19
+
20
+ p = parser(banner)
22
21
 
23
22
  opts = Trollop::with_standard_exception_handling p do
24
23
  o = p.parse ARGV
25
24
  raise Trollop::HelpNeeded if ARGV.empty? # show help screen
25
+ o
26
26
  end
27
27
 
28
+ Rjobs::JobHandler.host = opts[:host]
29
+ Rjobs::JobHandler.password = opts[:password]
30
+
28
31
  jobs_file = ARGV[0]
32
+ raise "The file \"#{jobs_file}\" must exist." unless File.exist?(jobs_file)
29
33
 
30
34
  jobs = get_jobs_info(jobs_file)
31
35
  jobs.each do |job|
@@ -9,16 +9,15 @@ require "rjobs/job_handler"
9
9
  require 'rjobs/cli_helper'
10
10
  include Rjobs::CliHelper
11
11
 
12
- p = Trollop::Parser.new do
13
- banner <<-EOS
12
+ banner = "================
14
13
  Get the status of jobs described in the jobs file.
15
-
14
+ ================
16
15
  Usage:
17
16
  rjstatus [options] <filename>
18
17
  where [options] are:
19
- EOS
20
-
21
- end
18
+ "
19
+
20
+ p = parser(banner)
22
21
 
23
22
  opts = Trollop::with_standard_exception_handling p do
24
23
  o = p.parse ARGV
@@ -26,10 +25,34 @@ opts = Trollop::with_standard_exception_handling p do
26
25
  end
27
26
 
28
27
  jobs_file = ARGV[0]
28
+ raise "The file \"#{jobs_file}\" must exist." unless File.exist?(jobs_file)
29
29
 
30
30
  jobs = get_jobs_info(jobs_file)
31
31
 
32
+ jFinished = 0
33
+ jPending = 0
34
+ jFailed = 0
35
+ jNE =0
36
+
32
37
  jobs.each do |job|
33
38
  puts "#{job.name} - #{job.status_with_color}"
39
+ case job.status
40
+ when /Finished/
41
+ jFinished +=1
42
+ when /Failed/
43
+ jFailed +=1
44
+ when /Not Exist/
45
+ jNE+=1
46
+ else
47
+ jPending +=1
48
+ end
49
+
34
50
  end
35
51
 
52
+ #output number of success jobs - pending jobs - failed jobs
53
+ sFinish = "#{jFinished} finished".green if jFinished > 0
54
+ sPending = "- #{jPending} pending" if jPending > 0
55
+ sFailed = "- #{jFailed} failed".red if jFailed > 0
56
+ sNE = "- #{jNE} not exist".red if jNE > 0
57
+
58
+ puts "#{jobs.count} jobs: #{sFinish} #{sPending} #{sFailed} #{sNE}."
@@ -10,16 +10,15 @@ require "rjobs/job_handler"
10
10
  require 'rjobs/cli_helper'
11
11
  include Rjobs::CliHelper
12
12
 
13
- p = Trollop::Parser.new do
14
- banner <<-EOS
13
+ banner = "================
15
14
  Submit jobs described in the YAML input file.
16
-
15
+ ================
17
16
  Usage:
18
- rjsubmit [options] <filename>
17
+ rjsubmit [options] <filename>
19
18
  where [options] are:
20
- EOS
21
-
22
- end
19
+ "
20
+
21
+ p = parser(banner)
23
22
 
24
23
  opts = Trollop::with_standard_exception_handling p do
25
24
  o = p.parse ARGV
@@ -28,6 +27,8 @@ end
28
27
 
29
28
 
30
29
  jobs_input_file = ARGV[0]
30
+ raise "The file \"#{jobs_input_file}\" must exist." unless File.exist?(jobs_input_file)
31
+
31
32
 
32
33
  jif = Rjobs::JobInputFile.new(jobs_input_file)
33
34
  jobs = []
@@ -12,7 +12,7 @@ Then /^show me the output$/ do
12
12
  end
13
13
 
14
14
  Then /^each line of the output should match \/([^\/]*)\/$/ do |expected|
15
- all_stdout.split("\n").each do |line|
15
+ all_stdout.split("\n")[0..-2].each do |line|
16
16
  # puts line
17
17
  line.should match expected
18
18
  end
@@ -1,3 +1,5 @@
1
+ require "trollop"
2
+
1
3
  module Rjobs
2
4
  module CliHelper
3
5
  def get_jobs_info(jobs_file)
@@ -10,5 +12,20 @@ module Rjobs
10
12
  end
11
13
  jobs
12
14
  end
15
+
16
+ def parser(banner_string)
17
+ default_hostname = ENV['XGRID_CONTROLLER_HOSTNAME'].nil? ? "127.0.0.1" : ENV['XGRID_CONTROLLER_HOSTNAME']
18
+ default_password = ENV['XGRID_CONTROLLER_PASSWORD'].nil? ? "xgrid" : ENV['XGRID_CONTROLLER_PASSWORD']
19
+ Trollop::Parser.new do
20
+ banner banner_string
21
+ opt :host, "Hostname or IP address of the xgrid controller",
22
+ :type=> String,
23
+ :default=> default_hostname
24
+ opt :password, "Password to access the xgrid controller",
25
+ :type=> String,
26
+ :default=> default_password
27
+ end
28
+ end
29
+
13
30
  end
14
31
  end
@@ -43,7 +43,6 @@ module Rjobs
43
43
  result = Plist::parse_xml(xml)
44
44
  @name = result['jobAttributes'].nil? ? "" : result['jobAttributes']['name']
45
45
  @status = result['jobAttributes'].nil? ? "Not Exist" : result['jobAttributes']['jobStatus']
46
-
47
46
  end
48
47
 
49
48
 
@@ -9,8 +9,8 @@ module Rjobs
9
9
 
10
10
  def self.get_job_attributes(id)
11
11
  cb = Rjobs::CommandBuilder.new("xgrid", {
12
- :h => @@host,
13
- :p => @@password,
12
+ :h => host,
13
+ :p => password,
14
14
  :f => "xml",
15
15
  :job => :attributes,
16
16
  :id => id
@@ -54,5 +54,23 @@ module Rjobs
54
54
  Rjobs::Process.run(cb.build)
55
55
  end
56
56
 
57
+ def self.host
58
+ @@host
59
+ end
60
+
61
+ def self.host=(value)
62
+ @@host = value
63
+ end
64
+
65
+ def self.password
66
+ @@password
67
+ end
68
+
69
+ def self.password=(value)
70
+ @@password = value
71
+ end
72
+
73
+
74
+
57
75
  end
58
76
  end
@@ -1,3 +1,3 @@
1
1
  module Rjobs
2
- VERSION = "0.2.0.alpha"
2
+ VERSION = "0.3.0.alpha"
3
3
  end
@@ -25,5 +25,7 @@ describe Rjobs::JobHandler do
25
25
  job.id.should == 11
26
26
  end
27
27
 
28
+
29
+
28
30
  end
29
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.alpha
4
+ version: 0.3.0.alpha
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-28 00:00:00.000000000Z
12
+ date: 2011-11-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70169642269800 !ruby/object:Gem::Requirement
16
+ requirement: &70100005401960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70169642269800
24
+ version_requirements: *70100005401960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cucumber
27
- requirement: &70169642268840 !ruby/object:Gem::Requirement
27
+ requirement: &70100005401340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70169642268840
35
+ version_requirements: *70100005401340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aruba
38
- requirement: &70169642268400 !ruby/object:Gem::Requirement
38
+ requirement: &70100005400720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70169642268400
46
+ version_requirements: *70100005400720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard
49
- requirement: &70169642267980 !ruby/object:Gem::Requirement
49
+ requirement: &70100005400120 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70169642267980
57
+ version_requirements: *70100005400120
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: growl_notify
60
- requirement: &70169642267440 !ruby/object:Gem::Requirement
60
+ requirement: &70100005399420 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70169642267440
68
+ version_requirements: *70100005399420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &70169642267020 !ruby/object:Gem::Requirement
71
+ requirement: &70100005398920 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70169642267020
79
+ version_requirements: *70100005398920
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: plist
82
- requirement: &70169642266600 !ruby/object:Gem::Requirement
82
+ requirement: &70100005398500 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70169642266600
90
+ version_requirements: *70100005398500
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: colorize
93
- requirement: &70169642266140 !ruby/object:Gem::Requirement
93
+ requirement: &70100005398080 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70169642266140
101
+ version_requirements: *70100005398080
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: trollop
104
- requirement: &70169642265700 !ruby/object:Gem::Requirement
104
+ requirement: &70100005397640 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70169642265700
112
+ version_requirements: *70100005397640
113
113
  description: Gem to handle Jobs for XGrid
114
114
  email:
115
115
  - merlinvn@gmail.com