Merge lp:~marienz/apport/search-for-executable into lp:~apport-hackers/apport/trunk

Proposed by Marco Rodrigues
Status: Rejected
Rejected by: Martin Pitt
Proposed branch: lp:~marienz/apport/search-for-executable
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 51 lines
1 file modified
apport/ui.py (+27/-13)
To merge this branch: bzr merge lp:~marienz/apport/search-for-executable
Reviewer Review Type Date Requested Status
Martin Pitt (community) Needs Fixing
Review via email: mp+13943@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

For backwards compatibility, please check if it is a valid package name first, and only then fall back to searching $PATH.

You might also consider calling "which" to search the PATH.

review: Needs Fixing
Revision history for this message
Martin Pitt (pitti) wrote :

This seems stale, setting to rejected. If you still want to work on this, please set back to "work in progress".

Unmerged revisions

1623. By Marien Zwart <marienz@siren>

When given a single argument also search $PATH for it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apport/ui.py'
2--- apport/ui.py 2009-10-14 21:17:30 +0000
3+++ apport/ui.py 2009-10-26 10:55:21 +0000
4@@ -501,20 +501,34 @@
5 self.options.pid = sys.argv[1]
6
7 # executable?
8- elif '/' in sys.argv[1]:
9- pkg = apport.packaging.get_file_package(sys.argv[1])
10- if not pkg:
11- optparser.error('%s does not belong to a package.' % sys.argv[1])
12- sys.exit(1)
13- self.args = []
14- self.options.filebug = True
15- self.options.package = pkg
16-
17- # otherwise: package name
18 else:
19- self.args = []
20- self.options.filebug = True
21- self.options.package = sys.argv[1]
22+ if '/' in sys.argv[1]:
23+ # Use as absolute path to the executable.
24+ fullpath = sys.argv[1]
25+ else:
26+ # Search $PATH for it:
27+ for path in os.environ['PATH'].split(os.pathsep):
28+ fullpath = os.path.join(path, sys.argv[1])
29+ # This follows symlinks, which is what we want.
30+ if os.path.isfile(fullpath):
31+ break
32+ else:
33+ fullpath = None
34+
35+ if fullpath is not None:
36+ pkg = apport.packaging.get_file_package(fullpath)
37+ if not pkg:
38+ optparser.error('%s does not belong to a package.' % fullpath)
39+ sys.exit(1)
40+ self.args = []
41+ self.options.filebug = True
42+ self.options.package = pkg
43+
44+ # otherwise: package name
45+ else:
46+ self.args = []
47+ self.options.filebug = True
48+ self.options.package = sys.argv[1]
49
50 def format_filesize(self, size):
51 '''Format the given integer as humanly readable and i18n'ed file size.'''

Subscribers

People subscribed via source and target branches