diff options
| author | Fulgen301 <tokmajigeorge@gmailc.om> | 2017-06-18 13:58:21 +0200 |
|---|---|---|
| committer | Fulgen301 <tokmajigeorge@gmail.com> | 2017-07-11 11:10:32 +0200 |
| commit | eb3d7298fda73b82cbbf1beef6568c335aaf5714 (patch) | |
| tree | b5d53163861ad174387582485868d1c559506717 | |
| parent | 8973840bd12b86de5ff1b6588b46273b414ef984 (diff) | |
| download | pycrctrl-eb3d7298fda73b82cbbf1beef6568c335aaf5714.tar.gz pycrctrl-eb3d7298fda73b82cbbf1beef6568c335aaf5714.zip | |
Fix config loading and writeToServer method
| -rw-r--r-- | pycrctrl/__pycache__/pycrctrl.cpython-36.pyc | bin | 0 -> 20344 bytes | |||
| -rw-r--r-- | pycrctrl/pycrctrl.py | 12 |
2 files changed, 6 insertions, 6 deletions
diff --git a/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc b/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..23e4767 --- /dev/null +++ b/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc diff --git a/pycrctrl/pycrctrl.py b/pycrctrl/pycrctrl.py index 09692b9..6c86940 100644 --- a/pycrctrl/pycrctrl.py +++ b/pycrctrl/pycrctrl.py @@ -255,7 +255,6 @@ class PyCRCtrl(object): self.loadConfigFile(config) self.loadCapabilities() self.loadScenarioList() - self.codec = QTextCodec.codecForName(self.config.get("encoding")) self.queue = queue.Queue(5) if self.config["Clonk"]["Updater"]["enabled"]: @@ -377,11 +376,11 @@ class PyCRCtrl(object): return True def setupConfig(self, config): + #codec + self.codec = QTextCodec.codecForName(config["Clonk"]["encoding"]) #commandline sep = ":" if config["Clonk"]["commandlinePrefix"] == "/" else "=" - config["Clonk"]["commandline"] = " ".join([ - "{}{}".format(config["Clonk"]["commandlinePrefix"], sep.join(entry) if isinstance(entry, list) else entry) for entry in config["Clonk"]["commandline"] - ]) + config["Clonk"]["commandline"] = " ".join("{}{}".format(config["Clonk"]["commandlinePrefix"], (sep.join(str(entry)) if isinstance(entry, list) else str(entry))) for entry in config["Clonk"]["commandline"]) #regexps @@ -390,6 +389,7 @@ class PyCRCtrl(object): } self.ingamechat = config["Clonk"]["IRC"]["ingamechat"] + return config def decodeRegExp(self, regexp): return self.codec.toUnicode(base64.b64decode(regexp)) @@ -540,9 +540,9 @@ class PyCRCtrl(object): return (CmdResult.RuntimeError, "") elif type(text) not in [bytes, QByteArray]: try: - text = self.codec.toUnicode(text) + text = self.codec.fromUnicode(text) except: - raise IOError("Cannot write anything else to the server except the following data types: QString, bytes, str, QByteArray") + raise IOError("Cannot write anything else to the server except the following data types: QString, bytes, str, QByteArray (got {})".format(type(text).__name__)) if self.clonk and self.clonk.stdin: self.clonk.stdin.write(bytes(text) + b"\n") |
