Merge lp:~javier.collado/utah/static_analysis_5 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 678
Merged at revision: 670
Proposed branch: lp:~javier.collado/utah/static_analysis_5
Merge into: lp:utah
Diff against target: 350 lines (+46/-31)
11 files modified
docs/source/conf.py (+15/-11)
examples/run_test_cobbler.py (+0/-1)
examples/run_utah_tests.py (+1/-1)
utah/client/common.py (+10/-3)
utah/client/result.py (+8/-2)
utah/client/runner.py (+3/-2)
utah/client/tests/test_state_agent.py (+2/-1)
utah/iso.py (+6/-4)
utah/provisioning/baremetal/cobbler.py (+0/-1)
utah/provisioning/vm/libvirtvm.py (+0/-4)
utah/timeout.py (+1/-1)
To merge this branch: bzr merge lp:~javier.collado/utah/static_analysis_5
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+122010@code.launchpad.net

Description of the change

Static analysis changes.

The ones that I'd like you to specially take a look at are:
- Max: rev. 669
- Joe: rev. 668

To post a comment you must log in.
678. By Javier Collado

Removed a few NOQA comments that were not used properly

Revision history for this message
Max Brustkern (nuclearbob) wrote :

The original intent of that was to allow commands to be run as a string or a list, but if nothing is currently using that option, removing it should be fine.

Revision history for this message
Javier Collado (javier.collado) wrote :

I removed it not only because commandstring variable isn't being used, but also because _getcommandargs still is able to concatenate the strings in an array:

        if isinstance(command, basestring):
            args.append(command)
        else:
            args.extend(command)

so that functionality should be still available.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

That's super. Looks good to me.

Revision history for this message
Javier Collado (javier.collado) wrote :

Joe, any comment from you? As a reminder, I wanted you to take a look a this:

26 + # TBD: Use url and token
227 + # url = self.publish_url
228 + # token = self.publish_token

I commented the variables since they don't seem to be used for anything. I guess the implementation isn't yet finished, but I wanted to check with you just in case this is some other thing that has to be addressed.

Revision history for this message
Joe Talbott (joetalbott) wrote :

Those are for pending work so commenting them out is fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/source/conf.py'
2--- docs/source/conf.py 2012-08-20 11:33:46 +0000
3+++ docs/source/conf.py 2012-08-30 09:20:36 +0000
4@@ -3,7 +3,8 @@
5 # UTAH documentation build configuration file, created by
6 # sphinx-quickstart on Tue Aug 7 18:05:11 2012.
7 #
8-# This file is execfile()d with the current directory set to its containing dir.
9+# This file is execfile()d with the current directory set to its containing
10+# dir.
11 #
12 # Note that not all possible configuration values are present in this
13 # autogenerated file.
14@@ -11,7 +12,8 @@
15 # All configuration values have a default; values that are commented out
16 # serve to show the default.
17
18-import sys, os
19+import sys
20+import os
21
22 # If extensions (or modules to document with autodoc) are in another directory,
23 # add these directories to sys.path here. If the directory is relative to the
24@@ -35,13 +37,13 @@
25 'apt', 'apt.cache'):
26 sys.modules[mod_name] = Mock(mod_name, (type,), {})
27
28-# -- General configuration -----------------------------------------------------
29+# -- General configuration ----------------------------------------------------
30
31 # If your documentation needs a minimal Sphinx version, state it here.
32 #needs_sphinx = '1.0'
33
34-# Add any Sphinx extension module names here, as strings. They can be extensions
35-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
36+# Add any Sphinx extension module names here, as strings. They can be
37+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
38 extensions = ['sphinx.ext.autodoc']
39
40 # Add any paths that contain templates here, relative to this directory.
41@@ -83,7 +85,8 @@
42 # directories to ignore when looking for source files.
43 exclude_patterns = []
44
45-# The reST default role (used for this markup: `text`) to use for all documents.
46+# The reST default role (used for this markup: `text`) to use for all
47+# documents.
48 #default_role = None
49
50 # If true, '()' will be appended to :func: etc. cross-reference text.
51@@ -104,7 +107,7 @@
52 #modindex_common_prefix = []
53
54
55-# -- Options for HTML output ---------------------------------------------------
56+# -- Options for HTML output --------------------------------------------------
57
58 # The theme to use for HTML and HTML Help pages. See the documentation for
59 # a list of builtin themes.
60@@ -184,7 +187,7 @@
61 htmlhelp_basename = 'UTAHdoc'
62
63
64-# -- Options for LaTeX output --------------------------------------------------
65+# -- Options for LaTeX output -------------------------------------------------
66
67 latex_elements = {
68 # The paper size ('letterpaper' or 'a4paper').
69@@ -198,7 +201,8 @@
70 }
71
72 # Grouping the document tree into LaTeX files. List of tuples
73-# (source start file, target name, title, author, documentclass [howto/manual]).
74+# (source start file, target name, title, author,
75+# documentclass [howto/manual]).
76 latex_documents = [
77 ('index', 'UTAH.tex', u'UTAH Documentation',
78 u'Canonical Ltd', 'manual'),
79@@ -225,7 +229,7 @@
80 #latex_domain_indices = True
81
82
83-# -- Options for manual page output --------------------------------------------
84+# -- Options for manual page output -------------------------------------------
85
86 # One entry per manual page. List of tuples
87 # (source start file, name, description, authors, manual section).
88@@ -238,7 +242,7 @@
89 #man_show_urls = False
90
91
92-# -- Options for Texinfo output ------------------------------------------------
93+# -- Options for Texinfo output -----------------------------------------------
94
95 # Grouping the document tree into Texinfo files. List of tuples
96 # (source start file, target name, title, author,
97
98=== modified file 'examples/run_test_cobbler.py'
99--- examples/run_test_cobbler.py 2012-08-28 15:35:55 +0000
100+++ examples/run_test_cobbler.py 2012-08-30 09:20:36 +0000
101@@ -5,7 +5,6 @@
102
103 from utah.exceptions import UTAHException
104 from utah.group import check_user_group, print_group_error_message
105-from utah.provisioning.baremetal.cobbler import CobblerMachine
106 from utah.provisioning.inventory.sqlite import ManualCobblerSQLiteInventory
107 from utah.run import run_tests
108 from utah.url import url_argument
109
110=== modified file 'examples/run_utah_tests.py'
111--- examples/run_utah_tests.py 2012-08-14 15:42:17 +0000
112+++ examples/run_utah_tests.py 2012-08-30 09:20:36 +0000
113@@ -97,7 +97,7 @@
114
115 if __name__ == '__main__':
116 try:
117- if type( config.jobtimeout) == int:
118+ if type(config.jobtimeout) == int:
119 try:
120 timeout(config.jobtimeout, run_utah_tests)
121 except UTAHTimeout:
122
123=== modified file 'utah/client/common.py'
124--- utah/client/common.py 2012-08-21 15:25:08 +0000
125+++ utah/client/common.py 2012-08-30 09:20:36 +0000
126@@ -57,9 +57,10 @@
127 """
128 pass
129
130+
131 # Inspired by:
132 # http://stackoverflow.com/a/3326559
133-def run_cmd(command, cwd=None, timeout=0, cmd_type=CMD_TC_TEST): # NOQA
134+def run_cmd(command, cwd=None, timeout=0, cmd_type=CMD_TC_TEST):
135
136 if command is None:
137 return
138@@ -115,9 +116,11 @@
139 cmd_type=cmd_type,
140 )
141
142+
143 # TODO: it might make sense to have a result object that keeps track of
144 # test pass, fail, error and serializes it's data.
145-def make_result(command, retcode, stdout='', stderr='', start_time='', time_delta='', cmd_type=CMD_TC_TEST): # NOQA
146+def make_result(command, retcode, stdout='', stderr='', start_time='',
147+ time_delta='', cmd_type=CMD_TC_TEST):
148 """
149 Make a result dictionary.
150 """
151@@ -296,6 +299,7 @@
152
153 return retval
154
155+
156 def get_arch():
157 """
158 The host's architecture (i.e. i386, amd64, etc.)
159@@ -305,16 +309,18 @@
160 arch = {
161 'x86_64': 'amd64',
162 'x86': 'i386',
163- }.get(uname[5]) # 5 == processor
164+ }.get(uname[5]) # 5 == processor
165
166 return arch
167
168+
169 def get_release():
170 """
171 The host's release name (i.e. precise, quantal, etc.)
172 """
173 return platform.dist()[2]
174
175+
176 def get_api_config():
177 """
178 Parse the client configuration file for API configuration data.
179@@ -328,6 +334,7 @@
180
181 return data['API']
182
183+
184 def get_build_number():
185 host_info = get_host_info()
186 pattern = re.compile('.*\(([0-9.]+)\)$')
187
188=== modified file 'utah/client/result.py'
189--- utah/client/result.py 2012-08-28 04:08:53 +0000
190+++ utah/client/result.py 2012-08-30 09:20:36 +0000
191@@ -7,17 +7,20 @@
192 get_build_number,
193 )
194
195+
196 def get_smoke_data(result):
197 data = {}
198 data['build_no'] = get_build_number()
199
200 return data
201
202+
203 def get_kernel_sru_data(result):
204 data = {}
205
206 return data
207
208+
209 # XXX: this logic should probably be moved into the __init__ method
210 # of the result object since there will be one result object per
211 # master.run
212@@ -35,6 +38,7 @@
213 if publish_type and publish_type in type_map.iterkeys():
214 return type_map[publish_type](result)
215
216+
217 class Result(object):
218 """
219 Result collection class.
220@@ -147,8 +151,9 @@
221 return len(self.results)
222
223 def publish_results(self):
224- url = self.publish_url
225- token = self.publish_token
226+ # TBD: Use url and token
227+ # url = self.publish_url
228+ # token = self.publish_token
229
230 create_payload(self)
231
232@@ -213,6 +218,7 @@
233
234 return status
235
236+
237 class ResultJSON(Result):
238 def result(self, verbose=False):
239
240
241=== modified file 'utah/client/runner.py'
242--- utah/client/runner.py 2012-08-28 11:22:41 +0000
243+++ utah/client/runner.py 2012-08-30 09:20:36 +0000
244@@ -81,7 +81,7 @@
245 'enum': ['smoke', 'kernel-sru', 'bootspeed', 'upgrade'],
246 },
247 "publish": {
248- 'type' : 'object',
249+ 'type': 'object',
250 'properties': {
251 "url": {
252 "type": "string",
253@@ -396,7 +396,8 @@
254 os.mkdir(name)
255
256 if name not in self.fetched_suites:
257- self.result.add_result(run_cmd(fetch_cmd, cwd=name, cmd_type=CMD_TS_FETCH))
258+ self.result.add_result(run_cmd(fetch_cmd, cwd=name,
259+ cmd_type=CMD_TS_FETCH))
260 self.fetched_suites.append(name)
261
262 # If fetch_cmd failed move on to the next testsuite.
263
264=== modified file 'utah/client/tests/test_state_agent.py'
265--- utah/client/tests/test_state_agent.py 2012-08-08 16:17:12 +0000
266+++ utah/client/tests/test_state_agent.py 2012-08-30 09:20:36 +0000
267@@ -145,7 +145,8 @@
268 # Need to set up utah_tests since we're simulating a restart
269 test_src = os.path.join(get_module_path(), 'client',
270 'examples', 'utah_tests')
271- test_dir = os.path.join(UTAH_DIR, 'testsuites', 'utah_tests', 'utah_tests')
272+ test_dir = os.path.join(UTAH_DIR, 'testsuites',
273+ 'utah_tests', 'utah_tests')
274 if not os.path.exists(test_dir):
275 shutil.copytree(test_src, test_dir)
276
277
278=== modified file 'utah/iso.py'
279--- utah/iso.py 2012-08-29 12:39:17 +0000
280+++ utah/iso.py 2012-08-30 09:20:36 +0000
281@@ -123,7 +123,8 @@
282 self.logger = logger
283 if image.startswith('~'):
284 path = os.path.expanduser(image)
285- self.logger.debug('Rewriting ~-based path: ' + image + ' to: ' + path)
286+ self.logger.debug('Rewriting ~-based path: ' + image +
287+ ' to: ' + path)
288 else:
289 path = image
290
291@@ -228,10 +229,12 @@
292 return listfiles(self.image, self.logger.debug, returnlist=returnlist)
293
294 def getrealfile(self, filename, outdir=None):
295- return getrealfile(self.image, filename, outdir=outdir, logmethod=self.logger.debug)
296+ return getrealfile(self.image, filename, outdir=outdir,
297+ logmethod=self.logger.debug)
298
299 def extract(self, filename, outdir=None, outfile=None, **kw):
300- return extract(self.image, filename, outdir, outfile, logmethod=self.logger.debug, **kw)
301+ return extract(self.image, filename, outdir, outfile,
302+ logmethod=self.logger.debug, **kw)
303
304 def dump(self, filename, **kw):
305 return dump(self.image, filename, logmethod=self.logger.debug, **kw)
306@@ -239,4 +242,3 @@
307 def extractall(self):
308 for myfile in self.listfiles(returnlist=True):
309 self.extract(myfile)
310-
311
312=== modified file 'utah/provisioning/baremetal/cobbler.py'
313--- utah/provisioning/baremetal/cobbler.py 2012-08-24 18:26:16 +0000
314+++ utah/provisioning/baremetal/cobbler.py 2012-08-30 09:20:36 +0000
315@@ -7,7 +7,6 @@
316 import tempfile
317 import time
318
319-import utah
320 from utah import config
321 from utah.provisioning.provisioning import (
322 CustomInstallMixin,
323
324=== modified file 'utah/provisioning/vm/libvirtvm.py'
325--- utah/provisioning/vm/libvirtvm.py 2012-08-24 18:26:16 +0000
326+++ utah/provisioning/vm/libvirtvm.py 2012-08-30 09:20:36 +0000
327@@ -312,10 +312,6 @@
328 """
329 if quiet is None:
330 quiet = not self.debug
331- if isinstance(command, basestring):
332- commandstring = command
333- else:
334- commandstring = ' '.join(command)
335 self.activecheck()
336 args = self._getcommandargs(command=command, quiet=quiet,
337 root=root, timeout=timeout)
338
339=== modified file 'utah/timeout.py'
340--- utah/timeout.py 2012-08-22 15:20:25 +0000
341+++ utah/timeout.py 2012-08-30 09:20:36 +0000
342@@ -18,7 +18,7 @@
343 # Mostly pulled from utah/client/common.py
344 # Inspired by:
345 # http://stackoverflow.com/a/3326559
346-def timeout(timeout, command, *args, **kw): # NOQA
347+def timeout(timeout, command, *args, **kw):
348 """
349 Run command with all other arguments for up to timeout seconds, after with
350 a UTAHTimeout exception is returned.

Subscribers

People subscribed via source and target branches