-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging changes for BreakingPoint 10.0 Patch3 release
- Loading branch information
Showing
16 changed files
with
17,373 additions
and
245 deletions.
There are no files selected for viewing
3,690 changes: 3,631 additions & 59 deletions
3,690
RestApi/Python/RestApi_v2/Modules/bps_restpy/restPyWrapper.py
Large diffs are not rendered by default.
Oops, something went wrong.
3,690 changes: 3,631 additions & 59 deletions
3,690
RestApi/Python/RestApi_v2/Modules/bps_restpy/restPyWrapper3.py
Large diffs are not rendered by default.
Oops, something went wrong.
115 changes: 0 additions & 115 deletions
115
RestApi/Python/RestApi_v2/Modules/bps_restpy/rest_samples/Retry_Sample.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
87 changes: 87 additions & 0 deletions
87
RestApi/Python/RestApi_v2/SampleScripts/Runtime_Strike_Update_Sample/DifferenceReport.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from collections import defaultdict | ||
|
||
class DifferenceReport: | ||
|
||
def __init__(self): | ||
self.sections = [] # -> dict {Section ID, Section Name, Strike Total Difference, Detail Difference[Time of Strike, Strike Name, Strike Reference, Permutations, Strike Tuples]} | ||
self.raw_sections = [] | ||
def add_change(self,section): | ||
self.sections.append(section) | ||
|
||
def add_raw_change(self,raw_section): | ||
self.raw_sections.append(raw_section) | ||
|
||
def print_all(self, security): | ||
print("Differences:") | ||
if security: | ||
with open("checkResult.txt", "w") as file: | ||
for section in self.sections: | ||
if "Strike Total Difference" in section and "Detail Difference" in section: | ||
section_id = section["Section ID"] | ||
section_name = section["Section Name"] | ||
file.write("Section ID: {0}\n".format(section_id)) | ||
file.write("Section Name: {0}\n".format(section_name)) | ||
print("Section ID: {0}".format(section_id)) | ||
print("Section Name: {0}".format(section_name)) | ||
file.write("Strike Total Difference: {0}\n".format(section["Strike Total Difference"])) | ||
print("Strike Total Difference: {0}\n".format(section["Strike Total Difference"])) | ||
for i in range(len(section["Detail Difference"]["Time of strike"])): | ||
file.write("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i])) | ||
file.write("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i])) | ||
file.write("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i])) | ||
file.write("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i])) | ||
file.write("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i])) | ||
file.write("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i])) | ||
print("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i])) | ||
print("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i])) | ||
print("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i])) | ||
print("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i])) | ||
print("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i])) | ||
print("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i])) | ||
print("++++++++++++++++++++++++++++++++++++") | ||
file.write("++++++++++++++++++++++++++++++++++++\n") | ||
file.write("===============================================================\n") | ||
print("===============================================================") | ||
else: | ||
with open("checkResult.txt", "w") as file: | ||
for section in self.sections: | ||
section_id = section["Section ID"] | ||
section_name = section["Section Name"] | ||
file.write("Section ID: {0}\n".format(section_id)) | ||
file.write("Section Name: {0}\n".format(section_name)) | ||
print("Section ID: {0}".format(section_id)) | ||
print("Section Name: {0}".format(section_name)) | ||
if "Strike Total Difference" in section and "Detail Difference" in section: | ||
file.write("Strike Total Difference: {0}\n".format(section["Strike Total Difference"])) | ||
print("Strike Total Difference: {0}\n".format(section["Strike Total Difference"])) | ||
for i in range(len(section["Detail Difference"]["Time of strike"])): | ||
file.write("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i])) | ||
file.write("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i])) | ||
file.write("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i])) | ||
file.write("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i])) | ||
file.write("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i])) | ||
file.write("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i])) | ||
print("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i])) | ||
print("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i])) | ||
print("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i])) | ||
print("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i])) | ||
print("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i])) | ||
print("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i])) | ||
print("++++++++++++++++++++++++++++++++++++") | ||
file.write("++++++++++++++++++++++++++++++++++++\n") | ||
file.write("===============================================================\n") | ||
print("===============================================================") | ||
|
||
def print_raw_all(self): | ||
print("Difference: ") | ||
with open ("checkResult.txt", "a+") as file: | ||
for raw_section in self.raw_sections: | ||
print("Section ID: {0}".format(raw_section.id)) | ||
print("Section Name: {0}".format(raw_section.name)) | ||
file.write("Section ID: {0}\n".format(raw_section.id)) | ||
file.write("Section Name: {0}\n".format("Section Name: {0}".format(raw_section.name))) | ||
|
||
|
||
|
101 changes: 101 additions & 0 deletions
101
RestApi/Python/RestApi_v2/SampleScripts/Runtime_Strike_Update_Sample/ReportContent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import sys, os, re, time | ||
from Section import Section | ||
from collections import defaultdict | ||
from DifferenceReport import DifferenceReport | ||
sys.path.append(os.path.dirname(__file__)) | ||
from restPyWrapper3 import * | ||
|
||
class ReportContent: | ||
|
||
def __init__(self, bps, runId, security = False): | ||
self.content = {} | ||
self.bps = bps | ||
self.sections = [] | ||
self.run_id = runId | ||
self.security_check = security | ||
|
||
def create_content(self): | ||
self.content = self.bps.reports.getReportContents(runid=self.run_id, getTableOfContents=True) | ||
|
||
def load_all_section(self): | ||
id_of_security_start = "" | ||
for i in range(len(self.content)): | ||
id = self.content[i]["Section ID"] | ||
name = self.content[i]["Section Name"] | ||
section_split = id.split(".") | ||
if len(section_split) > 1: | ||
parent_id = ".".join(id.split(".")[:-1]) | ||
parent_section = self.retrieve_section_by_id(parent_id) | ||
if parent_section: | ||
parent_section.children.append(id) | ||
section = Section(id,name,i) | ||
if id_of_security_start: | ||
if id.startswith(id_of_security_start): | ||
section.security = True | ||
section.load_section() | ||
section.normalize_variant_name() | ||
elif name == "Component Detection Assessment": | ||
id_of_security_start = id | ||
# Now all the security section children gets the detail of the table | ||
self.sections.append(section) | ||
|
||
def retrieve_section_by_id(self, section_id): | ||
for section in self.sections: | ||
if section_id == section.id: | ||
return section | ||
return None | ||
|
||
def compare_reportContent(self, content_to_compare): # | ||
try: | ||
difference = DifferenceReport() | ||
for section in self.sections: | ||
section_to_compare = content_to_compare.find_diff_sections(section) | ||
if section_to_compare: # Same Name Security or not Security | ||
|
||
# Any difference in the exisiting list | ||
if section.security and not section.children: # if it's a child | ||
section.get_security_content(self.bps, self.run_id) | ||
if not section_to_compare.children and not section_to_compare.detail: | ||
difference.add_change(section.to_dict()) | ||
else: | ||
if section.security_strike_total != section_to_compare.security_strike_total: | ||
section_diff = section.compare_security(section_to_compare,self.sections) | ||
difference.add_change(section_diff) | ||
else: | ||
difference.add_change(section.to_dict()) | ||
else: | ||
if section.security and not section.children: # if it's a child | ||
section.get_security_content(self.bps, self.run_id) | ||
difference.add_change(section.to_dict()) | ||
difference.print_all(self.security_check) | ||
except Exception as err: | ||
raise Exception(str(err)) | ||
|
||
|
||
def compare_raw_reportContent(self, content_to_compare): # | ||
try: | ||
difference = DifferenceReport() | ||
for section in self.sections: | ||
if not content_to_compare.find_sections_by_name(section.name): # The name are totally different, new section found | ||
# Any difference in the exisiting list | ||
difference.add_raw_change(section) # if it's a security component, it will generate things from detail | ||
difference.print_raw_all() | ||
except Exception as err: | ||
raise Exception(str(err)) | ||
|
||
def find_diff_sections(self, section_to_compare): | ||
for section in self.sections: | ||
if section.security and section_to_compare.security: | ||
if section.relative_name == section_to_compare.relative_name: | ||
return section | ||
else: | ||
if section.name == section_to_compare.name: | ||
return section | ||
return None | ||
|
||
|
||
def find_sections_by_name(self, section_name): | ||
for section in self.sections: | ||
if section.name == section_name: | ||
return True | ||
return False |
Oops, something went wrong.