summaryrefslogtreecommitdiffstats
path: root/tupkg/server/tupkgs
diff options
context:
space:
mode:
authorjchu <jchu>2004-09-03 22:27:15 +0200
committerjchu <jchu>2004-09-03 22:27:15 +0200
commitf841dbcf1ba07c841990186341c04a0c31da1cd5 (patch)
tree64c9b3294d644c8fe2a7cf7f2feb44cb9eaf97ee /tupkg/server/tupkgs
parent03157ad2395a6d664306648d06e03e26e7c5d33d (diff)
downloadaur-f841dbcf1ba07c841990186341c04a0c31da1cd5.tar.gz
aur-f841dbcf1ba07c841990186341c04a0c31da1cd5.tar.xz
a little more robust config stuff
Diffstat (limited to 'tupkg/server/tupkgs')
-rwxr-xr-xtupkg/server/tupkgs21
1 files changed, 19 insertions, 2 deletions
diff --git a/tupkg/server/tupkgs b/tupkg/server/tupkgs
index a1d343c9..63abaea0 100755
--- a/tupkg/server/tupkgs
+++ b/tupkg/server/tupkgs
@@ -160,7 +160,7 @@ class ClientSocket(threading.Thread):
self.readFiles()
class ServerSocket(threading.Thread):
- def __init__(self, db, port=1034, maxqueue=5, **other):
+ def __init__(self, db, port, maxqueue, **other):
threading.Thread.__init__(self, *other)
self.running = 1
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -199,10 +199,20 @@ def usage(name):
print " -c, --config Specify an alternate config file (default " + CONFIGFILE + ")"
sys.exit(2)
+def getDefaultConfig():
+ confdict = {}
+ confdict['port'] = 1034
+ confdict['maxqueue'] = 5
+
+ return confdict
+
+
def main(argv=None):
if argv is None:
argv = sys.argv
+ confdict = getDefaultConfig()
+
try:
optlist, args = getopt.getopt(argv[1:], "c:", ["config="])
except getopt.GetoptError:
@@ -222,6 +232,13 @@ def main(argv=None):
running = 1
+ print "Parsing config file"
+ if config.has_section('tupkgs'):
+ if config.has_option('tupkgs', 'port'):
+ confdict['port'] = config.getint('tupkgs', 'port')
+ if config.has_option('tupkgs', 'maxqueue'):
+ confdict['maxqueue'] = config.getint('tupkgs', 'maxqueue')
+
print "Connecting to MySQL database"
dbconn = MySQLdb.connect(host=config.get('mysql', 'host'),
user=config.get('mysql', 'username'),
@@ -229,7 +246,7 @@ def main(argv=None):
db=config.get('mysql', 'db'))
print "Starting ServerSocket"
- servsock = ServerSocket(dbconn)
+ servsock = ServerSocket(dbconn, confdict['port'], confdict['maxqueue'])
servsock.start()
try: