From c6d02d9085ea38cf7bc2e49488da15a9cc0e3c3b Mon Sep 17 00:00:00 2001 From: Fulgen301 Date: Mon, 10 Jul 2017 21:30:18 +0200 Subject: PyCRCtrl.setupConfig: Fix commandline parsing --- pycrctrl/pycrctrl.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pycrctrl/pycrctrl.py b/pycrctrl/pycrctrl.py index 19a482b..584341f 100644 --- a/pycrctrl/pycrctrl.py +++ b/pycrctrl/pycrctrl.py @@ -312,7 +312,16 @@ class PyCRCtrl(object): def setupConfig(self, config): #commandline sep = ":" if config["Clonk"]["commandlinePrefix"] == "/" else "=" - config["Clonk"]["commandline"] = " ".join("{}{}".format(config["Clonk"]["commandlinePrefix"], (sep.join(entry) if isinstance(entry, list) else str(entry))) for entry in config["Clonk"]["commandline"]) + + res = "" + for entry in config["Clonk"]["commandline"]: + if isinstance(entry, dict): + for i in entry.items(): + res += "{}{}{}{} ".format(config["Clonk"]["commandlinePrefix"], (i[0]), sep, str(i[1])) + else: + res += "{}{} ".format(config["Clonk"]["commandlinePrefix"], entry) + + config["Clonk"]["commandline"] = res #regexps @@ -329,11 +338,11 @@ class PyCRCtrl(object): def host(self, scenario=None, user=None) -> str: if scenario == None: return (CmdResult.SyntaxFail, "Bitte gib einen Szenarionamen an!") - if type(scenario) in [bytes, QByteArray]: + if hasattr(scenario, "decode"): try: - scenario = scenario.decode(self.config["Clonk"]["encoding"]) + scenario = scenario.decode(self.config["Clonk"]["encoding"], "replace") except: - return (CmdResult.SyntaxFail, "Unbekannter Datentyp!") + return (CmdResult.RuntimeError, "Dekodierfehler. Bitte kontaktiere den Hoster dieses Servers.") scenario = scenario.splitlines()[0] if scenario == "random": -- cgit v1.2.3-54-g00ecf