~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/externalcommand.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 06:52:39 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730065239-03b4ac02d9f56202
branding: change Bazaar-NG to Bazaar

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):
 
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
36
43
            path = os.path.join(dir, cmd)
37
44
            if os.path.isfile(path):
38
45
                return ExternalCommand(path)
43
50
    def __init__(self, path):
44
51
        self.path = path
45
52
 
46
 
 
47
53
    def name(self):
48
 
        return self.path.split(os.sep)[-1]
49
 
 
 
54
        return os.path.basename(self.path)
50
55
 
51
56
    def run(self, *args, **kwargs):
52
57
        raise NotImplementedError('should not be called on %r' % self)
53
58
 
54
 
 
55
 
    def run_argv(self, argv):
 
59
    def run_argv(self, argv, alias_argv=None):
56
60
        return os.spawnv(os.P_WAIT, self.path, [self.path] + argv)
57
61
 
58
 
 
59
62
    def help(self):
60
63
        m = 'external command from %s\n\n' % self.path
61
64
        pipe = os.popen('%s --help' % self.path)
62
65
        return m + pipe.read()
 
66