Skip to content

Commit ec285ac

Browse files
committed
load baremetal profile by yaml
1 parent 816bf96 commit ec285ac

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

qiling/utils.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
This module is intended for general purpose functions that can be used
88
thoughout the qiling framework
99
"""
10-
import importlib, os, copy, re, pefile, logging, sys
10+
11+
import importlib, os, copy, re, pefile, logging, sys, yaml
12+
1113
from configparser import ConfigParser
1214
from logging import LogRecord
1315
from typing import Any, Container, Optional, Sequence, Tuple, Type
@@ -476,15 +478,18 @@ def profile_setup(ql):
476478
_profile = ql.profile
477479
debugmsg = "Profile: %s" % _profile
478480

479-
os_profile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "profiles", ostype_convert_str(ql.ostype).lower() + ".ql")
481+
if ql.baremetal:
482+
config = {}
483+
if ql.profile:
484+
with open(ql.profile) as f:
485+
config = yaml.load(f, Loader=yaml.Loader)
480486

481-
if ql.profile:
482-
profiles = [os_profile, ql.profile]
483487
else:
484-
profiles = [os_profile]
488+
profile_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "profiles", ostype_convert_str(ql.ostype).lower() + ".ql")
489+
profiles = [profile_path, ql.profile] if ql.profile else [profile_path]
485490

486-
config = ConfigParser()
487-
config.read(profiles)
491+
config = ConfigParser()
492+
config.read(profiles)
488493

489494
return config, debugmsg
490495

0 commit comments

Comments
 (0)