from collections import OrderedDict import pickle import os from config import SETTINGS_FILE_NAME class ApplicationContext: def __init__(self): self.connections = OrderedDict() class Connection: id = 0 name = '' region = '' aws_secret_access_key = '' aws_access_key_id = '' def __init__(self): self.id = max(list(context.connections.keys()) + [0]) + 1 def __hash__(self): return self.name.__hash__() def __cmp__(self, other): return self.name == other.name def load_context(application): if not os.path.exists(SETTINGS_FILE_NAME): return with open(SETTINGS_FILE_NAME, 'rb') as file: application.context = pickle.load(file) def save_context(application): with open(SETTINGS_FILE_NAME, 'wb') as file: pickle.dump(application.context, file) context = ApplicationContext() main_window = None windows = []