~gma500/emgd/jockey

« back to all changes in this revision

Viewing changes to jockey/oslib.py

  • Committer: Martin Pitt
  • Date: 2011-01-08 13:01:09 UTC
  • Revision ID: martin.pitt@canonical.com-20110108130109-pe30g2toenzc4erw
move has_defaultroute to OSLib for easier reuse

Show diffs side-by-side

added added

removed removed

Lines of Context:
597
597
                return f
598
598
 
599
599
        return None
 
600
 
 
601
    @classmethod
 
602
    def has_defaultroute(klass):
 
603
        '''Return if there is a default route.
 
604
 
 
605
        This is a reasonable indicator that online tests can be run.
 
606
        '''
 
607
        if klass._has_defaultroute_cache is None:
 
608
            klass._has_defaultroute_cache = False
 
609
            route = subprocess.Popen(['/sbin/route', '-n'],
 
610
                stdout=subprocess.PIPE)
 
611
            for l in route.stdout:
 
612
                if l.startswith('0.0.0.0 '):
 
613
                    klass._has_defaultroute_cache = True
 
614
            route.wait()
 
615
 
 
616
        return klass._has_defaultroute_cache
 
617
 
 
618
    _has_defaultroute_cache = None