Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[host-service] Fix the path of host_modules #10314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/sonic-host-services/scripts/sonic-host-server
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import os.path
import glob
import importlib
import sys
import site

import dbus
import dbus.service
Expand All @@ -15,7 +16,13 @@ from gi.repository import GObject

def register_modules():
"""Register all host modules"""
mod_path = '/usr/local/lib/python3.7/dist-packages/host_modules'
mod_path = ""
for package_path in site.getsitepackages():
candidate = os.path.join(package_path, 'host_modules')
if os.path.isdir(candidate):
mod_path = candidate
print("host modules path:", mod_path)
break
sys.path.append(mod_path)
for mod_file in glob.glob(os.path.join(mod_path, '*.py')):
if os.path.isfile(mod_file) and not mod_file.endswith('__init__.py'):
Expand Down