Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/grss:master commit in: grs/
Date: Wed, 01 Jul 2015 12:23:47
Message-Id: 1435753557.cc5128c7066d712a8f532ce33b6917a265f7c7e0.blueness@gentoo
1 commit: cc5128c7066d712a8f532ce33b6917a265f7c7e0
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 1 12:25:57 2015 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 1 12:25:57 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=cc5128c7
7
8 grs/Interpret.py: remove excessive try-except block.
9
10 grs/Interpret.py | 160 +++++++++++++++++++++++++++----------------------------
11 1 file changed, 78 insertions(+), 82 deletions(-)
12
13 diff --git a/grs/Interpret.py b/grs/Interpret.py
14 index 8cef40e..6525c9e 100644
15 --- a/grs/Interpret.py
16 +++ b/grs/Interpret.py
17 @@ -109,92 +109,88 @@ class Interpret(Daemon):
18 stampit(progress)
19
20 build_script = os.path.join(libdir, 'build')
21 - try:
22 - with open(build_script, 'r') as s:
23 - line_number = 0
24 - for l in s.readlines():
25 - line_number += 1
26 -
27 - # For a release run, execute every line of the build script.
28 - # For an update run, exexute only lines with a leading +.
29 - ignore_stamp = False
30 - m = re.search('^(\+)(.*)$', l)
31 - if m:
32 - # There is a leading +, so remove it and skip if doing an update run
33 - ignore_stamp = self.update_run
34 - l = m.group(2)
35 - else:
36 - # There is no leading +, so skip if this is an update run
37 - if self.update_run:
38 - continue
39 -
40 - progress = os.path.join(tmpdir, '.completed_%02d' % line_number)
41 - if os.path.exists(progress) and not ignore_stamp:
42 + with open(build_script, 'r') as s:
43 + line_number = 0
44 + for l in s.readlines():
45 + line_number += 1
46 +
47 + # For a release run, execute every line of the build script.
48 + # For an update run, exexute only lines with a leading +.
49 + ignore_stamp = False
50 + m = re.search('^(\+)(.*)$', l)
51 + if m:
52 + # There is a leading +, so remove it and skip if doing an update run
53 + ignore_stamp = self.update_run
54 + l = m.group(2)
55 + else:
56 + # There is no leading +, so skip if this is an update run
57 + if self.update_run:
58 continue
59
60 - try:
61 - m = re.search('(\S+)\s+(\S+)', l)
62 - verb = m.group(1)
63 - obj = m.group(2)
64 - except AttributeError:
65 - verb = l.strip()
66 - obj = None
67 + progress = os.path.join(tmpdir, '.completed_%02d' % line_number)
68 + if os.path.exists(progress) and not ignore_stamp:
69 + continue
70 +
71 + try:
72 + m = re.search('(\S+)\s+(\S+)', l)
73 + verb = m.group(1)
74 + obj = m.group(2)
75 + except AttributeError:
76 + verb = l.strip()
77 + obj = None
78
79 - if verb == '':
80 + if verb == '':
81 + stampit(progress)
82 + continue
83 + if verb == 'log':
84 + if smartlog(l, obj):
85 stampit(progress)
86 continue
87 - if verb == 'log':
88 - if smartlog(l, obj):
89 - stampit(progress)
90 - continue
91 - if obj == 'stamp':
92 - lo.log('='*80)
93 - else:
94 - lo.log(obj)
95 - elif verb == 'mount':
96 - if smartlog(l, obj, False):
97 - stampit(progress)
98 - continue
99 - md.mount_all()
100 - elif verb == 'unmount':
101 - if smartlog(l, obj, False):
102 - stampit(progress)
103 - continue
104 - md.umount_all()
105 - elif verb == 'populate':
106 - if smartlog(l, obj):
107 - stampit(progress)
108 - continue
109 - po.populate(cycle=int(obj))
110 - elif verb == 'runscript':
111 - if smartlog(l, obj):
112 - stampit(progress)
113 - continue
114 - ru.runscript(obj)
115 - elif verb == 'clean':
116 - if smartlog(l, obj, False):
117 - stampit(progress)
118 - continue
119 - po.clean()
120 - elif verb == 'kernel':
121 - if smartlog(l, obj, False):
122 - stampit(progress)
123 - continue
124 - ke.kernel()
125 - elif verb == 'tarit':
126 - if smartlog(l, obj, False):
127 - stampit(progress)
128 - continue
129 - bi.tarit()
130 - elif verb == 'hashit':
131 - if smartlog(l, obj, False):
132 - stampit(progress)
133 - continue
134 - bi.hashit()
135 + if obj == 'stamp':
136 + lo.log('='*80)
137 else:
138 - lo.log('Bad command: %s' % l)
139 -
140 - stampit(progress)
141 + lo.log(obj)
142 + elif verb == 'mount':
143 + if smartlog(l, obj, False):
144 + stampit(progress)
145 + continue
146 + md.mount_all()
147 + elif verb == 'unmount':
148 + if smartlog(l, obj, False):
149 + stampit(progress)
150 + continue
151 + md.umount_all()
152 + elif verb == 'populate':
153 + if smartlog(l, obj):
154 + stampit(progress)
155 + continue
156 + po.populate(cycle=int(obj))
157 + elif verb == 'runscript':
158 + if smartlog(l, obj):
159 + stampit(progress)
160 + continue
161 + ru.runscript(obj)
162 + elif verb == 'clean':
163 + if smartlog(l, obj, False):
164 + stampit(progress)
165 + continue
166 + po.clean()
167 + elif verb == 'kernel':
168 + if smartlog(l, obj, False):
169 + stampit(progress)
170 + continue
171 + ke.kernel()
172 + elif verb == 'tarit':
173 + if smartlog(l, obj, False):
174 + stampit(progress)
175 + continue
176 + bi.tarit()
177 + elif verb == 'hashit':
178 + if smartlog(l, obj, False):
179 + stampit(progress)
180 + continue
181 + bi.hashit()
182 + else:
183 + lo.log('Bad command: %s' % l)
184
185 - except FileNotFoundError:
186 - lo.log('Failed to open build script: %s' % build_script)
187 + stampit(progress)