def store_message_in_file(self, message: Message) -> Tuple[str, str]:
"""
Stores a message in a json file.
The filename of the file will be the current time.
Also generates a response file location in which the executable may
write a response into
:param message: The message to save
:return: The location of the stored message json file,
the location of the response file
"""
json_data = message.to_dict()
while True: # Make sure that file does not exist
message_file = os.path.join(self.message_dir, str(time.time()))
if not os.path.isfile(message_file):
with open(message_file + ".json", 'w') as json_file:
json.dump(json_data, json_file)
return message_file + ".json", message_file + "-response.json"
# noinspection PyMethodMayBeStatic
评论列表
文章目录