Changeset 1514 in tailor


Ignore:
Timestamp:
05/20/08 17:17:56 (5 years ago)
Author:
lele@…
Hash name:
20080520151756-97f81-8984c9abe378971ad6190b805e7fd3f86dac7d27
Message:

Allow to override what SystemCommand? assume as an ok status

Location:
vcpx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vcpx/shwrap.py

    r1426 r1514  
    5353    """Don't execute commands longer than this number of characters.""" 
    5454 
    55     def __init__(self, command=None, cwd=None, nolog=False): 
     55    def __init__(self, command=None, cwd=None, nolog=False, ok_status=None): 
    5656        """ 
    5757        Initialize a ExternalCommand instance, specifying the command 
     
    7171        self.exit_status = None 
    7272        """Once the command has been executed, this is its exit status.""" 
     73 
     74        self.ok_status = ok_status is None and (0,) or ok_status 
     75        """Used to determine which exit_status should not trigger warnings.""" 
    7376 
    7477        self._last_command = None 
     
    267270 
    268271        self.exit_status = process.returncode 
    269         if not self.exit_status: 
     272        if self.exit_status in self.ok_status: 
    270273            if self.log: self.log.info("[Ok]") 
    271274        else: 
  • vcpx/tests/shwrap.py

    r1513 r1514  
    3636        c.execute() 
    3737        self.assertNotEqual(c.exit_status, 0) 
     38 
     39    def testOkStatus(self): 
     40        """Verify the log on exit_status""" 
     41 
     42        class Logger: 
     43            def warning(self, *args): 
     44                raise Exception('should not happen: %s' % str(args)) 
     45 
     46            def info(self, *args): 
     47                pass 
     48 
     49            def debug(self, *args): 
     50                pass 
     51 
     52        if platform != 'win32': 
     53            c = ExternalCommand(['false'], ok_status=(0,1)) 
     54        else: 
     55            c = ExternalCommand(['cmd','/c exit 1'], ok_status=(0,1)) 
     56        c.execute() 
     57 
     58        c.log = Logger() 
     59        c.execute() 
    3860 
    3961    def testExitStatusUnknownCommand(self): 
Note: See TracChangeset for help on using the changeset viewer.