summaryrefslogtreecommitdiffstats
path: root/tupkg/server
diff options
context:
space:
mode:
authorjchu <jchu>2004-09-03 19:48:42 +0000
committerjchu <jchu>2004-09-03 19:48:42 +0000
commit25b010480680d8f2f5d0cb2a12fa635aec50bc52 (patch)
tree45f347eaa93ccbc2a981dede597d8514b57bd57a /tupkg/server
parenta4710414e0efcb456bcd725c5956547edc4162af (diff)
downloadaurweb-25b010480680d8f2f5d0cb2a12fa635aec50bc52.tar.xz
added a little bit better messaging, getopts to server side, stuff for mysql access, and config file support
Diffstat (limited to 'tupkg/server')
-rwxr-xr-xtupkg/server/tupkgs37
-rw-r--r--tupkg/server/tupkgs.conf4
2 files changed, 38 insertions, 3 deletions
diff --git a/tupkg/server/tupkgs b/tupkg/server/tupkgs
index 4dd085b..213e462 100755
--- a/tupkg/server/tupkgs
+++ b/tupkg/server/tupkgs
@@ -22,8 +22,16 @@ import struct
import cgi
import urllib
import md5
+import MySQLdb
+import MySQLdb.connections
+import ConfigParser
+import getopt
+import os.path
CACHEDIR = '/var/cache/tupkgs/'
+CONFIGFILE = '/etc/tupkgs.conf'
+
+config = ConfigParser.ConfigParser()
class ClientFile:
def __init__(self, filename, actual_size, actual_md5):
@@ -155,23 +163,46 @@ class ServerSocket(threading.Thread):
sread, swrite, serror = select.select([self.socket],[self.socket],[self.socket],5)
if sread:
(clientsocket, address) = self.socket.accept()
+ print "New connection from " + str(address)
ct = ClientSocket(clientsocket)
ct.start()
self.clients.append(ct)
- print len(self.clients)
self.clients = filter(self._clean, self.clients)
- print len(self.clients)
self.socket.close()
[x.close() for x in self.clients]
[x.join() for x in self.clients]
+def usage(name):
+ print "usage: " + name + " [options]"
+ print "options:"
+ print " -c, --config Specify an alternate config file (default " + CONFIGFILE + ")"
+ sys.exit(2)
+
def main(argv=None):
if argv is None:
argv = sys.argv
+ try:
+ optlist, args = getopt.getopt(argv[1:], "c:", ["config="])
+ except getopt.GetoptError:
+ usage(argv[0])
+
+ conffile = CONFIGFILE
+
+ for i, k in optlist:
+ if i in ('-c', '--config'):
+ conffile = k
+
+ if not os.path.isfile(conffile):
+ print "Error: cannot access config file ("+conffile+")"
+ usage(argv[0])
+
+ config.read(conffile)
+
running = 1
+ print "Starting ServerSocket"
servsock = ServerSocket()
servsock.start()
@@ -182,7 +213,7 @@ def main(argv=None):
except KeyboardInterrupt:
running = 0
- print "Just cleaning up stuff"
+ print "Cleaning up stuff"
servsock.close()
diff --git a/tupkg/server/tupkgs.conf b/tupkg/server/tupkgs.conf
new file mode 100644
index 0000000..7e0ecbf
--- /dev/null
+++ b/tupkg/server/tupkgs.conf
@@ -0,0 +1,4 @@
+[mysql]
+username = aur
+password = aur
+host = localhost