Changeset 1243 in tailor


Ignore:
Timestamp:
08/16/06 00:22:03 (7 years ago)
Author:
lele@…
Hash name:
20060815222203-97f81-504b28f38fc35328ead5ffe73a0bc2e945e200c3
Message:

Option to disable the logging facility, for test purposes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/shwrap.py

    r1173 r1243  
    5353    """Don't execute commands longer than this number of characters.""" 
    5454 
    55     def __init__(self, command=None, cwd=None): 
     55    def __init__(self, command=None, cwd=None, nolog=False): 
    5656        """ 
    5757        Initialize a ExternalCommand instance, specifying the command 
     
    7575        """Last executed command.""" 
    7676 
    77         self.log = getLogger('tailor.shell') 
     77        if nolog: 
     78            self.log = False 
     79        else: 
     80            self.log = getLogger('tailor.shell') 
    7881 
    7982    def __str__(self): 
     
    191194            self._last_command.extend(args) 
    192195 
    193         self.log.info(self) 
     196        if self.log: self.log.info(self) 
    194197 
    195198        if self.DRY_RUN: 
     
    200203            raise OSError(ENOENT, "Working directory does not exist", cwd) 
    201204 
    202         self.log.debug("Executing %r (%r)", self, cwd) 
     205        if self.log: self.log.debug("Executing %r (%r)", self, cwd) 
    203206 
    204207        if not kwargs.has_key('env'): 
     
    246249        if input and isinstance(input, unicode): 
    247250            encoding = getpreferredencoding() 
    248             self.log.warning("Using default %s encoding, ignoring errors; " 
    249                              "caller should use repository's encoding and " 
    250                              "pass an already encoded input" % encoding) 
     251            if self.log: 
     252                self.log.warning("Using default %s encoding, ignoring errors; " 
     253                                 "caller should use repository's encoding and " 
     254                                 "pass an already encoded input" % encoding) 
    251255            input = input.encode(encoding, 'ignore') 
    252256 
     
    255259        self.exit_status = process.returncode 
    256260        if not self.exit_status: 
    257             self.log.info("[Ok]") 
    258         else: 
    259             self.log.warning("[Status %s]", self.exit_status) 
     261            if self.log: self.log.info("[Ok]") 
     262        else: 
     263            if self.log: self.log.warning("[Status %s]", self.exit_status) 
    260264 
    261265        # For debug purposes, copy the output to our stderr when hidden above 
Note: See TracChangeset for help on using the changeset viewer.