def _configure_and_start_service(service_branch, fledge_url, remove_directories):
    try:
        subprocess.run(['$FLEDGE_ROOT/tests/system/python/scripts/install_c_service {} {}'.format(service_branch, SERVICE)], shell=True, check=True, stdout=subprocess.DEVNULL)
    except subprocess.CalledProcessError:
        assert False, '{} installation failed'.format(SERVICE)
    finally:
        remove_directories('/tmp/fledge-service-{}'.format(SERVICE))
    conn = http.client.HTTPConnection(fledge_url)
    data = {'name': SERVICE_NAME, 'type': 'notification', 'enabled': 'true'}
    conn.request('POST', '/fledge/service', json.dumps(data))
    r = conn.getresponse()
    assert (200 == r.status)
    r = r.read().decode()
    jdoc = json.loads(r)
    assert (2 == len(jdoc))
    assert (SERVICE_NAME == jdoc['name'])
def _configure_and_start_service(service_branch, fledge_url, remove_directories):
    try:
        subprocess.run(['$FLEDGE_ROOT/tests/system/python/scripts/install_c_service {} {}'.format(service_branch, SERVICE)], shell=True, check=True, stdout=subprocess.DEVNULL)
    except subprocess.CalledProcessError:
        assert False, '{} installation failed'.format(SERVICE)
    finally:
        remove_directories('/tmp/fledge-service-{}'.format(SERVICE))
    conn = http.client.HTTPConnection(fledge_url)
    data = {'name': SERVICE_NAME, 'type': 'notification', 'enabled': 'true'}
    conn.request('POST', '/fledge/service', json.dumps(data))
    r = conn.getresponse()
    assert (200 == r.status)
    r = r.read().decode()
    jdoc = json.loads(r)
    assert (2 == len(jdoc))
    assert (SERVICE_NAME == jdoc['name'])