pkg-wizard 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -49,6 +49,72 @@ module PKGWizard
49
49
  end
50
50
  end
51
51
 
52
+ # list failed pkgs
53
+ get '/job/failed' do
54
+ max = params[:max] || 10
55
+ jobs = Dir["failed/job_*"].sort { |a,b| a <=> b }
56
+ max = max.to_i
57
+ if jobs.size > max.to_i
58
+ jobs[- max..-1].to_yaml
59
+ else
60
+ jobs.to_yaml
61
+ end
62
+ end
63
+
64
+ get '/job/stats' do
65
+ fjobs = Dir["failed/job*"].size
66
+ sjobs = Dir["output/job*"].size
67
+ total_jobs = fjobs + sjobs
68
+ {
69
+ :failed_jobs => fjobs,
70
+ :successful_jobs => sjobs,
71
+ :total_jobs => total_jobs
72
+ }.to_yaml
73
+ end
74
+
75
+ # list failed pkgs
76
+ get '/job/successful' do
77
+ max = params[:max] || 10
78
+ jobs = Dir["output/job_*"].sort { |a,b| a <=> b }
79
+ max = max.to_i
80
+ if jobs.size > max.to_i
81
+ jobs[- max..-1].to_yaml
82
+ else
83
+ jobs.to_yaml
84
+ end
85
+ end
86
+
87
+ get '/job/:name' do
88
+ jname = params[:name]
89
+ jobs = Dir['output/job_*'] + Dir['failed/job_*']
90
+ found = false
91
+ meta = ''
92
+ if jname == 'all'
93
+ found = true
94
+ metas = []
95
+ jobs.each do |j|
96
+ mfile = j + '/meta.yml'
97
+ if File.exist?(mfile)
98
+ metas << YAML.load_file(mfile)
99
+ else
100
+ $stderr.puts "[WARNING] Meta file #{mfile} not found"
101
+ end
102
+ end
103
+ meta = metas.to_yaml
104
+ else
105
+ jobs.each do |j|
106
+ if File.basename(j) == jname
107
+ found = true
108
+ puts j + '/meta.yml'
109
+ meta = File.read(j + '/meta.yml')
110
+ break
111
+ end
112
+ end
113
+ end
114
+ status 404 if not found
115
+ meta
116
+ end
117
+
52
118
  end
53
119
 
54
120
  def self.perform
@@ -103,9 +169,11 @@ module PKGWizard
103
169
  end
104
170
  if meta[:status] == 'error'
105
171
  FileUtils.mv job_dir, 'failed/'
172
+ FileUtils.rm_f 'failed/last' if File.exist?('failed/last')
106
173
  FileUtils.ln_sf "#{File.basename(job_dir)}", "failed/last"
107
174
  else
108
175
  FileUtils.mv job_dir, 'output/'
176
+ FileUtils.rm_f 'output/last' if File.exist?('output/last')
109
177
  FileUtils.ln_sf "#{File.basename(job_dir)}", "output/last"
110
178
  end
111
179
  end
@@ -91,7 +91,6 @@ module PKGWizard
91
91
  fo = File.new(pkg)
92
92
  fsize = File.size(pkg)
93
93
  count = 0
94
- pcount = 0
95
94
  $stdout.sync = true
96
95
  line_reset = "\r\e[0K"
97
96
  res = StreamingUploader.post(
@@ -101,8 +100,7 @@ module PKGWizard
101
100
  count += size
102
101
  per = (100*count)/fsize
103
102
  if per %10 == 0
104
- pcount += 10
105
- print "#{line_reset}Uploading:".ljust(40) + "#{pcount}%"
103
+ print "#{line_reset}Uploading:".ljust(40) + "[#{count}/#{fsize}]"
106
104
  end
107
105
  end
108
106
  puts "#{line_reset}Uploading: #{File.basename(pkg)} ".ljust(40) + "[#{fsize}] [COMPLETE]"
data/lib/pkg-wizard.rb CHANGED
@@ -4,7 +4,7 @@ require 'mixlib/cli'
4
4
 
5
5
  module PKGWizard
6
6
 
7
- VERSION = '0.1.5'
7
+ VERSION = '0.1.6'
8
8
 
9
9
  class Distribution
10
10
  def self.detect
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkg-wizard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Rubio