def initialize(cls, working_dir): cls.working_dir = working_dir cls.default_values[u'disk'] = free_partition_space(cls.working_dir) HardwarePreset.get_or_create(name=cls.DEFAULT_NAME, defaults=cls.default_values) HardwarePreset.get_or_create(name=cls.CUSTOM_NAME, defaults=cls.CUSTOM_VALUES)
def upsert_hw_preset(cls, preset): preset_dict = cls.__preset_to_dict(preset) name = cls.__sanitize_preset_name(preset_dict['name']) defaults = dict(preset_dict) defaults.pop('name') preset, created = HardwarePreset.get_or_create(name=name, defaults=defaults) if not created: preset.apply(preset_dict) preset.save() return preset.to_dict()