Repository: rotki/rotki

Issue:
python -m rotkehlchen --help throws an exception
Trying to invoke `--help` on the python backend shows the usage and help text but after that throws an exception.

This is the output:
```
  --loglevel {debug,info,warn,error,critical}
                        Choose the logging level
  --logfromothermodules
                        If given then logs from all all imported modules that
                        use the logging system will also be visible.
CRITICAL:root:Traceback (most recent call last):
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/__main__.py", line 12, in main
    rotkehlchen_server = RotkehlchenServer()
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/server.py", line 65, in __init__
    self.args = app_args()
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/args.py", line 72, in app_args
    args = p.parse_args()
  File "/usr/lib64/python3.6/argparse.py", line 1730, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.6/argparse.py", line 1762, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.6/argparse.py", line 1968, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib64/python3.6/argparse.py", line 1908, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib64/python3.6/argparse.py", line 1836, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib64/python3.6/argparse.py", line 1021, in __call__
    parser.exit()
  File "/usr/lib64/python3.6/argparse.py", line 2376, in exit
    _sys.exit(status)
SystemExit: 0

Failed to start rotkehlchen backend:
Traceback (most recent call last):
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/__main__.py", line 12, in main
    rotkehlchen_server = RotkehlchenServer()
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/server.py", line 65, in __init__
    self.args = app_args()
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/args.py", line 72, in app_args
    args = p.parse_args()
  File "/usr/lib64/python3.6/argparse.py", line 1730, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.6/argparse.py", line 1762, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.6/argparse.py", line 1968, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib64/python3.6/argparse.py", line 1908, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib64/python3.6/argparse.py", line 1836, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib64/python3.6/argparse.py", line 1021, in __call__
    parser.exit()
  File "/usr/lib64/python3.6/argparse.py", line 2376, in exit
    _sys.exit(status)
SystemExit: 0
```

This should be really easy to fix. Simply add another `except` [here](https://github.com/rotkehlchenio/rotkehlchen/blob/486866234804c64ee7e7c581cc1bc7f7841bec96/rotkehlchen/__main__.py#L13) and catch the `SystemExit` exception and in the case it's a clean exit, let it exit cleanly and if not print a stack trace.

Like that:

```
    except SystemExit as e:
        if e.code is None or e.code == 0:
            sys.exit(0)
        else:
            tb = traceback.format_exc()
            logging.critical(tb)
            print("Failed to start rotkehlchen backend:\n{}".format(tb))
            sys.exit(e.code)
```

```
```



Discussion:

Resolving patch:
diff --git a/rotkehlchen/__main__.py b/rotkehlchen/__main__.py
--- a/rotkehlchen/__main__.py
+++ b/rotkehlchen/__main__.py
@@ -10,6 +10,14 @@ def main():
     from rotkehlchen.server import RotkehlchenServer
     try:
         rotkehlchen_server = RotkehlchenServer()
+    except SystemExit as e:
+        if e.code is None or e.code == 0:
+            sys.exit(0)
+        else:
+            tb = traceback.format_exc()
+            logging.critical(tb)
+            print("Failed to start rotkehlchen backend:\n{}".format(tb))
+            sys.exit(1)
     except: # noqa
         tb = traceback.format_exc()
         logging.critical(tb)


Test patch: