Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Commit

Permalink
Using actual ConfigParser call; dingd has -c for config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bandie committed May 2, 2020
1 parent 3e7f23c commit 57fb2f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ding
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def readConfig():
else:
CONFIG = "ding.cfg"

cfg = configparser.SafeConfigParser()
cfg = configparser.ConfigParser()
try:
cfg.read(CONFIG)

Expand Down
28 changes: 19 additions & 9 deletions dingd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Author: Bandie Canis
# License: 2-Clause BSD license

import ssl, socket, subprocess, time, os, sys
import ssl, socket, subprocess, time, os, sys, getopt
import configparser

CONFIG = None
Expand All @@ -26,7 +26,7 @@ def getTimestamp():
return t

def execFromConfig(option, pw=False):
cfg = configparser.SafeConfigParser()
cfg = configparser.ConfigParser()
cfg.read(CONFIG)

if(pw):
Expand Down Expand Up @@ -107,16 +107,19 @@ def main():
except EOFError:
print(getTimestamp(), "EOF")

def init():
def init(cfg=None):

global CONFIG, host, port, cafile, certfile, keyfile, pw_on, password, pwtimeout, tmppw_on, context, bindsocket

if(os.name == 'nt'):
CONFIG = "dingd.win.cfg"
if(cfg==None):
if(os.name == 'nt'):
CONFIG = "dingd.win.cfg"
else:
CONFIG = "dingd.cfg"
else:
CONFIG = "dingd.cfg"
CONFIG = cfg

cfg = configparser.SafeConfigParser()
cfg = configparser.ConfigParser()
cfg.read(CONFIG)

try:
Expand Down Expand Up @@ -176,10 +179,17 @@ def init():


if(__name__ == "__main__"):

try:
init()
conf = None
opts, args = getopt.getopt(sys.argv[1:], "c:")
for o, a in opts:
if o == "-c":
conf = a
init(conf)
main()
except getopt.GetoptError as e:
print("Error using options. Allowed options:\n-c [FILE] - Config file\n")
quit(2)
except KeyboardInterrupt:
print("\r\rServer stopped.")

0 comments on commit 57fb2f7

Please sign in to comment.