mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 00:02:28 +00:00
Added indentation and default plugins
* setup.py:
This commit is contained in:
parent
7c2e0ddec7
commit
b484b453e0
@ -17,7 +17,3 @@
|
||||
"""
|
||||
Sentiment analysis server in Python
|
||||
"""
|
||||
|
||||
import extensions
|
||||
import blueprints
|
||||
import plugins
|
||||
|
@ -44,6 +44,10 @@ if __name__ == '__main__':
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Run the application in debug mode')
|
||||
parser.add_argument('--default-plugins',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Run the application in debug mode')
|
||||
parser.add_argument('--host',
|
||||
type=str,
|
||||
default="127.0.0.1",
|
||||
@ -62,14 +66,14 @@ if __name__ == '__main__':
|
||||
logging.basicConfig(level=getattr(logging, args.level))
|
||||
app = Flask(__name__)
|
||||
app.debug = args.debug
|
||||
sp = Senpy(app, args.plugins_folder)
|
||||
sp = Senpy(app, args.plugins_folder, default_plugins=args.default_plugins)
|
||||
sp.activate_all()
|
||||
import logging
|
||||
http_server = WSGIServer((args.host, args.port), app)
|
||||
try:
|
||||
print "Server running on port %s:%d. Ctrl+C to quit" % (args.host,
|
||||
args.port)
|
||||
print("Server running on port %s:%d. Ctrl+C to quit" % (args.host,
|
||||
args.port))
|
||||
http_server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
http_server.stop()
|
||||
print "Bye!"
|
||||
print("Bye!")
|
||||
|
@ -27,14 +27,14 @@ class Senpy(object):
|
||||
|
||||
""" Default Senpy extension for Flask """
|
||||
|
||||
def __init__(self, app=None, plugin_folder="plugins", base_plugins=True):
|
||||
def __init__(self, app=None, plugin_folder="plugins", default_plugins=False):
|
||||
self.app = app
|
||||
|
||||
self._search_folders = set()
|
||||
self._outdated = True
|
||||
|
||||
self.add_folder(plugin_folder)
|
||||
if base_plugins:
|
||||
if default_plugins:
|
||||
base_folder = os.path.join(os.path.dirname(__file__), "plugins")
|
||||
self.add_folder(base_folder)
|
||||
|
||||
|
@ -154,7 +154,7 @@ class Leaf(dict):
|
||||
' type="application/ld+json"' % url)
|
||||
}
|
||||
del js["@context"]
|
||||
return FlaskResponse(json.dumps(js),
|
||||
return FlaskResponse(json.dumps(js, indent=4),
|
||||
status=self.get("status", 200),
|
||||
headers=headers,
|
||||
mimetype="application/json")
|
||||
|
3
setup.py
3
setup.py
@ -15,7 +15,7 @@ except AttributeError:
|
||||
install_reqs = [str(ir.req) for ir in install_reqs]
|
||||
test_reqs = [str(ir.req) for ir in test_reqs]
|
||||
|
||||
VERSION = "0.4.6"
|
||||
VERSION = "0.4.7"
|
||||
|
||||
setup(
|
||||
name='senpy',
|
||||
@ -34,5 +34,6 @@ extendable, so new algorithms and sources can be used.
|
||||
classifiers=[],
|
||||
install_requires=install_reqs,
|
||||
tests_require=test_reqs,
|
||||
test_suite="nose.collector",
|
||||
include_package_data=True,
|
||||
)
|
||||
|
@ -0,0 +1,3 @@
|
||||
nose
|
||||
mock
|
||||
pbr
|
@ -15,7 +15,7 @@ class ExtensionsTest(TestCase):
|
||||
def create_app(self):
|
||||
self.app = Flask("test_extensions")
|
||||
self.dir = os.path.join(os.path.dirname(__file__), "..")
|
||||
self.senpy = Senpy(plugin_folder=self.dir, base_plugins=False)
|
||||
self.senpy = Senpy(plugin_folder=self.dir, default_plugins=False)
|
||||
self.senpy.init_app(self.app)
|
||||
self.senpy.activate_plugin("Dummy", sync=True)
|
||||
return self.app
|
||||
|
Loading…
Reference in New Issue
Block a user