Commit ea8c0652 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

remove path folder

parent d14ad2b3
Pipeline #350520 passed with stage
in 11 seconds
{"thingId": "s3i:7f46a255-3245-439e-84f0-090f0b221965", "policyId": "s3i:7f46a255-3245-439e-84f0-090f0b221965", "attributes": {"class": "ml40::Thing", "name": "my HMI", "roles": [{"class": "ml40::HMI"}], "features": []}}
\ No newline at end of file
......@@ -7,6 +7,9 @@
from ml.app_logger import APP_LOGGER, setup_logger
import time
from config import *
import os
root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
dt_creation_app_id = dt_creation_app_id
dt_creation_app_secret = dt_creation_app_secret
......@@ -54,9 +57,10 @@
features=[{"class": "fml40::ProvidesProductionData"},
{"class": "fml40::AcceptsFellingJobs"},
{"class": "ml40::Composite",
"targets": [config_engine, config_cran]}])
"targets": [config_engine, config_cran]}],
root=root_path)
setup_logger(dt_name)
dt_model = load_config(config_file_name)
dt_model = load_config(config_file_name, root=root_path)
dt = create_dt_ref(model=dt_model, grant_type="client_credentials", secret=dt_secret,
is_broker_rest=True,
......
......@@ -7,12 +7,16 @@
import requests
import json
from config import *
import os
root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
setup_logger("my HMI")
config_file_name = make_thing_config(dt_id=hmi_id, name="my HMI", roles=[{"class": "ml40::HMI"}],
)
hmi_model = load_config(config_file_name)
root=root_path)
hmi_model = load_config(config_file_name, root=root_path)
hmi = create_dt_ref(model=hmi_model, grant_type="password", secret=hmi_secret,
username=username, password=password,
is_broker_rest=True, is_broker=True, is_repo=False)
......
......@@ -13,7 +13,6 @@
from s3i import IdentityProvider
from ml.app_logger import APP_LOGGER
from ml.authentication import GRANT_TYPES
from path.path import get_root
IDENTITY_PROVIDER_URL = "https://idp.s3i.vswf.dev/"
......@@ -333,7 +332,7 @@ def make_thing_config(dt_id, name, roles, features=[], root=__file__):
}
}
path = os.path.join(get_root(root), "configs", "{}.json".format(name))
path = os.path.join(root, "configs", "{}.json".format(name))
with open(path, 'wb') as file:
file.write(json.dumps(config_file).encode('utf-8'))
return "{}.json".format(name)
......@@ -345,7 +344,7 @@ def load_config(config_file_name, root=__file__):
:param config_filepath: Path to json formatted file.
"""
config_file_path = os.path.join(get_root(root), "configs", config_file_name)
config_file_path = os.path.join(root, "configs", config_file_name)
with open(config_file_path) as config_file:
config = json.load(config_file)
return config
......
import os
import sys
def get_root(file_path):
path = sys.modules[__name__].__file__ if __name__ == "__main__" else file_path
return os.path.abspath(os.path.join(os.path.dirname(path), os.path.pardir))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment