Home | History | Annotate | Download | only in cros
      1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """Provides utility methods for interacting with upstart"""
      6 
      7 import os
      8 
      9 from autotest_lib.client.common_lib import utils
     10 
     11 def ensure_running(service_name):
     12     """Fails if |service_name| is not running.
     13 
     14     @param service_name: name of the service.
     15     """
     16     cmd = 'initctl status %s | grep start/running' % service_name
     17     utils.system(cmd)
     18 
     19 
     20 def has_service(service_name):
     21     """Returns true if |service_name| is installed on the system.
     22 
     23     @param service_name: name of the service.
     24     """
     25     return os.path.exists('/etc/init/' + service_name + '.conf')
     26