summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoui Chang <louipc.ist@gmail.com>2008-12-10 01:51:50 -0500
committerLoui Chang <louipc.ist@gmail.com>2008-12-10 21:11:52 -0500
commit5b47a29d2b0665f41ddd2e045ef926e8b3aa2368 (patch)
treea6c6b2fcd116f6b57b586b4f7092e993f1247564
parenta195e38901915567ad0e6c3b3ae252434bf99b47 (diff)
Add some more error checking to tupkgupdate.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
-rwxr-xr-xtupkg/update/tupkgupdate23
1 files changed, 15 insertions, 8 deletions
diff --git a/tupkg/update/tupkgupdate b/tupkg/update/tupkgupdate
index 06154e8..63314d4 100755
--- a/tupkg/update/tupkgupdate
+++ b/tupkg/update/tupkgupdate
@@ -355,7 +355,8 @@ def usage(name):
print " -c, --config Specify a path to the config file."
print " -n Don't actually perform any action on the repo."
print " --delete Delete duplicate and temporary pkgs."
- print " --paranoid Warn about duplicate pkgs that aren't identical via `cmp`."
+ print " --paranoid Warn of duplicate pkgs that aren't identical."
+ sys.exit(1)
############################################################
# MAIN
@@ -369,7 +370,6 @@ try:
['config=', 'delete', 'paranoid'])
except getopt.GetoptError:
usage(sys.argv[0])
- sys.exit(1)
switches = {}
for opt in optlist:
@@ -378,13 +378,15 @@ for opt in optlist:
# Check for required arguments.
if (len(args) < 3):
usage(sys.argv[0])
- sys.exit(-1)
for opt, value in optlist:
if opt in ('-c', '--config'):
conffile = value
-repo_dir, pkgbuild_dir, build_dir = args
+try:
+ repo_dir, pkgbuild_dir, build_dir = args
+except ValueError:
+ usage(sys.argv[0])
if not os.path.isfile(conffile):
print "Error: cannot access config file (%s)" % conffile
@@ -402,10 +404,15 @@ else:
# Open the database if we need it so we find out now if we can't!
if config_use_db:
- db = PackageDatabase(config.get('mysql', 'host'),
- config.get('mysql', 'username'),
- config.get('mysql', 'password'),
- config.get('mysql', 'db'))
+ try:
+ db = PackageDatabase(config.get('mysql', 'host'),
+ config.get('mysql', 'username'),
+ config.get('mysql', 'password'),
+ config.get('mysql', 'db'))
+ except:
+ print "Error: Could not connect to the database %s at %s." % (
+ config.get('mysql', 'db'), config.get('mysql', 'host'))
+ sys.exit(1)
# Set up the lists and tables
packages = dict()