~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/externalcommand.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-01 19:27:48 UTC
  • mto: (1185.50.19 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1532.
  • Revision ID: john@arbash-meinel.com-20051201192748-369238cd06ecf7e8
Added osutils.mkdtemp()

Show diffs side-by-side

added added

removed removed

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