~skss/live-usb-install/live-usb-install

« back to all changes in this revision

Viewing changes to tools/distributions.py

  • Committer: Krasimir Stefanov
  • Date: 2010-12-08 13:56:49 UTC
  • Revision ID: lokiisyourmaster@gmail.com-20101208135649-qvtp2n4zw07oqu7h
2.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
import os
 
3
import sys
 
4
import glob
 
5
import re
 
6
import ConfigParser
 
7
 
 
8
if len(sys.argv) == 2:
 
9
        if sys.argv[1] == '-d':
 
10
                distributions = []
 
11
                files = glob.glob('../live-usb-install/presets/*/')
 
12
                for filename in files:
 
13
                        if os.path.isdir(filename):
 
14
                                m = re.search('live-usb-install/presets/(.*?)/',filename)
 
15
                                distributions.append(m.group(1))
 
16
 
 
17
 
 
18
                distributions.sort()
 
19
                print len(distributions)
 
20
        
 
21
        elif sys.argv[1] == '-v':
 
22
                versions = []
 
23
                files = glob.glob('../live-usb-install/presets/*/*/*')
 
24
                for filename in files:
 
25
                        if filename.endswith("info.txt"):
 
26
                                m = re.search('live-usb-install/presets/(.*?)/(.*?)/info.txt',filename)
 
27
                                info_path = os.path.abspath(filename)
 
28
                
 
29
                                versions.append(m.group(1)+' - '+m.group(2))
 
30
                
 
31
                print len(versions)
 
32
                
 
33
        elif sys.argv[1] == '-dl':
 
34
                distributions = []
 
35
                files = glob.glob('../live-usb-install/presets/*/')
 
36
                for filename in files:
 
37
                        if os.path.isdir(filename):
 
38
                                m = re.search('live-usb-install/presets/(.*?)/',filename)
 
39
                                distributions.append(m.group(1))
 
40
 
 
41
 
 
42
                distributions.sort()
 
43
                for name in distributions:
 
44
                        print ' -',name
 
45
        
 
46
        elif sys.argv[1] == '-vl':
 
47
                versions = []
 
48
                files = glob.glob('../live-usb-install/presets/*/*/*')
 
49
                for filename in files:
 
50
                        if filename.endswith("info.txt"):
 
51
                                m = re.search('live-usb-install/presets/(.*?)/(.*?)/info.txt',filename)
 
52
                                info_path = os.path.abspath(filename)
 
53
                
 
54
                                versions.append(m.group(1)+' - '+m.group(2))
 
55
                
 
56
                for name in versions:
 
57
                        print name
 
58
else:
 
59
        print "Usage: distributions.py [OPTIONS]"
 
60
        print "  -d     Show distributions count"
 
61
        print "  -dl    Show distributions list"
 
62
        print "  -v     Show versions count"
 
63
        print "  -vl    Show versions list"
 
64
 
 
65