summaryrefslogtreecommitdiffstats
path: root/tupkg/server
diff options
context:
space:
mode:
authorjchu <jchu>2004-09-03 20:27:15 +0000
committerjchu <jchu>2004-09-03 20:27:15 +0000
commitf841dbcf1ba07c841990186341c04a0c31da1cd5 (patch)
tree64c9b3294d644c8fe2a7cf7f2feb44cb9eaf97ee /tupkg/server
parent03157ad2395a6d664306648d06e03e26e7c5d33d (diff)
downloadaurweb-f841dbcf1ba07c841990186341c04a0c31da1cd5.tar.xz
a little more robust config stuff
Diffstat (limited to 'tupkg/server')
-rwxr-xr-xtupkg/server/tupkgs21
-rw-r--r--tupkg/server/tupkgs.conf3
2 files changed, 22 insertions, 2 deletions
diff --git a/tupkg/server/tupkgs b/tupkg/server/tupkgs
index a1d343c..63abaea 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:
diff --git a/tupkg/server/tupkgs.conf b/tupkg/server/tupkgs.conf
index 94b6fad..ab31db9 100644
--- a/tupkg/server/tupkgs.conf
+++ b/tupkg/server/tupkgs.conf
@@ -1,3 +1,6 @@
+[tupkgs]
+port = 1034
+
[mysql]
username = aur
password = aur