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.PIPE, > + cwd=self.cwd) > + except OSError, e:
except OSError as e:
> + if e.errno == errno.ENOENT: > + raise ExternalHelperFailed( > + "%s does not exist" % script_path) > out, ignore = proc.communicate(json.dumps(keys)) > if proc.returncode != 0: > raise ExternalHelperFailed( > @@ -59,10 +65,15 @@ > def _get(self, key): > script_path = os.path.join(self.basepath, key) > 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.PIPE, > + cwd=self.cwd) > + except OSError, e:
> + if e.errno == errno.ENOENT: > + raise ExternalHelperFailed( > + "%s does not exist" % script_path) > out, ignore = proc.communicate() > if proc.returncode != 0: > # TODO: some info on the failure
=== modified file 'pkgme/tests/test_vala_backend.py' --- pkgme/tests/test_vala_backend.py 2010-12-18 14:40:42 +0000 +++ pkgme/tests/test_vala_backend.py 2011-01-16 19:09:53 +0000 > @@ -31,10 +31,10 @@ > backend_dir = get_backend_dir(__file__, 'vala') > > > -class PythonBackendTests(TestCase, TestWithFixtures): > +class ValaBackendTests(TestCase, TestWithFixtures): > > def setUp(self): > - super(PythonBackendTests, self).setUp() > + super(ValaBackendTests, self).setUp() > self.tempdir = self.useFixture(TempdirFixture()) > > def write_file_in_tempdir(self, path, content):
« Back to merge proposal
review approve
merge approve
=== modified file 'pkgme/backend.py' dir(underunder_ file, backend): abspath( os.path. normpath(
--- 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_
> - backend_dir = os.path.normpath(
> + backend_dir = os.path.
Only abspath() should be necessary, as it calls normpath() on its return posixpath. py.
value. See Python's Lib/os/
> os.path.join( dirname( underunder_ file), os.pardir, {platform} -{version} directory and that cannot be used as a join(self. basepath, self.WANT_ SCRIPT_ NAME) abspath( self.basepath) , self.WANT_ SCRIPT_ NAME) exists( script_ path): subprocess. PIPE, subprocess. STDOUT, stdin=subproces s.PIPE, subprocess. PIPE, subprocess. STDOUT, stdin=subproces s.PIPE,
> os.path.
> - '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.
> @@ -114,12 +115,19 @@
> self.basepath = basepath
>
> def want(self, path):
> - script_path = os.path.
> + script_path = os.path.join(
> + os.path.
> if os.path.
> - proc = subprocess.Popen(
> - [script_path], stdout=
> - stderr=
> - cwd=path)
> + try:
> + proc = subprocess.Popen(
> + [script_path], stdout=
> + stderr=
> + 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: ailed( abspath( path) isdir(path) :
> + raise ExternalHelperF
> + "%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.
> if not os.path.
> continue
> fnames = os.listdir(path)
=== modified file 'pkgme/ project_ info.py' info.py 2010-11-10 00:44:43 +0000 info.py 2011-01-16 19:09:53 +0000 join(self. basepath, self.INFO_ SCRIPT_ NAME) exists( script_ path): subprocess. PIPE, subprocess. STDOUT, stdin=subproces s.PIPE, subprocess. PIPE, subprocess. STDOUT, stdin=subproces s.PIPE,
--- pkgme/project_
+++ pkgme/project_
> @@ -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.
> if os.path.
> - proc = subprocess.Popen(
> - [script_path], stdout=
> - stderr=
> - cwd=self.cwd)
> + try:
> + proc = subprocess.Popen(
> + [script_path], stdout=
> + stderr=
> + cwd=self.cwd)
> + except OSError, e:
except OSError as e:
> + if e.errno == errno.ENOENT: ailed( e(json. dumps(keys) ) ailed( join(self. basepath, key) exists( script_ path): subprocess. PIPE, subprocess. STDOUT, stdin=subproces s.PIPE, subprocess. PIPE, subprocess. STDOUT, stdin=subproces s.PIPE,
> + raise ExternalHelperF
> + "%s does not exist" % script_path)
> out, ignore = proc.communicat
> if proc.returncode != 0:
> raise ExternalHelperF
> @@ -59,10 +65,15 @@
> def _get(self, key):
> script_path = os.path.
> if os.path.
> - proc = subprocess.Popen(
> - [script_path], stdout=
> - stderr=
> - cwd=self.cwd)
> + try:
> + proc = subprocess.Popen(
> + [script_path], stdout=
> + stderr=
> + cwd=self.cwd)
> + except OSError, e:
except OSError as e:
> + if e.errno == errno.ENOENT: ailed(
> + raise ExternalHelperF
> + "%s does not exist" % script_path)
> out, ignore = proc.communicate()
> if proc.returncode != 0:
> # TODO: some info on the failure
=== modified file 'pkgme/ tests/test_ vala_backend. py' test_vala_ backend. py 2010-12-18 14:40:42 +0000 test_vala_ backend. py 2011-01-16 19:09:53 +0000 dir(__file_ _, 'vala') sts(TestCase, TestWithFixtures): s(TestCase, TestWithFixtures): kendTests, self).setUp() ndTests, self).setUp() (TempdirFixture ()) in_tempdir( self, path, content):
--- pkgme/tests/
+++ pkgme/tests/
> @@ -31,10 +31,10 @@
> backend_dir = get_backend_
>
>
> -class PythonBackendTe
> +class ValaBackendTest
>
> def setUp(self):
> - super(PythonBac
> + super(ValaBacke
> self.tempdir = self.useFixture
>
> def write_file_