~roadmr/ubuntu/oneiric/checkbox/fix-662322-in-0.12.9

« back to all changes in this revision

Viewing changes to scripts/optical_detect

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Manrique, Marc Tardif, Chad A. Davis, Barry Warsaw
  • Date: 2011-07-01 11:37:27 UTC
  • Revision ID: james.westby@ubuntu.com-20110701113727-k4pekmtyr7v2i6le
Tags: 0.12.3
[ Marc Tardif ]
* Only reading CHECKBOX_* environment variables in config (LP: #802458)
* Imported scripts and jobs from Platform Services.

[Chad A. Davis]
* Switch to dh_python2 and debhelper7 (LP: #788514)

[Barry Warsaw]
* Fix checkbox_clean.run() to ignore missing executables, as is the case
  in a fresh checkout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import os
 
4
import re
 
5
import sys
 
6
 
 
7
 
 
8
def main(args):
 
9
    line_pattern = r"\s*(\d+)\s+dev='([^']+)'" \
 
10
        "\s+([wr-]{6})\s:\s'([^']+)'\s'([^']+)'"
 
11
    line_regex = re.compile(line_pattern)
 
12
 
 
13
    count = 0
 
14
    command = "wodim --devices"
 
15
    for line in os.popen(command).readlines():
 
16
        match = re.match(line_regex, line)
 
17
        if match:
 
18
            count += 1
 
19
            print match.group(4), match.group(5)
 
20
 
 
21
    if not count:
 
22
        print "None."
 
23
        return 1
 
24
 
 
25
    return 0
 
26
 
 
27
 
 
28
if __name__ == "__main__":
 
29
    sys.exit(main(sys.argv[1:]))