summaryrefslogtreecommitdiff
path: root/tupkg/client
diff options
context:
space:
mode:
authorjchu <jchu>2004-09-03 20:46:03 +0000
committerjchu <jchu>2004-09-03 20:46:03 +0000
commit90473a79d3be3041eed7f9c9cbb32a10f4804b65 (patch)
treed984da90e4cb3df244c25bd1ee9eb95854f34910 /tupkg/client
parent47b7a53460953650eeadb2140da38095cd426628 (diff)
added getopts to tupkg
Diffstat (limited to 'tupkg/client')
-rwxr-xr-xtupkg/client/tupkg34
1 files changed, 31 insertions, 3 deletions
diff --git a/tupkg/client/tupkg b/tupkg/client/tupkg
index 125288a..a96923e 100755
--- a/tupkg/client/tupkg
+++ b/tupkg/client/tupkg
@@ -20,6 +20,7 @@ import os.path
import cgi
import urllib
import md5
+import getopt
class ClientFile:
def __init__(self, pathname):
@@ -111,18 +112,45 @@ class ClientSocket:
self.sendMsg("ack")
def usage():
- print "usage: tupkg <package file>"
+ print "usage: tupkg [options] <package file>"
+ print "options:"
+ print " -u, --user Connect with username"
+ print " -P, --password Connect with password"
+ print " -h, --host Connect to host"
+ print " -p, --port Connect to host on port (default 1034)"
def main(argv=None):
if argv is None:
argv = sys.argv
+ confdict = {}
+ confdict['user'] = ""
+ confdict['password'] = ""
+ confdict['host'] = ''
+ confdict['port'] = 1034
+
if len(argv) == 1:
usage()
return 1
+ try:
+ optlist, args = getopt.getopt(argv[1:], "u:P:h:p:", ["user=", "password=", "host=", "port="])
+ except getopt.GetoptError:
+ usage()
+ return 1
+
+ for i, k in optlist:
+ if i in ('-u', '--user'):
+ confdict['user'] = k
+ if i in ('-P', '--password'):
+ confdict['password'] = k
+ if i in ('-h', '--host'):
+ confdict['host'] = k
+ if i in ('-p', '--port'):
+ confdict['port'] = int(k)
+
files = []
- for i in argv[1:]:
+ for i in args:
try:
files.append(ClientFile(i))
except IOError, err:
@@ -130,7 +158,7 @@ def main(argv=None):
usage()
return 1
- cs = ClientSocket(files, 'localhost', 1034, "tu", "tu")
+ cs = ClientSocket(files, confdict['host'], confdict['port'], confdict['user'], confdict['password'])
cs.connect()
if not cs.auth():