こんにちは、来てくれてありがとう。GUIからのデータで満たされたJSONdictを書き込む際に問題が発生しました。このスクリプトの実行後、何かで満たされた場合でも、空の.jsonファイルを取得しました。該当する結果なしでグーグル。
import easygui
import sys
from json import load, dump
from time import strftime, gmtime
def runTest():
# This is not really correct, but it works.
sys.argv = "Some Text"
date = strftime("%d.%m.%Y", gmtime()) + " " + str(int(strftime("%H", gmtime())) + 4) + strftime(":%M", gmtime())
test_case_area = easygui.buttonbox(
"Welcome to Automation Testing Environment, please, select the testing area name:", "Autotests gentle robot",
("GUI", "EPG", "LCN"))
stb = easygui.buttonbox("Please specify the STB type", "STB",
("something_1", "something_2", "something_3", "something_4", "something_5", "something_6", "something_7"))
platform = easygui.buttonbox("Please specify the {0} platform".format(stb), "{0} - Platform".format(stb),
("something_1", "something_2", "something_3", "something_4", "something_5"))
full_platform = stb + "_" + platform
msg = "Specify {0} parameters".format(full_platform)
title = "{0} version information".format(full_platform)
fieldNames = ["Software STB", "Hardware STB", "Module", "Software module", "Hardware module", "Tester", "Drive"]
fieldValues = easygui.multenterbox(msg, title, fieldNames)
test_conf_file_r = open("{0}:\\BBT2\\Configuration\\CP_PowerState.json".format(fieldValues[6]), "r")
test_conf_vocab = load(test_conf_file_r)
test_conf_vocab["platform"] = full_platform
test_conf_vocab["SW_version"] = fieldValues[0]
test_conf_vocab["HW_version"] = fieldValues[1]
test_conf_vocab["test_name"] = test_case_area
test_conf_vocab["disk"] = fieldValues[6]
test_conf_file_w = open("{0}:\\BBT2\\Configuration\\CP_PowerState.json".format(fieldValues[6]), "w")
dump(test_conf_vocab, test_conf_file_w)
IDLEでスクリプトの.json部分を完了した後、変数test_conf_vocab
を呼び出してtest_conf_file_w
個別に正常に機能しますが、空のファイルを再度取得しました。私はどういうわけか私がめちゃくちゃになっていることを知ってjson.dump()
います、私は自分自身のまともな間違いを見ることができないか、グーグルで検索することができません。