File: debci-job

package info (click to toggle)
debci 3.13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,656 kB
  • sloc: ruby: 6,516; sh: 2,437; javascript: 100; makefile: 92; perl: 11
file content (51 lines) | stat: -rwxr-xr-x 1,431 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/ruby

require 'debci'
require 'debci/job'
require 'thor'

module Debci
  class JobCLI < Thor
    desc 'import STATUS_FILE [STATUS_FILE ...]', 'Import data from status file'
    method_option :remove, type: :boolean, default: false
    method_option :verbose, type: :boolean, default: false
    def import(*status_files)
      status_files.each do |status_file|
        begin
          Debci::Job.import(status_file)
          puts('I: imported %<status_file>s' % { status_file: status_file }) if options { :verbose }
          if options[:remove]
            File.unlink(status_file)
            puts('I: removed %<status_file>s' % { status_file: status_file }) if options { :verbose }
          end
        rescue Debci::Job::InvalidStatusFile => exc
          puts("E: #{exc}")
        end
      end
    end

    desc 'history-json PACKAGE', 'Generate package history in JSON'
    def history_json(pkg)
      history = Debci::Job.history(pkg, suite, arch)
      puts JSON.pretty_generate(history.as_json)
    end

    desc 'latest-json PACKAGE', 'Generate JSON for the most recent test job that has no pin-packages'
    def latest_json(pkg)
      latest = Debci::Job.history(pkg, suite, arch).last
      puts JSON.pretty_generate(latest.as_json)
    end

    no_commands do
      def arch
        Debci.config.arch
      end

      def suite
        Debci.config.suite
      end
    end
  end
end

Debci::JobCLI.start