def makeClient(self, ip, ratelimit=2, direct_reply=3, self_reply=False, require_email=False, require_author=False): conf = config.load(os.path.join(dist.location, "share", "isso.conf")) conf.set("general", "dbpath", self.path) conf.set("hash", "algorithm", "none") conf.set("guard", "enabled", "true") conf.set("guard", "ratelimit", str(ratelimit)) conf.set("guard", "direct-reply", str(direct_reply)) conf.set("guard", "reply-to-self", "1" if self_reply else "0") conf.set("guard", "require-email", "1" if require_email else "0") conf.set("guard", "require-author", "1" if require_author else "0") class App(Isso, core.Mixin): pass app = App(conf) app.wsgi_app = FakeIP(app.wsgi_app, ip) return Client(app, Response)
def makeClient(self, ip, ratelimit=2, direct_reply=3, self_reply=False, require_email=False, require_author=False): conf = config.load( pkg_resources.resource_filename('isso', 'defaults.ini')) conf.set("general", "dbpath", self.path) conf.set("hash", "algorithm", "none") conf.set("guard", "enabled", "true") conf.set("guard", "ratelimit", str(ratelimit)) conf.set("guard", "direct-reply", str(direct_reply)) conf.set("guard", "reply-to-self", "1" if self_reply else "0") conf.set("guard", "require-email", "1" if require_email else "0") conf.set("guard", "require-author", "1" if require_author else "0") class App(Isso, core.Mixin): pass app = App(conf) app.wsgi_app = FakeIP(app.wsgi_app, ip) return Client(app, Response)
def main(): parser = ArgumentParser(description="a blog comment hosting service") subparser = parser.add_subparsers(help="commands", dest="command") parser.add_argument('--version', action='version', version='%(prog)s ' + dist.version) parser.add_argument("-c", dest="conf", default="/etc/isso.conf", metavar="/etc/isso.conf", help="set configuration file") imprt = subparser.add_parser('import', help="import Disqus XML export") imprt.add_argument("dump", metavar="FILE") imprt.add_argument("-n", "--dry-run", dest="dryrun", action="store_true", help="perform a trial run with no changes made") imprt.add_argument("-t", "--type", dest="type", default=None, choices=["disqus", "wordpress"], help="export type") serve = subparser.add_parser("run", help="run server") args = parser.parse_args() conf = config.load(join(dist.location, "share", "isso.conf"), args.conf) if args.command == "import": conf.set("guard", "enabled", "off") if args.dryrun: xxx = tempfile.NamedTemporaryFile() dbpath = xxx.name else: dbpath = conf.get("general", "dbpath") mydb = db.SQLite3(dbpath, conf) migrate.dispatch(args.type, mydb, args.dump) sys.exit(0) if not any(conf.getiter("general", "host")): logger.error("No website(s) configured, Isso won't work.") sys.exit(1) if conf.get("server", "listen").startswith("http://"): host, port, _ = urlsplit(conf.get("server", "listen")) try: from gevent.pywsgi import WSGIServer WSGIServer((host, port), make_app(conf)).serve_forever() except ImportError: run_simple(host, port, make_app(conf), threaded=True, use_reloader=conf.getboolean('server', 'reload')) else: sock = conf.get("server", "listen").partition("unix://")[2] try: os.unlink(sock) except OSError as ex: if ex.errno != errno.ENOENT: raise wsgi.SocketHTTPServer(sock, make_app(conf)).serve_forever()
def setUp(self): fd, self.path = tempfile.mkstemp() conf = config.load(config.default_file()) conf.set("general", "dbpath", self.path) self.conf = conf class App(Isso, core.Mixin): pass self.app = App(conf) self.client = JSONClient(self.app, Response) self.post = self.client.post
def __init__(self, *confs): self.isso = {} for i, conf in enumerate(map(config.load(Dispatcher.default, conf))): if not conf.get("general", "name"): logger.warn("unable to dispatch %r, no 'name' set", confs[i]) continue self.isso["/" + conf.get("general", "name")] = make_app(conf) super(Dispatcher, self).__init__(self.default, mounts=self.isso)
def __init__(self, *confs): self.isso = {} default = os.path.join(dist.location, dist.project_name, "defaults.ini") for i, path in enumerate(confs): conf = config.load(default, path) if not conf.get("general", "name"): logger.warn("unable to dispatch %r, no 'name' set", confs[i]) continue self.isso["/" + conf.get("general", "name")] = make_app(conf) super(Dispatcher, self).__init__(self.default, mounts=self.isso)
def makeClient(self, ip): conf = config.load(config.default_file()) conf.set("general", "dbpath", self.path) conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") class App(Isso, core.Mixin): pass app = App(conf) app.wsgi_app = FakeIP(app.wsgi_app, ip) return JSONClient(app, Response)
def makeClient(self, ip): conf = config.load(os.path.join(dist.location, "share", "isso.conf")) conf.set("general", "dbpath", self.path) conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") class App(Isso, core.Mixin): pass app = App(conf) app.wsgi_app = FakeIP(app.wsgi_app, ip) return JSONClient(app, Response)
def setUp(self): fd, self.path = tempfile.mkstemp() conf = config.load(os.path.join(dist.location, "share", "isso.conf")) conf.set("general", "dbpath", self.path) conf.set("moderation", "enabled", "true") conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") class App(Isso, core.Mixin): pass self.app = App(conf) self.app.wsgi_app = FakeIP(self.app.wsgi_app, "192.168.1.1") self.client = JSONClient(self.app, Response)
def __init__(self, *confs): self.isso = {} default = pkg_resources.resource_filename('isso', 'defaults.ini') for i, path in enumerate(confs): conf = config.load(default, path) if not conf.get("general", "name"): logger.warn("unable to dispatch %r, no 'name' set", confs[i]) continue self.isso["/" + conf.get("general", "name")] = make_app(conf) super(Dispatcher, self).__init__(self.default, mounts=self.isso)
def setUp(self): fd, self.path = tempfile.mkstemp() conf = config.load( os.path.join(dist.location, dist.project_name, "defaults.ini")) conf.set("general", "dbpath", self.path) self.conf = conf class App(Isso, core.Mixin): pass self.app = App(conf) self.client = JSONClient(self.app, Response) self.post = self.client.post
def __init__(self, *confs): self.isso = {} default = os.path.join(dist.location, 'isso', "defaults.ini") for i, path in enumerate(confs): conf = config.load(default, path) if not conf.get("general", "name"): logger.warn("unable to dispatch %r, no 'name' set", confs[i]) continue self.isso["/" + conf.get("general", "name")] = make_app(conf) super(Dispatcher, self).__init__(self.default, mounts=self.isso)
def setUp(self): fd, self.path = tempfile.mkstemp() conf = config.load( pkg_resources.resource_filename('isso', 'defaults.ini')) conf.set("general", "dbpath", self.path) conf.set("moderation", "enabled", "true") conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") class App(Isso, core.Mixin): pass self.app = App(conf) self.app.wsgi_app = FakeIP(self.app.wsgi_app, "192.168.1.1") self.client = JSONClient(self.app, Response)
def makeClient(self, ip, ratelimit=2, direct_reply=3, self_reply=False): conf = config.load(os.path.join(dist.location, "share", "isso.conf")) conf.set("general", "dbpath", self.path) conf.set("hash", "algorithm", "none") conf.set("guard", "enabled", "true") conf.set("guard", "ratelimit", str(ratelimit)) conf.set("guard", "direct-reply", str(direct_reply)) conf.set("guard", "reply-to-self", "1" if self_reply else "0") class App(Isso, core.Mixin): pass app = App(conf) app.wsgi_app = FakeIP(app.wsgi_app, ip) return Client(app, Response)
def setUp(self): fd, self.path = tempfile.mkstemp() conf = config.load(config.default_file()) conf.set("general", "dbpath", self.path) conf.set("moderation", "enabled", "true") conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") class App(Isso, core.Mixin): pass self.app = App(conf) self.app.wsgi_app = FakeIP(self.app.wsgi_app, "192.168.1.1") self.client = JSONClient(self.app, Response) # add default comment rv = self.client.post( '/new?uri=test', data=json.dumps({"text": "..."})) self.assertEqual(rv.status_code, 202)
def setUp(self): fd, self.path = tempfile.mkstemp() conf = config.load(config.default_file()) conf.set("general", "dbpath", self.path) conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") conf.set("general", "latest-enabled", "true") self.conf = conf class App(Isso, core.Mixin): pass self.app = App(conf) self.app.wsgi_app = FakeIP(self.app.wsgi_app, "192.168.1.1") self.client = JSONClient(self.app, Response) self.get = self.client.get self.put = self.client.put self.post = self.client.post self.delete = self.client.delete
# -*- encoding: utf-8 -*- from __future__ import unicode_literals import os from isso import make_app from isso import dist, config application = make_app(config.load( os.path.join(dist.location, dist.project_name, "defaults.ini"), os.environ.get('ISSO_SETTINGS')), multiprocessing=True)
def main(): parser = ArgumentParser(description="a blog comment hosting service") subparser = parser.add_subparsers(help="commands", dest="command") parser.add_argument('--version', action='version', version='%(prog)s ' + dist.version) parser.add_argument("-c", dest="conf", default="/etc/isso.conf", metavar="/etc/isso.conf", help="set configuration file") imprt = subparser.add_parser('import', help="import Disqus XML export") imprt.add_argument("dump", metavar="FILE") imprt.add_argument("-n", "--dry-run", dest="dryrun", action="store_true", help="perform a trial run with no changes made") imprt.add_argument("-t", "--type", dest="type", default=None, choices=["disqus", "wordpress"], help="export type") imprt.add_argument("--empty-id", dest="empty_id", action="store_true", help="workaround for weird Disqus XML exports, #135") serve = subparser.add_parser("run", help="run server") args = parser.parse_args() conf = config.load(join(dist.location, dist.project_name, "defaults.ini"), args.conf) if args.command == "import": conf.set("guard", "enabled", "off") if args.dryrun: xxx = tempfile.NamedTemporaryFile() dbpath = xxx.name else: dbpath = conf.get("general", "dbpath") mydb = db.SQLite3(dbpath, conf) migrate.dispatch(args.type, mydb, args.dump, args.empty_id) sys.exit(0) if conf.get("general", "log-file"): handler = logging.FileHandler(conf.get("general", "log-file")) logger.addHandler(handler) logging.getLogger("werkzeug").addHandler(handler) logger.propagate = False logging.getLogger("werkzeug").propagate = False if not any(conf.getiter("general", "host")): logger.error("No website(s) configured, Isso won't work.") sys.exit(1) if conf.get("server", "listen").startswith("http://"): host, port, _ = urlsplit(conf.get("server", "listen")) try: from gevent.pywsgi import WSGIServer WSGIServer((host, port), make_app(conf)).serve_forever() except ImportError: run_simple(host, port, make_app(conf), threaded=True, use_reloader=conf.getboolean('server', 'reload')) else: sock = conf.get("server", "listen").partition("unix://")[2] try: os.unlink(sock) except OSError as ex: if ex.errno != errno.ENOENT: raise wsgi.SocketHTTPServer(sock, make_app(conf)).serve_forever()
# -*- encoding: utf-8 -*- import os import pkg_resources from isso import config, make_app application = make_app(config.load( pkg_resources.resource_filename('isso', 'defaults.ini'), os.environ.get('ISSO_SETTINGS')), multiprocessing=True)
#! python3 """ WSGI script to allow launch isso through Apache mod_wsgi. """ import site site.addsitedir("./.venv") import os from pathlib import Path from isso import config, dist, make_app # globals isso_conf_file = Path(__file__).parent / "isso-prod.cfg" application = make_app( config.load( default=os.path.join(dist.location, dist.project_name, "defaults.ini"), user=str(isso_conf_file.resolve()), ), multiprocessing=True, threading=True, )
# -*- encoding: utf-8 -*- from __future__ import unicode_literals import os from isso import make_app from isso import dist, config application = make_app( config.load( os.path.join(dist.location, "isso", "defaults.ini"), os.environ.get('ISSO_SETTINGS')), multiprocessing=True)
# This portion of code is fork of gunicorn's example of running # custom applications. # Original link - http://gunicorn-docs.readthedocs.org/en/latest/custom.html # 2009-2015 (c) Benoit Chesneau <*****@*****.**> # 2009-2015 (c) Paul J. Davis <*****@*****.**> import os import sys import multiprocessing import gunicorn.app.base from gunicorn.six import iteritems from isso import make_app from isso import config as isso_config application = make_app(isso_config.load('production.cfg')) virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/' virtualenv = os.path.join(virtenv, 'bin/activate_this.py') try: execfile(virtualenv, dict(__file__=virtualenv)) except IOError: pass ip = os.environ['OPENSHIFT_PYTHON_IP'] port = int(os.environ['OPENSHIFT_PYTHON_PORT']) def number_of_workers(): return (multiprocessing.cpu_count() * 2) + 1
# -*- encoding: utf-8 -*- from __future__ import unicode_literals import os from isso import make_app from isso import dist, config application = make_app( config.load( os.path.join(dist.location, dist.project_name, "defaults.ini"), os.environ.get('ISSO_SETTINGS')), multiprocessing=True)
# This portion of code is fork of gunicorn's example of running # custom applications. # Original link - http://gunicorn-docs.readthedocs.org/en/latest/custom.html # 2009-2015 (c) Benoit Chesneau <*****@*****.**> # 2009-2015 (c) Paul J. Davis <*****@*****.**> import os import sys import multiprocessing import gunicorn.app.base from gunicorn.six import iteritems from isso import make_app from isso import config as isso_config application = make_app(isso_config.load('production.cfg')) """ virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/' virtualenv = os.path.join(virtenv, 'bin/activate_this.py') try: execfile(virtualenv, dict(__file__=virtualenv)) except IOError: pass ip = os.environ['OPENSHIFT_PYTHON_IP'] port = int(os.environ['OPENSHIFT_PYTHON_PORT']) """ def number_of_workers(): return (multiprocessing.cpu_count() * 2) + 1
def main(): parser = ArgumentParser(description="a blog comment hosting service") subparser = parser.add_subparsers(help="commands", dest="command") parser.add_argument('--version', action='version', version='%(prog)s ' + dist.version) parser.add_argument("-c", dest="conf", default="/etc/isso.cfg", metavar="/etc/isso.cfg", help="set configuration file") imprt = subparser.add_parser('import', help="import Disqus XML export") imprt.add_argument("dump", metavar="FILE") imprt.add_argument("-n", "--dry-run", dest="dryrun", action="store_true", help="perform a trial run with no changes made") imprt.add_argument("-t", "--type", dest="type", default=None, choices=["disqus", "wordpress", "generic"], help="export type") imprt.add_argument("--empty-id", dest="empty_id", action="store_true", help="workaround for weird Disqus XML exports, #135") # run Isso as stand-alone server subparser.add_parser("run", help="run server") args = parser.parse_args() # ISSO_SETTINGS env var takes precedence over `-c` flag conf_file = os.environ.get('ISSO_SETTINGS') or args.conf if not conf_file: logger.error("No configuration file specified! Exiting.") sys.exit(1) if exists(conf_file): logger.info("Using configuration file '%s'", abspath(conf_file)) else: logger.error("Specified config '%s' does not exist! Exiting.", abspath(conf_file)) sys.exit(1) conf = config.load(config.default_file(), conf_file) if args.command == "import": conf.set("guard", "enabled", "off") if args.dryrun: xxx = tempfile.NamedTemporaryFile() dbpath = xxx.name else: dbpath = conf.get("general", "dbpath") mydb = db.SQLite3(dbpath, conf) migrate.dispatch(args.type, mydb, args.dump, args.empty_id) sys.exit(0) if conf.get("general", "log-file"): handler = logging.FileHandler(conf.get("general", "log-file")) logger.addHandler(handler) logging.getLogger("werkzeug").addHandler(handler) logger.propagate = False logging.getLogger("werkzeug").propagate = False if conf.get("server", "listen").startswith("http://"): host, port, _ = urlsplit(conf.get("server", "listen")) try: from gevent.pywsgi import WSGIServer WSGIServer((host, port), make_app(conf)).serve_forever() except ImportError: run_simple(host, port, make_app(conf), threaded=True, use_reloader=conf.getboolean('server', 'reload')) else: sock = conf.get("server", "listen").partition("unix://")[2] try: os.unlink(sock) except OSError as ex: if ex.errno != errno.ENOENT: raise wsgi.SocketHTTPServer(sock, make_app(conf)).serve_forever()
# -*- encoding: utf-8 -*- from __future__ import unicode_literals import os from isso import make_app from isso import dist, config application = make_app(config.load( os.path.join(dist.location, "share", "isso.conf"), os.environ.get('ISSO_SETTINGS')), multiprocessing=True)