Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(5)  |  Derive(0)  |  Import(0)
Validation function.  Converts a config value to a shell command of
the form (fname, optionslist). Raises ConfigError on failure.

        def _parseCommand(command):
    """Validation function.  Converts a config value to a shell command of
       the form (fname, optionslist). Raises ConfigError on failure."""
    c = command.strip().split()
    if not c:
        raise ConfigError("Invalid command %r" %command)
    cmd, opts = c[0], c[1:]
    if os.path.isabs(cmd):
        if not os.path.exists(cmd):
            raise ConfigError("Executable file not found: %s" % cmd)
        else:
            return cmd, opts
    else:
        # Path is relative
        for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
            p = os.path.expanduser(p)
            c = os.path.join(p, cmd)
            if os.path.exists(c):
                return c, opts

        raise ConfigError("No match found for command %r" %cmd)
        


src/m/i/mixminion-HEAD/lib/mixminion/test.py   mixminion(Download)
        if not sys.platform == 'win32':
            # WIN32 This should get implemented for Windows.
            c = C._parseCommand("ls -l")
            self.assert_(os.path.exists(c[0]) and c[0].endswith("/ls"))
            self.assertEquals(c[1], ['-l'])
            c = C._parseCommand("rm")
            self.assert_(os.path.exists(c[0]) and c[0].endswith("/rm"))
            self.assertEquals(c[1], [])
            self.assertEquals(C._parseCommand("/bin/ls"), ("/bin/ls", []))
            self.failUnless(C._parseCommand(sys.executable)[0] is not None)
        nonexistcmd = 'LindenAndPierre -meow'
        try:
            cmd, opts = C._parseCommand(nonexistcmd)
            if os.path.exists(cmd):
                # Ok, I guess they would.