Merge lp://staging/~james-w/pkgme/further-test-fixes into lp://staging/pkgme

Proposed by James Westby
Status: Merged
Approved by: Barry Warsaw
Approved revision: 44
Merged at revision: 47
Proposed branch: lp://staging/~james-w/pkgme/further-test-fixes
Merge into: lp://staging/pkgme
Prerequisite: lp://staging/~james-w/pkgme/add-docs
Diff against target: 116 lines (+36/-16)
3 files modified
pkgme/backend.py (+15/-6)
pkgme/project_info.py (+19/-8)
pkgme/tests/test_vala_backend.py (+2/-2)
To merge this branch: bzr merge lp://staging/~james-w/pkgme/further-test-fixes
Reviewer Review Type Date Requested Status
Barry Warsaw (community) Approve
Review via email: mp+46419@code.staging.launchpad.net

Description of the change

Hi,

Here are some further improvements that prevented me from running
some of the tests, or helped me diagnose those problems.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :
Download full text (5.1 KiB)

 review approve
 merge approve

=== modified file 'pkgme/backend.py'
--- pkgme/backend.py 2010-12-18 14:55:00 +0000
+++ pkgme/backend.py 2011-01-16 19:09:53 +0000
> @@ -1,3 +1,4 @@
> +import errno
> import os
> import sys
> import subprocess
> @@ -16,10 +17,10 @@
>
>
> def get_backend_dir(underunder_file, backend):
> - backend_dir = os.path.normpath(
> + backend_dir = os.path.abspath(os.path.normpath(

Only abspath() should be necessary, as it calls normpath() on its return
value. See Python's Lib/os/posixpath.py.

> os.path.join(
> os.path.dirname(underunder_file), os.pardir,
> - 'backends', backend))
> + 'backends', backend)))
> # When 'python setup.py test' is run with virtualenv, backend_dir will not
> # point to the right place. It will point into the
> # build/lib.{platform}-{version} directory and that cannot be used as a
> @@ -114,12 +115,19 @@
> self.basepath = basepath
>
> def want(self, path):
> - script_path = os.path.join(self.basepath, self.WANT_SCRIPT_NAME)
> + script_path = os.path.join(
> + os.path.abspath(self.basepath), self.WANT_SCRIPT_NAME)
> if os.path.exists(script_path):
> - proc = subprocess.Popen(
> - [script_path], stdout=subprocess.PIPE,
> - stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
> - cwd=path)
> + try:
> + proc = subprocess.Popen(
> + [script_path], stdout=subprocess.PIPE,
> + stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
> + cwd=path)
> + except OSError, e:

Probably should use "except OSError as e" for forward compatibility. (We only
have to support >=Python 2.6, right?)

> + if e.errno == errno.ENOENT:
> + raise ExternalHelperFailed(
> + "%s does not exist" % script_path)
> + raise
> out, ignore = proc.communicate()
> if proc.returncode != 0:
> # TODO: some info on the failure
> @@ -216,6 +224,7 @@
> backends = []
> names = set()
> for path in self.paths:
> + path = os.path.abspath(path)
> if not os.path.isdir(path):
> continue
> fnames = os.listdir(path)

=== modified file 'pkgme/project_info.py'
--- pkgme/project_info.py 2010-11-10 00:44:43 +0000
+++ pkgme/project_info.py 2011-01-16 19:09:53 +0000
> @@ -1,3 +1,4 @@
> +import errno
> import json
> import os
> import subprocess
> @@ -40,10 +41,15 @@
> def get_all(self, keys):
> script_path = os.path.join(self.basepath, self.INFO_SCRIPT_NAME)
> if os.path.exists(script_path):
> - proc = subprocess.Popen(
> - [script_path], stdout=subprocess.PIPE,
> - stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
> - cwd=self.cwd)
> + try:
> + proc = subprocess.Popen(
> + [script_path], stdout=subprocess.PIPE,
> + stderr=subprocess.STDOUT, stdin=subprocess.PI...

Read more...

review: Approve
Revision history for this message
James Westby (james-w) wrote :

On Mon, 24 Jan 2011 19:28:31 -0000, Barry Warsaw <email address hidden> wrote:
> > + try:
> > + proc = subprocess.Popen(
> > + [script_path], stdout=subprocess.PIPE,
> > + stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
> > + cwd=path)
> > + except OSError, e:
>
> Probably should use "except OSError as e" for forward compatibility. (We only
> have to support >=Python 2.6, right?)

I guess so. Someone is bound to request 2.3 support some day, but I'm
fine with 2.6 for now.

Thanks,

James

45. By James Westby

Tweaks from review. Thanks Barry.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: