From 7e4ae2fc0aec745a690195121193bff001242751 Mon Sep 17 00:00:00 2001 From: merspieler Date: Thu, 4 Apr 2019 06:48:30 +0000 Subject: [PATCH] Reworked return codes Signed-off-by: merspieler --- README.md | 7 +++++++ build | 4 ++-- create-project | 6 +++--- create-venv | 1 + edit-settings | 4 ++-- install | 6 +++--- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 71cd125..8e3bee2 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,12 @@ Programs that were not covered by `Getting started`: It will make sure, that everything is in the correct format and in the correct datatype. * `./delete-db `: Deletes the database. +## Return codes +* 0: Success +* 1: Argument error +* 2: IO error. An error with a file or database +* 3: Child process failed/can not be called +* 130: Aborted by user. + ## User scripts User scripts in the `scripts/` directory are help scripts contributed by users. They Do not belong to the easy-osm2city concept but extend it. Use only if you know what you do. diff --git a/build b/build index ce8dde0..e3e45d8 100755 --- a/build +++ b/build @@ -151,7 +151,7 @@ def run_command(command): return elif exit_code == 130: print("Interrupted by user. Aborting...") - sys.exit(0) + sys.exit(130) start_time = time.time() @@ -180,7 +180,7 @@ try: project_bounds = get_bounds("projects/" + project + "/settings") if project_bounds == []: print("Unable to read project settings") - sys.exit(1) + sys.exit(2) start_bounds = start_bounds[0] project_bounds = project_bounds[0] if start_bounds["north"] == project_bounds["north"] and start_bounds["east"] == project_bounds["east"]: diff --git a/create-project b/create-project index b3a8916..f0f4737 100755 --- a/create-project +++ b/create-project @@ -56,12 +56,12 @@ fi source general-settings > /dev/null if [ $? == 1 ]; then echo "Couldn't find the general settings. Please run ./install first." - exit 1 + exit 2 fi if [ ! -f ".databases" ]; then echo "There are no databases created by easy-osm2city. Please create one by running ./create-db" - exit 1 + exit 2 fi echo "Which database do you want to use?" @@ -70,7 +70,7 @@ cat .databases | grep -e "$db_name" > /dev/null if [ $? == 1 ]; then echo "Database doesn't exsist. Please choose a different database or create one by running" echo "./create-db -d $db_name" - exit 1 + exit 2 fi mkdir -p "projects/$project/scenery" diff --git a/create-venv b/create-venv index d44b5aa..81acdce 100755 --- a/create-venv +++ b/create-venv @@ -54,4 +54,5 @@ if [ $? == 1 ]; then echo "shapely" echo "psycopg2-binary" echo "NOTE: use 'source venv/bin/activate' before you install the packages" + exit 3 fi diff --git a/edit-settings b/edit-settings index 34012d2..2974c9a 100755 --- a/edit-settings +++ b/edit-settings @@ -68,7 +68,7 @@ if project == "": if os.path.isfile("projects/" + project + "/params.ini") == False: print("Project '" + project + "' not found") - sys.exit(1) + sys.exit(2) console_height, console_width = os.popen('stty size', 'r').read().split() @@ -116,7 +116,7 @@ try: option["value"] = int(value) except: print("A problem occured while reading the params.ini file...") - sys.exit(1) + sys.exit(2) finally: ini_file.close() diff --git a/install b/install index 7614547..11633fd 100755 --- a/install +++ b/install @@ -72,7 +72,7 @@ if [ "$skip_install" != 1 ]; then echo "git" echo "Then rerun this script with skip-install argument" echo "./install --skip-install" - exit 1 + exit 3 fi sudo apt-get install -y git osmosis postgis pgadmin3 postgresql-contrib postgresql-client postgresql-postgis postgresql python-pip python3-venv if [ $? == 100 ]; then @@ -91,7 +91,7 @@ if [ "$skip_install" != 1 ]; then echo "git" echo "Then rerun this script with skip-install argument" echo "./install --skip-install" - exit 1 + exit 3 fi fi @@ -102,7 +102,7 @@ if [ "$skip_git" != 1 ]; then echo "https://gitlab.com/fg-radi/osm2city" echo "https://gitlab.com/fg-radi/osm2city-data" echo "Unzip them in this directory and make sure, the are named osm2city and osm2city-data" - exit 1 + exit 3 fi git clone https://gitlab.com/fg-radi/osm2city.git git clone https://gitlab.com/fg-radi/osm2city-data.git