aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2019-02-27 09:04:57 +0100
committerPapoteur <papoteur@mageia.org>2019-02-27 09:04:57 +0100
commit7b9fed841bba9e7fc390603db7bc789f4829d627 (patch)
treee9aab3445dac67d3369b653f0afd27e2cfe110b9 /MgaRepo
parent837d162973d2030d446a5ecd6ae0d5aa551881dc (diff)
downloadmgarepo-7b9fed841bba9e7fc390603db7bc789f4829d627.tar
mgarepo-7b9fed841bba9e7fc390603db7bc789f4829d627.tar.gz
mgarepo-7b9fed841bba9e7fc390603db7bc789f4829d627.tar.bz2
mgarepo-7b9fed841bba9e7fc390603db7bc789f4829d627.tar.xz
mgarepo-7b9fed841bba9e7fc390603db7bc789f4829d627.zip
Manage exception with maintdb command
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/commands/maintdb.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/MgaRepo/commands/maintdb.py b/MgaRepo/commands/maintdb.py
index 83621b1..ad830b4 100644
--- a/MgaRepo/commands/maintdb.py
+++ b/MgaRepo/commands/maintdb.py
@@ -34,8 +34,16 @@ def maintdb(maintdb_args):
host = config.get("maintdb", "host", "maintdb.mageia.org")
if (maintdb_args[0] == 'get' and len(maintdb_args)>=2):
import urllib.request
- page=urllib.request.urlopen('http://'+host+'/'+maintdb_args[1])
- rep = page.read().decode('utf8')
+ try:
+ page=urllib.request.urlopen('http://'+host+'/'+maintdb_args[1])
+ rep = page.read().decode('utf8')
+ except urllib.error.HTTPError as e:
+ if e.code == 404 :
+ rep = "There is no package named {}".format(maintdb_args[1])
+ else:
+ rep = e.reason
+ except Exception as e:
+ rep = "Error trying to query the database : {}. Have you active Internet connection?".format(e.reason)
print(rep)
else:
maintdb_helper = get_helper("maintdb")