diff options
| author | Fulgen301 <tokmajigeorge@gmail.com> | 2017-03-17 18:05:14 +0100 |
|---|---|---|
| committer | Fulgen301 <tokmajigeorge@gmail.com> | 2017-07-11 11:10:30 +0200 |
| commit | ec0fd2df4f6f2110a9a9ba0ff73808fd883e8440 (patch) | |
| tree | 0ebcc6f60beff5e31a00e819c501e4542493effb | |
| parent | fd0d5640e25017cc8b4ebcd6dbc084527b233334 (diff) | |
| download | pycrctrl-ec0fd2df4f6f2110a9a9ba0ff73808fd883e8440.tar.gz pycrctrl-ec0fd2df4f6f2110a9a9ba0ff73808fd883e8440.zip | |
pycrctrl.py: Add basic configuration file which is generated at first use
| -rw-r--r-- | pycrctrl.py | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/pycrctrl.py b/pycrctrl.py index 4b87516..01b9b90 100644 --- a/pycrctrl.py +++ b/pycrctrl.py @@ -256,6 +256,7 @@ class PyCRCtrl(object): self.loadCapabilities() self.loadScenarioList() self.codec = QTextCodec.codecForName(self.config.get("encoding")) + self.queue = queue.Queue(5) if self.config.get("engine") == "openclonk-server": self.updater = Updater(self) @@ -308,8 +309,69 @@ class PyCRCtrl(object): if self.path == None: return False - self.config = json.load(open(os.path.join(self.path, config),"r")) - return True + config = os.path.join(self.path, config) + + if os.path.isdir(config): + return False + + elif os.path.isfile(config): + self.config = json.load(open(os.path.join(self.path, config),"r")) + return True + + elif not os.path.exists(config): + c = { + "General" : { + "Directories" : { + "plugins" : [] + }, + "useLogfile" : True, + }, + + "Clonk" : { + "engine" : "clonk", + "commandline" : ["fullscreen", ["lobby",300], ["config","config.txt"], "record", "faircrew"], + "commandlinePrefix" : "/", + "prefix" : "@", + + "Channels" : { + "parent" : "", + "ingame" : "" + }, + + "RegExps" : { + "lobbyStartExp" : "", + "startExp" : "", + "joinExp" : "", + "leaveExp" : "", + "shutdownExp" : "" + } + + "autohost" : False, + "IRC" : { + "ingamechat" : True + }, + + "Rights" : { + "admin" : True, + "moderator" : True + } + }, + + "Updater" : { + "enabled" : False, + "Addresses" : { + "snapshotList" : "", + "snapshotDownload" : "", + "autobuildList" : "", + "autobuildAddress" : "" + } + } + } + } + + json.dump(c, open(config, "w")) + return c + def decodeRegExp(self, regexp): return self.codec.toUnicode(base64.b64decode(regexp)) @@ -635,6 +697,9 @@ class PyCRCtrl(object): except KeyError: return False + + def registerHook(self, hook, function, replace=False): + pass # # |
