mirror of
https://github.com/gsi-upm/senpy
synced 2025-10-15 09:42:22 +00:00
Several fixes and changes
* Added interactive debugging * Better exception logging * More tests for errors * Added ONBUILD to dockerfile Now creating new images based on senpy's is as easy as: ```from senpy:<version>```. This will automatically mount the code to /senpy-plugins and install all dependencies * Added /data as a VOLUME * Added `--use-wheel` to pip install both on the image and in the auto-install function. * Closes #9 Break compatibilitity: * Removed ability to (de)activate plugins through the web
This commit is contained in:
@@ -26,6 +26,7 @@ from gevent.wsgi import WSGIServer
|
||||
from gevent.monkey import patch_all
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import senpy
|
||||
|
||||
@@ -34,6 +35,22 @@ patch_all(thread=False)
|
||||
SERVER_PORT = os.environ.get("PORT", 5000)
|
||||
|
||||
|
||||
def info(type, value, tb):
|
||||
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
|
||||
# we are in interactive mode or we don't have a tty-like
|
||||
# device, so we call the default hook
|
||||
sys.__excepthook__(type, value, tb)
|
||||
else:
|
||||
import traceback
|
||||
import pdb
|
||||
# we are NOT in interactive mode, print the exception...
|
||||
traceback.print_exception(type, value, tb)
|
||||
print
|
||||
# ...then start the debugger in post-mortem mode.
|
||||
# pdb.pm() # deprecated
|
||||
pdb.post_mortem(tb) # more "modern"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Run a Senpy server')
|
||||
parser.add_argument(
|
||||
@@ -84,6 +101,8 @@ def main():
|
||||
rl.setLevel(getattr(logging, args.level))
|
||||
app = Flask(__name__)
|
||||
app.debug = args.debug
|
||||
if args.debug:
|
||||
sys.excepthook = info
|
||||
sp = Senpy(app, args.plugins_folder, default_plugins=args.default_plugins)
|
||||
if args.only_install:
|
||||
sp.install_deps()
|
||||
|
Reference in New Issue
Block a user