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

Remove DFCI Python Scripts #397

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
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
43 changes: 40 additions & 3 deletions SetupDataPkg/Tools/ConfigEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import sys
import base64
import datetime
from pathlib import Path

sys.dont_write_bytecode = True
Expand All @@ -16,7 +17,6 @@
import tkinter.ttk as ttk # noqa: E402
import tkinter.messagebox as messagebox # noqa: E402
import tkinter.filedialog as filedialog # noqa: E402
from SettingSupport.SettingsXMLLib import SettingsXMLLib # noqa: E402
from GenNCCfgData import CGenNCCfgData # noqa: E402
from CommonUtility import ( # noqa: E402
bytes_to_value,
Expand Down Expand Up @@ -917,6 +917,44 @@ def save_delta_file(self, full=False):
csv_path, self.cfg_data_list[file_id].org_cfg_data_bin, new_data, full
)

def create_settings_xml(self, filename, version, lsv, settingslist):

with open(filename, "w") as f:
f.write('<?xml version="1.0" encoding="utf-8"?>\n')
f.write('<SettingsPacket xmlns="urn:UefiSettings-Schema">\n')
f.write(' <CreatedBy>Dfci Testcase Libraries</CreatedBy>\n')
f.write(' <CreatedOn>')

print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), end='', file=f)

f.write('</CreatedOn>\n')
f.write(' <Version>')
print(version, end='', file=f)
f.write('</Version>\n')
f.write(' <LowestSupportedVersion>')
print(lsv, end='', file=f)
f.write('</LowestSupportedVersion>\n')
f.write(' <Settings>\n')

#
# The settings list is a list of a list. The lowest level list is really a tuple of
# setting id and value
#
for setting in settingslist:
f.write(' <Setting>\n')
f.write(' <Id>')
print(setting[0], end='', file=f)
f.write('</Id>\n')
f.write(' <Value>')
print(setting[1], end='', file=f)
f.write('</Value>\n')
f.write(' </Setting>\n')

f.write(' </Settings>\n')
f.write('</SettingsPacket>\n')

return True

def save_to_svd(self, full):
path = self.get_save_file_name("svd")
if not path:
Expand Down Expand Up @@ -951,8 +989,7 @@ def save_to_svd(self, full):
(name_array[index], b64data.decode("utf-8"))
)

set_lib = SettingsXMLLib()
set_lib.create_settings_xml(
self.create_settings_xml(
filename=temp_file, version=1, lsv=1, settingslist=settings
)

Expand Down
44 changes: 40 additions & 4 deletions SetupDataPkg/Tools/GenNCCfgData.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from collections import OrderedDict
import base64

from SettingSupport.DFCI_SupportLib import DFCI_SupportLib # noqa: E402
import xml.etree.ElementTree as ET

from CommonUtility import bytes_to_value
from VariableList import (
Schema,
Expand Down Expand Up @@ -228,6 +229,43 @@ def get_var_list_for_instance(self, var_list):
break
return actual_var_list

def iterate_each_setting(self, resultfile, handler):
xmlstring = ""
found = False
a = open(resultfile, "r")

# find the start of the xml string and then copy all lines to xmlstring variable
for line in a.readlines():
if found:
xmlstring += line
else:
if line.lstrip().startswith("<?xml"):
xmlstring = line
found = True
a.close()

if (len(xmlstring) == 0) or (not found):
print("Result XML not found")
return None

# make an element tree from xml string
r = None
root = ET.fromstring(xmlstring)

# Process Settings produced by SettingsXMLLib.py
for e in root.findall(
"./{urn:UefiSettings-Schema}Settings/{urn:UefiSettings-Schema}Setting"
):
i = e.find("{urn:UefiSettings-Schema}Id")
r = e.find("{urn:UefiSettings-Schema}Value")
handler(i.text, r.text)

# Process SettingsCurrent from ConfApp output (from DFCI Libs)
for e in root.findall("./Settings/SettingCurrent"):
i = e.find("Id")
r = e.find("Value")
handler(i.text, r.text)

def load_from_svd(self, path):
def handler(id, value):
# ignore YAML entries
Expand All @@ -240,9 +278,7 @@ def handler(id, value):
uefi_variables_to_knobs(self.schema, actual_var_list)
self.sync_shim_and_schema()

a = DFCI_SupportLib()

a.iterate_each_setting(path, handler)
self.iterate_each_setting(path, handler)

def load_default_from_bin(self, bin_data, is_variable_list_format):
var_list = read_vlist_from_buffer(bin_data)
Expand Down
95 changes: 0 additions & 95 deletions SetupDataPkg/Tools/SettingSupport/BldDskPkt.py

This file was deleted.

76 changes: 0 additions & 76 deletions SetupDataPkg/Tools/SettingSupport/CertSupportLib.py

This file was deleted.

Loading
Loading