Skip to content

Commit

Permalink
Merge pull request #276 from wayyoungboy/dev1
Browse files Browse the repository at this point in the history
fix utf-8 decode and encode
  • Loading branch information
wayyoungboy authored Jun 21, 2024
2 parents 898995a + 82000af commit b80c7dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ jobs:
sudo apt-get install -y alien
- name: Convert RPM to DEB
run: sudo alien -k --scripts oceanbase-diagnostic-tool-*.rpm
run: |
sudo alien -k --scripts oceanbase-diagnostic-tool-*.rpm
pwd
- name: Upload DEB Artifact
uses: actions/upload-artifact@v3
with:
name: obdiag-deb-package
path: /home/runner/work/obdiag/obdiag/oceanbase-diagnostic-tool_*.deb
path: ./oceanbase-diagnostic-tool_*.deb
retention-days: 3
10 changes: 7 additions & 3 deletions handler/checker/check_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, context, check_target_type="observer"):
new_node.append(node)
self.nodes = new_node
self.version = get_version(self.nodes, self.check_target_type, self.cluster, self.stdio)

obConnectorPool = None
# add OBConnectorPool
try:
obConnectorPool = checkOBConnectorPool(context, 3, self.cluster)
Expand Down Expand Up @@ -184,8 +184,11 @@ def get_all_tasks(self):
if file.endswith('.yaml'):
folder_name = os.path.basename(root)
task_name = "{}.{}".format(folder_name, file.split('.')[0])
task_data = YamlUtils.read_yaml_data(os.path.join(root, file))
tasks[task_name] = task_data
with open(os.path.join(root, file), 'r', encoding='utf-8') as f:
task_data = yaml.safe_load(f)
if task_data is None:
continue
tasks[task_name] = task_data
if len(tasks) == 0:
raise Exception("the len of tasks is 0")
self.tasks = tasks
Expand Down Expand Up @@ -241,6 +244,7 @@ def execute(self):
self.report.export_report()
except CheckrReportException as e:
self.stdio.error("Report error :{0}".format(e))
self.stdio.verbose(traceback.format_exc())
except Exception as e:
self.stdio.error("Internal error :{0}".format(e))
self.stdio.verbose(traceback.format_exc())
Expand Down
8 changes: 4 additions & 4 deletions handler/checker/check_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_report_path(self):

def export_report_xml(self):
allMap = self.report_tobeMap()
with open(self.report_path + ".xml", 'w', encoding="utf8") as f:
with open(self.report_path + ".xml", 'w', encoding='utf-8') as f:
allreport = {}
allreport["report"] = allMap
json_str = json.dumps(allreport)
Expand All @@ -93,13 +93,13 @@ def export_report_xml(self):

def export_report_yaml(self):
allMap = self.report_tobeMap()
with open(self.report_path + ".yaml", 'w', encoding="utf8") as f:
with open(self.report_path + ".yaml", 'w', encoding='utf-8') as f:
yaml.dump(allMap, f)

def export_report_json(self):
allMap = self.report_tobeMap()
self.stdio.verbose("export_report_json allMap: {0}".format(allMap))
with open(self.report_path + ".json", 'w', encoding="utf8") as f:
with open(self.report_path + ".json", 'w', encoding='utf-8') as f:
# for python2 and python3
try:
json.dump(allMap, f, ensure_ascii=False)
Expand Down Expand Up @@ -167,7 +167,7 @@ def export_report_table(self):
report_all_tb.add_row([task.name, "all pass"])
telemetry.push_check_info(self.report_target, {"fail_cases": list(set(failMap)), "critical_cases": list(set(criticalMap)), "warning_cases": list(set(warningMap))})

fp = open(self.report_path + ".table", 'a+', encoding="utf8")
fp = open(self.report_path + ".table", 'a+', encoding='utf-8')

if len(report_fail_tb._rows) != 0:
self.stdio.verbose(report_fail_tb)
Expand Down
2 changes: 1 addition & 1 deletion telemetry/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def put_data(self):
re = {"content": report_data, "component": "obdiag"}

# put to /tmp
with open(const.OBDIAG_TELEMETRY_FILE_NAME, 'w', encoding="utf8") as f:
with open(const.OBDIAG_TELEMETRY_FILE_NAME, 'w', encoding="UTF-8") as f:
f.write(json.dumps(re, ensure_ascii=False))
self.put_info_to_oceanbase()

Expand Down

0 comments on commit b80c7dd

Please sign in to comment.