~ubuntu-branches/ubuntu/lucid/bzr/lucid-proposed

« back to all changes in this revision

Viewing changes to bzrlib/externalcommand.py

Tags: upstream-0.7
ImportĀ upstreamĀ versionĀ 0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import sys
24
24
 
25
25
from bzrlib.commands import Command
 
26
from bzrlib.osutils import pathjoin
26
27
 
27
28
 
28
29
class ExternalCommand(Command):
34
35
        bzrpath = os.environ.get('BZRPATH', '')
35
36
 
36
37
        for dir in bzrpath.split(os.pathsep):
 
38
            ## Empty directories are not real paths
 
39
            if not dir:
 
40
                continue
 
41
            # This needs to be os.path.join() or windows cannot
 
42
            # find the batch file that you are wanting to execute
37
43
            path = os.path.join(dir, cmd)
38
44
            if os.path.isfile(path):
39
45
                return ExternalCommand(path)
44
50
    def __init__(self, path):
45
51
        self.path = path
46
52
 
47
 
 
48
53
    def name(self):
49
 
        return self.path.split(os.sep)[-1]
50
 
 
 
54
        return os.path.basename(self.path)
51
55
 
52
56
    def run(self, *args, **kwargs):
53
57
        raise NotImplementedError('should not be called on %r' % self)
54
58
 
55
 
 
56
59
    def run_argv(self, argv):
57
60
        return os.spawnv(os.P_WAIT, self.path, [self.path] + argv)
58
61
 
59
 
 
60
62
    def help(self):
61
63
        m = 'external command from %s\n\n' % self.path
62
64
        pipe = os.popen('%s --help' % self.path)
63
65
        return m + pipe.read()
 
66