--- hatari/python-ui/hatari.py 2019/04/09 08:50:49 1.1.1.5 +++ hatari/python-ui/hatari.py 2019/04/09 08:51:33 1.1.1.6 @@ -48,10 +48,17 @@ class Hatari: def is_compatible(self): "check Hatari compatibility and return error string if it's not" - for line in os.popen(self.hataribin + " -h").readlines(): + error = "Hatari not found or it doesn't support the required --control-socket option!" + pipe = os.popen(self.hataribin + " -h") + for line in pipe.readlines(): if line.find("--control-socket") >= 0: - return None - return "Hatari not found or it doesn't support the required --control-socket option!" + error = None + break + try: + pipe.close() + except IOError: + pass + return error def save_config(self): os.popen(self.hataribin + " --saveconfig") @@ -292,7 +299,10 @@ class HatariConfigMapping(ConfigStore): else: getattr(self, method)() - def _change_option(self, option): + def _change_option(self, option, quoted = None): + "handle option changing, and quote spaces for quoted part of it" + if quoted: + option = "%s %s" % (option, quoted.replace(" ", "\\ ")) if self._lock_updates: self._options.append(option) else: @@ -508,7 +518,7 @@ class HatariConfigMapping(ConfigStore): def set_floppy(self, drive, filename): self.set("[Floppy]", "szDisk%cFileName" % ("A", "B")[drive], filename) - self._change_option("--disk-%c %s" % (("a", "b")[drive], filename)) + self._change_option("--disk-%c" % ("a", "b")[drive], str(filename)) # ------------ fast FDC access --------------- def get_fastfdc(self): @@ -545,7 +555,7 @@ class HatariConfigMapping(ConfigStore): if dirname and os.path.isdir(dirname): self.set("[HardDisk]", "bUseHardDiskDirectory", True) self.set("[HardDisk]", "szHardDiskDirectory", dirname) - self._change_option("--harddrive %s" % dirname) + self._change_option("--harddrive", str(dirname)) # ------------ ACSI HD (file) --------------- def get_acsi_image(self): @@ -556,7 +566,7 @@ class HatariConfigMapping(ConfigStore): if filename and os.path.isfile(filename): self.set("[HardDisk]", "bUseHardDiskImage", True) self.set("[HardDisk]", "szHardDiskImage", filename) - self._change_option("--acsi %s" % filename) + self._change_option("--acsi", str(filename)) # ------------ IDE master (file) --------------- def get_idemaster_image(self): @@ -567,7 +577,7 @@ class HatariConfigMapping(ConfigStore): if filename and os.path.isfile(filename): self.set("[HardDisk]", "bUseIdeMasterHardDiskImage", True) self.set("[HardDisk]", "szIdeMasterHardDiskImage", filename) - self._change_option("--ide-master %s" % filename) + self._change_option("--ide-master", str(filename)) # ------------ IDE slave (file) --------------- def get_ideslave_image(self): @@ -578,7 +588,7 @@ class HatariConfigMapping(ConfigStore): if filename and os.path.isfile(filename): self.set("[HardDisk]", "bUseIdeSlaveHardDiskImage", True) self.set("[HardDisk]", "szIdeSlaveHardDiskImage", filename) - self._change_option("--ide-slave %s" % filename) + self._change_option("--ide-slave", str(filename)) # ------------ TOS ROM --------------- def get_tos(self): @@ -586,7 +596,7 @@ class HatariConfigMapping(ConfigStore): def set_tos(self, filename): self.set("[ROM]", "szTosImageFileName", filename) - self._change_option("--tos %s" % filename) + self._change_option("--tos", str(filename)) # ------------ memory --------------- def get_memory_names(self): @@ -661,6 +671,22 @@ class HatariConfigMapping(ConfigStore): self.set("[Screen]", "bKeepResolution", value) self._change_option("--desktop %s" % str(value)) + # --------- keep desktop res - st ------ + def get_desktop_st(self): + return self.get("[Screen]", "bKeepResolutionST") + + def set_desktop_st(self, value): + self.set("[Screen]", "bKeepResolutionST", value) + self._change_option("--desktop-st %s" % str(value)) + + # ------------ force max --------------- + def get_force_max(self): + return self.get("[Screen]", "bForceMax") + + def set_force_max(self, value): + self.set("[Screen]", "bForceMax", value) + self._change_option("--force-max %s" % str(value)) + # ------------ show borders --------------- def get_borders(self): return self.get("[Screen]", "bAllowOverscan")