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

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 715
Merged at revision: 712
Proposed branch: lp:~javier.collado/utah/static_analysis_7
Merge into: lp:utah
Diff against target: 465 lines (+80/-54) (has conflicts)
15 files modified
utah/client/common.py (+9/-4)
utah/client/phoenix.py (+3/-1)
utah/client/result.py (+7/-5)
utah/client/runner.py (+9/-1)
utah/client/state_agent.py (+1/-1)
utah/client/testcase.py (+15/-5)
utah/client/tests/manual_privileges.py (+5/-5)
utah/client/testsuite.py (+1/-3)
utah/config.py (+7/-17)
utah/preseed.py (+2/-2)
utah/provisioning/provisioning.py (+4/-4)
utah/provisioning/vm/libvirtvm.py (+4/-2)
utah/run.py (+9/-0)
utah/timeout.py (+3/-3)
utah/url.py (+1/-1)
Text conflict in utah/client/runner.py
Text conflict in utah/run.py
To merge this branch: bzr merge lp:~javier.collado/utah/static_analysis_7
Reviewer Review Type Date Requested Status
Max Brustkern (community) Needs Information
Joe Talbott (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+129238@code.launchpad.net

Description of the change

Today I used pylint instead of flake8 and found a lot of issues that were not detected previously,
so I decided to fix some of them.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

- There's a bug on line 213 that shouldn't be 'stdout' with quotes which means you shouldn't rename 'stdout' to '_stdout'.

- There's a bug on line 222, that should pass msg into the inner assertion if msg is not None.

- Regarding the relative imports: One of my goals was that the tests and the client be runnable from a local copy of the repository. Can you confirm that both of these cases work as expected with these changes. I am fine with the requirement that both the client and the tests be run from the top-level directory of the branch which means utah resolves to the relative path and doesn't have to be in the python path.

714. By Javier Collado

Fixed use variable, not string ('stdout' -> stdout) as suggested by Joe

715. By Javier Collado

Fixed use hardcoded message by default as suggested by Joe

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

@Joe

Thanks for finding those bugs.

I've run the test cases from the root directory of the branch and from utah/client directory
and they work fine (I believe that nose takes care of setting PYTHONPATH properly).

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

Looks fine to me. I'll let Max comment on the changes in the server code.

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

I've got questions! They may reveal gaps in my understanding of proper python programming.

It seems like in some cases, like config.py and client/testsuite.py, docstrings are being changed from
"""
Do a thing.
"""
to
# Do a thing.
But not everywhere. Is there a reason only some of them are coming up?

What's the deal with cls instead of self? Is that something we should be using elsewhere, or is there some reason it only gets changed in the one instance in preseed.py?

How come in provisioning.py we have _stdout and stderr, but in timeout.py we have stdout and _stderr?

Why do a bunch of parameters change to have underscores before them, but not all of them?

Also, lines 120-132 look like a merge conflict.

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

Okay, I read up on the cls vs. self thing, and I get that now, so nevermind on that one.

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

On Mon, Oct 15, 2012 at 02:12:20PM -0000, Max Brustkern wrote:
> Review: Needs Information
>
> I've got questions! They may reveal gaps in my understanding of proper python programming.
>
> It seems like in some cases, like config.py and client/testsuite.py, docstrings are being changed from
> """
> Do a thing.
> """
> to
> # Do a thing.
> But not everywhere. Is there a reason only some of them are coming up?

I have a bad habit of commenting out large blocks of code by turning
them into strings with """ or '''. Because we're doing in-source
documentation and python convention uses these strings (depending on
where they are located) as documentation. So, in short, comments
should use the comment character '#' and documentation should be in
apparently. I'll leave it to others to argue if comments are
documentation or not. The way I look at it is if your comment is
related to a few lines of code it won't make sense in the on-line
documents.
>
> What's the deal with cls instead of self? Is that something we should be using elsewhere, or is there some reason it only gets changed in the one instance in preseed.py?
>
> How come in provisioning.py we have _stdout and stderr, but in timeout.py we have stdout and _stderr?
>
> Why do a bunch of parameters change to have underscores before them, but not all of them?

I'm used to the convention that a leading underscore means internal use.
Apparently pylint's authors think that prefixing an unused variable with
an underscore is a way to indicate to pylint that we meant to include a
variable that we aren't yet using.

I don't really agree with this and think it makes the code more
confusing.

Joe

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

- Documentation strings

Note that not all strings are documentation strings, in particular (pep257: http://www.python.org/dev/peps/pep-0257/):
---
A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object.
---

This means that strings literals in other locations are string objects that are constructed and then
thrown away. Those strings are the ones that should be marked as comments.

- Leading underscore in variable names

The general convention in python is to use a leading underscore to set private methods and
instance variables, that is, methods that are an implementation detail and shouldn't be accessed
from the outside (even if the language lets you do that).

Another general convention is to use a single underscore as a name for local variables
you don't care about and that can be safely discarded. An extension of that convention
(used by pylint, but maybe not widely adopted by the whole community) is to use variable names
with a leading underscore to state the same while providing a longer name that can be used
for documentation (when you see _stderr, it's clear that stderr is being discarded, when you see
just _, you have have to know the API or look at the documentation).

I don't find the two uses for the underscore confusing for variables because the scopes don't
mix together (instance variables vs. local variables).

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

All right. I like everything except the merge conflict, then.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'utah/client/common.py'
--- utah/client/common.py 2012-10-11 20:42:24 +0000
+++ utah/client/common.py 2012-10-12 09:39:20 +0000
@@ -52,7 +52,7 @@
52CMD_TS_CLEANUP = 'testsuite_cleanup'52CMD_TS_CLEANUP = 'testsuite_cleanup'
5353
5454
55def do_nothing(obj=None):55def do_nothing(_obj=None):
56 """56 """
57 Do nothing method used a placeholder for save_state_callbacks.57 Do nothing method used a placeholder for save_state_callbacks.
58 """58 """
@@ -78,7 +78,7 @@
78 class TimeoutAlarm(Exception):78 class TimeoutAlarm(Exception):
79 pass79 pass
8080
81 def alarm_handler(signum, frame):81 def alarm_handler(_signum, _frame):
82 raise TimeoutAlarm82 raise TimeoutAlarm
8383
84 start_time = datetime.datetime.now()84 start_time = datetime.datetime.now()
@@ -154,7 +154,7 @@
154def get_process_children(pid):154def get_process_children(pid):
155 p = subprocess.Popen('ps --no-headers -o pid --ppid %d' % pid, shell=True,155 p = subprocess.Popen('ps --no-headers -o pid --ppid %d' % pid, shell=True,
156 stdout=subprocess.PIPE, stderr=subprocess.PIPE)156 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
157 stdout, stderr = p.communicate()157 stdout, _stderr = p.communicate()
158158
159 return [int(pid) for pid in stdout.split()]159 return [int(pid) for pid in stdout.split()]
160160
@@ -258,10 +258,15 @@
258 return orig_privs258 return orig_privs
259259
260260
261def gather_artifacts(extras=[], excludes=[]):261def gather_artifacts(extras=None, excludes=None):
262 """262 """
263 Include a set of useful artifacts (i.e. files) for the logs.263 Include a set of useful artifacts (i.e. files) for the logs.
264 """264 """
265 if extras is None:
266 extras = []
267 if excludes is None:
268 excludes = []
269
265 artifacts = ['/var/log/syslog', '/proc/cpuinfo']270 artifacts = ['/var/log/syslog', '/proc/cpuinfo']
266271
267 artifacts += extras272 artifacts += extras
268273
=== modified file 'utah/client/phoenix.py'
--- utah/client/phoenix.py 2012-10-11 20:43:24 +0000
+++ utah/client/phoenix.py 2012-10-12 09:39:20 +0000
@@ -13,9 +13,11 @@
1313
14class Phoenix(object):14class Phoenix(object):
1515
16 def __init__(self, testsuite, directory='.', testcases=['testcase1']):16 def __init__(self, testsuite, directory='.', testcases=None):
17 self.testsuite = testsuite17 self.testsuite = testsuite
18 self.directory = directory18 self.directory = directory
19 if testcases is None:
20 testcases = ['testcase1']
19 self.testcases = testcases21 self.testcases = testcases
2022
21 self.tslist_content = ""23 self.tslist_content = ""
2224
=== modified file 'utah/client/result.py'
--- utah/client/result.py 2012-10-02 15:59:47 +0000
+++ utah/client/result.py 2012-10-12 09:39:20 +0000
@@ -8,14 +8,14 @@
8 )8 )
99
1010
11def get_smoke_data(result):11def get_smoke_data(_result):
12 data = {}12 data = {}
13 data['build_no'] = get_build_number()13 data['build_no'] = get_build_number()
1414
15 return data15 return data
1616
1717
18def get_kernel_sru_data(result):18def get_kernel_sru_data(_result):
19 data = {}19 data = {}
2020
21 return data21 return data
@@ -60,7 +60,7 @@
60 self.failures = 060 self.failures = 0
61 self.passes = 061 self.passes = 0
6262
63 def add_result(self, result, extra_info={}):63 def add_result(self, result, extra_info=None):
64 """64 """
65 Add a result to the object.65 Add a result to the object.
6666
@@ -78,6 +78,9 @@
78 if result is None:78 if result is None:
79 return79 return
8080
81 if extra_info is None:
82 extra_info = {}
83
81 # Add items from extra_info into the result84 # Add items from extra_info into the result
82 if len(extra_info) > 0:85 if len(extra_info) > 0:
83 result['extra_info'] = extra_info86 result['extra_info'] = extra_info
@@ -192,8 +195,7 @@
192195
193196
194def literal_block(dumper, data):197def literal_block(dumper, data):
195 return dumper.represent_scalar('tag:yaml.org,2002:str',198 return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
196 data, style='|')
197yaml.add_representer(LiteralString, literal_block)199yaml.add_representer(LiteralString, literal_block)
198200
199201
200202
=== modified file 'utah/client/runner.py'
--- utah/client/runner.py 2012-10-11 20:42:24 +0000
+++ utah/client/runner.py 2012-10-12 09:39:20 +0000
@@ -1,8 +1,16 @@
1<<<<<<< TREE
1from common import DEFAULT_TSLIST2from common import DEFAULT_TSLIST
2from result import Result3from result import Result
3from testsuite import TestSuite4from testsuite import TestSuite
4from state_agent import StateAgentYAML5from state_agent import StateAgentYAML
5import exceptions6import exceptions
7=======
8from utah.client.common import DEFAULT_TSLIST
9from utah.client.result import Result
10from utah.client.testsuite import TestSuite
11from utah.client.state_agent import StateAgentYAML
12from utah.client import exceptions
13>>>>>>> MERGE-SOURCE
614
7import os15import os
8import shutil16import shutil
@@ -10,7 +18,7 @@
10import urllib18import urllib
11import jsonschema19import jsonschema
1220
13from common import (21from utah.client.common import (
14 MASTER_RUNLIST,22 MASTER_RUNLIST,
15 UTAH_DIR,23 UTAH_DIR,
16 DEFAULT_STATE_FILE,24 DEFAULT_STATE_FILE,
1725
=== modified file 'utah/client/state_agent.py'
--- utah/client/state_agent.py 2012-08-02 18:36:14 +0000
+++ utah/client/state_agent.py 2012-10-12 09:39:20 +0000
@@ -1,7 +1,7 @@
1import os1import os
2import yaml2import yaml
33
4from common import DEFAULT_STATE_FILE, parse_yaml_file4from utah.client.common import DEFAULT_STATE_FILE, parse_yaml_file
55
66
7class StateAgent(object):7class StateAgent(object):
88
=== modified file 'utah/client/testcase.py'
--- utah/client/testcase.py 2012-10-04 15:39:50 +0000
+++ utah/client/testcase.py 2012-10-12 09:39:20 +0000
@@ -3,10 +3,20 @@
3"""3"""
4import jsonschema4import jsonschema
55
6from common import run_cmd, parse_control_file6from utah.client.common import (
7from common import do_nothing7 run_cmd,
8from common import CMD_TC_BUILD, CMD_TC_SETUP, CMD_TC_TEST, CMD_TC_CLEANUP8 parse_control_file,
9from exceptions import MissingFile, ValidationError, MissingData9 do_nothing,
10 CMD_TC_BUILD,
11 CMD_TC_SETUP,
12 CMD_TC_TEST,
13 CMD_TC_CLEANUP,
14 )
15from utah.client.exceptions import (
16 MissingFile,
17 ValidationError,
18 MissingData,
19 )
1020
1121
12class TestCase(object):22class TestCase(object):
@@ -175,7 +185,7 @@
175 or self.dependencies is None185 or self.dependencies is None
176 or self.action is None186 or self.action is None
177 or self.expected_results is None):187 or self.expected_results is None):
178 raise MissingData188 raise MissingData
179189
180 # Return value to indicate whether processing of a TestSuite should190 # Return value to indicate whether processing of a TestSuite should
181 # continue. This is to avoid a shutdown race on reboot cases.191 # continue. This is to avoid a shutdown race on reboot cases.
182192
=== modified file 'utah/client/tests/manual_privileges.py'
--- utah/client/tests/manual_privileges.py 2012-08-08 12:58:52 +0000
+++ utah/client/tests/manual_privileges.py 2012-10-12 09:39:20 +0000
@@ -64,7 +64,7 @@
64 stderr=subprocess.PIPE64 stderr=subprocess.PIPE
65 )65 )
6666
67 (stdout, stderr) = proc.communicate()67 (stdout, _stderr) = proc.communicate()
6868
69 if not quiet:69 if not quiet:
70 print("{}:\n{}".format(cmd, stdout))70 print("{}:\n{}".format(cmd, stdout))
@@ -74,8 +74,8 @@
74 proc = subprocess.Popen(['ls', '-al', filename], stdout=subprocess.PIPE,74 proc = subprocess.Popen(['ls', '-al', filename], stdout=subprocess.PIPE,
75 stderr=subprocess.PIPE)75 stderr=subprocess.PIPE)
7676
77 (stdout, stderr) = proc.communicate()77 stdout, _stderr = proc.communicate()
78 print("{}: {}".format(filename, 'stdout'))78 print("{}: {}".format(filename, stdout))
7979
8080
81def get_privs():81def get_privs():
@@ -91,8 +91,8 @@
9191
92class baseTestPriv(unittest.TestCase):92class baseTestPriv(unittest.TestCase):
9393
94 def assertRoot(self, msg=None):94 def assertRoot(self, msg="Must be root"):
95 self.assertEqual(os.geteuid(), 0, msg="Must be root")95 self.assertEqual(os.geteuid(), 0, msg=msg)
9696
97 def assertPrivs(self, privs, msg=None):97 def assertPrivs(self, privs, msg=None):
98 # Only check privileges passed in98 # Only check privileges passed in
9999
=== modified file 'utah/client/testsuite.py'
--- utah/client/testsuite.py 2012-08-28 11:22:41 +0000
+++ utah/client/testsuite.py 2012-10-12 09:39:20 +0000
@@ -86,9 +86,7 @@
86 os.mkdir(self.path)86 os.mkdir(self.path)
8787
88 os.chdir(self.path)88 os.chdir(self.path)
89 """89 # Build a TestSuite from a control file's data.
90 Build a TestSuite from a control file's data.
91 """
92 control_file = os.path.join(name, control_file)90 control_file = os.path.join(name, control_file)
9391
94 if os.path.exists(control_file):92 if os.path.exists(control_file):
9593
=== modified file 'utah/config.py'
--- utah/config.py 2012-10-11 10:59:45 +0000
+++ utah/config.py 2012-10-12 09:39:20 +0000
@@ -54,10 +54,8 @@
54 template=None,54 template=None,
55)55)
5656
57"""57# These depend on the local user/path, and need to be filtered out
58These depend on the local user/path, and need to be filtered out of the config58# of the config file created at package build time.
59file created at package build time.
60"""
61LOCALDEFAULTS = dict(59LOCALDEFAULTS = dict(
62 bridge=getbridge(),60 bridge=getbridge(),
63 hostname=socket.gethostname(),61 hostname=socket.gethostname(),
@@ -68,9 +66,7 @@
68 vmpath=os.path.join(os.path.expanduser('~'), 'vm'),66 vmpath=os.path.join(os.path.expanduser('~'), 'vm'),
69)67)
7068
71"""69# These depend on other config options, so they're added last.
72These depend on other config options, so they're added last.
73"""
74LOCALDEFAULTS['logfile'] = os.path.join(DEFAULTS['logpath'],70LOCALDEFAULTS['logfile'] = os.path.join(DEFAULTS['logpath'],
75 LOCALDEFAULTS['hostname'] + '.log')71 LOCALDEFAULTS['hostname'] + '.log')
76LOCALDEFAULTS['debuglog'] = os.path.join(DEFAULTS['logpath'],72LOCALDEFAULTS['debuglog'] = os.path.join(DEFAULTS['logpath'],
@@ -81,9 +77,7 @@
81CONFIG = {}77CONFIG = {}
82CONFIG.update(DEFAULTS)78CONFIG.update(DEFAULTS)
8379
84"""80# Process config files.
85Process config files.
86"""
87files = ['/etc/utah/config', '~/.utah/config', os.getenv('UTAH_CONFIG_FILE')]81files = ['/etc/utah/config', '~/.utah/config', os.getenv('UTAH_CONFIG_FILE')]
88for conffile in files:82for conffile in files:
89 if conffile is not None:83 if conffile is not None:
@@ -96,10 +90,8 @@
9690
97def dumpdefaults(build=False):91def dumpdefaults(build=False):
98 if build:92 if build:
99 """93 # Remove user and path dependent items so they won't get set on the
100 Remove user and path dependent items so they won't get set on the94 # machine that builds the package.
101 machine that builds the package.
102 """
103 for item in LOCALDEFAULTS:95 for item in LOCALDEFAULTS:
104 DEFAULTS.pop(item)96 DEFAULTS.pop(item)
105 return json.dumps(DEFAULTS, sort_keys=True, indent=4)97 return json.dumps(DEFAULTS, sort_keys=True, indent=4)
@@ -110,7 +102,5 @@
110102
111103
112if __name__ == '__main__':104if __name__ == '__main__':
113 """105 # If we're not told otherwise, assume this is the package build.
114 If we're not told otherwise, assume this is the package build.
115 """
116 print(dumpdefaults(build=True))106 print(dumpdefaults(build=True))
117107
=== modified file 'utah/preseed.py'
--- utah/preseed.py 2012-10-08 13:25:41 +0000
+++ utah/preseed.py 2012-10-12 09:39:20 +0000
@@ -153,7 +153,7 @@
153 return '<{}: {!r}>'.format(self.__class__.__name__, str(self))153 return '<{}: {!r}>'.format(self.__class__.__name__, str(self))
154154
155 @classmethod155 @classmethod
156 def new(self, parent, lines):156 def new(cls, parent, lines):
157 """157 """
158 Create new section subclass based on the lines in the preseed158 Create new section subclass based on the lines in the preseed
159 """159 """
@@ -222,7 +222,7 @@
222 self.name = name222 self.name = name
223 self.obj_name = '_{}'.format(name)223 self.obj_name = '_{}'.format(name)
224224
225 def __get__(self, obj, type=None):225 def __get__(self, obj, owner=None):
226 if not hasattr(obj, self.obj_name):226 if not hasattr(obj, self.obj_name):
227 self.__set__(obj, '')227 self.__set__(obj, '')
228 value = getattr(obj, self.obj_name)228 value = getattr(obj, self.obj_name)
229229
=== modified file 'utah/provisioning/provisioning.py'
--- utah/provisioning/provisioning.py 2012-10-11 10:59:45 +0000
+++ utah/provisioning/provisioning.py 2012-10-12 09:39:20 +0000
@@ -324,7 +324,7 @@
324 'done ; '324 'done ; '
325 'gdebi -n -q {}'325 'gdebi -n -q {}'
326 .format(remote_deb))326 .format(remote_deb))
327 returncode, stdout, stderr = self.run(install_command, root=True)327 returncode, _stdout, stderr = self.run(install_command, root=True)
328 if (returncode != 0 or328 if (returncode != 0 or
329 re.search(r'script returned error exit status \d+',329 re.search(r'script returned error exit status \d+',
330 stderr)):330 stderr)):
@@ -382,7 +382,7 @@
382 """382 """
383 self._unimplemented(sys._getframe().f_code.co_name)383 self._unimplemented(sys._getframe().f_code.co_name)
384384
385 def stop(self, force=False):385 def stop(self, _force=False):
386 """386 """
387 Stop the machine, and set active to False.387 Stop the machine, and set active to False.
388 Graceful shutdown should be attempted if supported and force is False.388 Graceful shutdown should be attempted if supported and force is False.
@@ -391,7 +391,7 @@
391 """391 """
392 self._unimplemented(sys._getframe().f_code.co_name)392 self._unimplemented(sys._getframe().f_code.co_name)
393393
394 def uploadfiles(self, files, target=os.path.normpath('/tmp/')):394 def uploadfiles(self, _files, _target=os.path.normpath('/tmp/')):
395 """395 """
396 Upload a list of local files to a target on the machine and return396 Upload a list of local files to a target on the machine and return
397 True if all uploads succeed.397 True if all uploads succeed.
@@ -489,7 +489,7 @@
489 ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())489 ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
490 self.ssh_client = ssh_client490 self.ssh_client = ssh_client
491491
492 def run(self, command, quiet=None, root=False, timeout=None):492 def run(self, command, _quiet=None, root=False, timeout=None):
493 """493 """
494 Run a command using ssh.494 Run a command using ssh.
495 """495 """
496496
=== modified file 'utah/provisioning/vm/libvirtvm.py'
--- utah/provisioning/vm/libvirtvm.py 2012-10-10 08:49:03 +0000
+++ utah/provisioning/vm/libvirtvm.py 2012-10-12 09:39:20 +0000
@@ -121,7 +121,7 @@
121 self.vm.shutdown()121 self.vm.shutdown()
122 self.active = False122 self.active = False
123123
124 def libvirterrorhandler(self, context, err):124 def libvirterrorhandler(self, _context, err):
125 """125 """
126 Log libvirt errors instead of sending them directly to the console.126 Log libvirt errors instead of sending them directly to the console.
127 """127 """
@@ -348,7 +348,7 @@
348 """348 """
349 def __init__(self, arch=None, boot=None, diskbus=None, disksizes=None,349 def __init__(self, arch=None, boot=None, diskbus=None, disksizes=None,
350 emulator=None, image=None, initrd=None, installtype=None,350 emulator=None, image=None, initrd=None, installtype=None,
351 kernel=None, machineid=None, macs=[], name=None,351 kernel=None, machineid=None, macs=None, name=None,
352 prefix='utah', preseed=None, series=None, xml=None,352 prefix='utah', preseed=None, series=None, xml=None,
353 *args, **kw):353 *args, **kw):
354 # Make sure that no other virtualization solutions are running354 # Make sure that no other virtualization solutions are running
@@ -413,6 +413,8 @@
413 if self.domaintype == 'qemu':413 if self.domaintype == 'qemu':
414 self.logger.debug('Raising boot timeout for qemu domain')414 self.logger.debug('Raising boot timeout for qemu domain')
415 self.boottimeout *= 4415 self.boottimeout *= 4
416 if macs is None:
417 macs = []
416 self.macs = macs418 self.macs = macs
417 self.xml = xml419 self.xml = xml
418 self.dircheck()420 self.dircheck()
419421
=== modified file 'utah/run.py'
--- utah/run.py 2012-10-10 09:46:47 +0000
+++ utah/run.py 2012-10-12 09:39:20 +0000
@@ -40,9 +40,18 @@
40 options = ' -r /tmp/' + os.path.basename(locallist)40 options = ' -r /tmp/' + os.path.basename(locallist)
41 utah_command = 'utah' + extraopts + options41 utah_command = 'utah' + extraopts + options
42 try:42 try:
43<<<<<<< TREE
43 returncode, stdout, stderr = machine.run(utah_command)44 returncode, stdout, stderr = machine.run(utah_command)
44 # TODO: Decide which returncode means utah client failure45 # TODO: Decide which returncode means utah client failure
45 # and which one means test case failure46 # and which one means test case failure
47=======
48 returncode, stdout, _stderr = machine.run(utah_command)
49 if returncode != 0:
50 machine.logger.error('utah failed with return code: {}\n'
51 .format(returncode))
52 exitstatus = 1
53 break
54>>>>>>> MERGE-SOURCE
46 except UTAHException as error:55 except UTAHException as error:
47 machine.logger.error('Failed to run test: ' + str(error))56 machine.logger.error('Failed to run test: ' + str(error))
48 exitstatus = 157 exitstatus = 1
4958
=== modified file 'utah/timeout.py'
--- utah/timeout.py 2012-08-30 09:18:10 +0000
+++ utah/timeout.py 2012-10-12 09:39:20 +0000
@@ -27,7 +27,7 @@
27 if command is None:27 if command is None:
28 return28 return
2929
30 def alarm_handler(signum, frame):30 def alarm_handler(_signum, _frame):
31 raise UTAHTimeout31 raise UTAHTimeout
3232
33 if timeout != 0:33 if timeout != 0:
@@ -66,7 +66,7 @@
66 class TimeoutAlarm(Exception):66 class TimeoutAlarm(Exception):
67 pass67 pass
6868
69 def alarm_handler(signum, frame):69 def alarm_handler(_signum, _frame):
70 raise TimeoutAlarm70 raise TimeoutAlarm
7171
72 if timeout != 0:72 if timeout != 0:
@@ -106,6 +106,6 @@
106 """106 """
107 p = subprocess.Popen('ps --no-headers -o pid --ppid %d' % pid, shell=True,107 p = subprocess.Popen('ps --no-headers -o pid --ppid %d' % pid, shell=True,
108 stdout=subprocess.PIPE, stderr=subprocess.PIPE)108 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
109 stdout, stderr = p.communicate()109 stdout, _stderr = p.communicate()
110110
111 return [int(pid) for pid in stdout.split()]111 return [int(pid) for pid in stdout.split()]
112112
=== modified file 'utah/url.py'
--- utah/url.py 2012-08-08 15:11:52 +0000
+++ utah/url.py 2012-10-12 09:39:20 +0000
@@ -56,7 +56,7 @@
56 Check if local file exists56 Check if local file exists
57 """57 """
58 # Based on urllib.URLopener.open_local_file implementation58 # Based on urllib.URLopener.open_local_file implementation
59 host, filename = urllib.splithost(url)59 _host, filename = urllib.splithost(url)
60 path = os.path.abspath(urllib.url2pathname(filename))60 path = os.path.abspath(urllib.url2pathname(filename))
6161
62 if not os.path.exists(path):62 if not os.path.exists(path):

Subscribers

People subscribed via source and target branches