Changeset 78:559da4f6eef0 in livinglogic.python.tipimaid

Show
Ignore:
Timestamp:
02/03/09 10:54:28 (10 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Simplify handling of non-existant subprocess.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • liaalh.py

    r77 r78  
    3535        self.utcrotate = utcrotate 
    3636        self.execute = execute 
    37         if execute is not None: 
    38             if subprocessworks: 
    39                 self.do_something = self.do_something_subprocess 
    4037        self.updateutcoffset() 
    4138        self.handlevirtualhost = "%v" in pattern 
     
    146143            raise 
    147144 
    148     def do_something_subprocess(self, filename): 
    149         try: 
    150             retcode = subprocess.call([self.execute, filename]) 
    151         except OSError, exc: 
    152             sys.stderr.write("Subprocess \"%s %s\" caused exception %r" % (self.execute, filename, retcode)) 
    153             sys.stderr.flush() 
    154         if retcode != 0: 
    155             sys.stderr.write("Subprocess \"%s %s\" returned error code %s" % (self.execute, filename, retcode)) 
    156             sys.stderr.flush() 
    157  
    158145    def do_something(self, filename): 
    159146        try: 
    160             retcode = os.system("%s %s" % (self.execute, filename)) 
     147            if subprocessworks: 
     148                retcode = subprocess.call([self.execute, filename]) 
     149            else: 
     150                retcode = os.system("%s %s" % (self.execute, filename)) 
    161151        except OSError, exc: 
    162152            sys.stderr.write("Subprocess \"%s %s\" caused exception %r" % (self.execute, filename, retcode))