def parse_options(self): parser = ArgumentParser( formatter_class=ArgumentDefaultsHelpFormatter, version=version, ) add = parser.add_argument add( "--config", action="store", default=None, dest="config", metavar="FILE", type=str, help="read configuration from FILE" ) add( "--debug", action="store_true", default=False, dest="debug", help="enable debugging mode" ) add( "--daemon", action="store_true", default=False, dest="daemon", help="run as a background process" ) add( "--verbose", action="store_true", default=False, dest="verbose", help="enable verbose logging" ) add( "--logfile", action="store", default=None, dest="logfile", metavar="FILE", type=str, help="store logging information to FILE" ) add( "--pidfile", action="store", default="charla.pid", dest="pidfile", metavar="FILE", type=str, help="write process id to FILE" ) add( "--embedded", action="store_true", default=bool(int(environ.get("EMBEDDED", "0"))), dest="embedded", help="Use an embedded database" ) add( "--dbhost", action="store", default=environ.get("REDIS_PORT_6379_TCP_ADDR", "localhost"), dest="dbhost", metavar="HOST", type=str, help="set database host to HOST (Redis)" ) add( "--dbport", action="store", default=int(environ.get("REDIS_PORT_6379_TCP_PORT", "6379")), dest="dbport", metavar="PORT", type=int, help="set database port to PORT (Redis)" ) add( "-p", "--plugin", action="append", default=plugins.DEFAULTS, dest="plugins", help="Plugin to load (multiple allowed)" ) add( "-P", "--port", action="store", type=int, default=7000, dest="port", help="Port to listen to" ) namespace = parser.parse_args() if namespace.config is not None: filename = namespace.config if exists(filename): config = reprconf.as_dict(str(filename)) for option, value in config.pop("globals", {}).items(): if option in namespace: self[option] = value else: warn("Ignoring unknown option %r" % option) self.update(config) for option, value in namespace.__dict__.items(): if option not in self and value is not None: self[option] = value
def parse_options(self): parser = ArgumentParser( formatter_class=ArgumentDefaultsHelpFormatter, version=version, ) add = parser.add_argument add( "-c", "--config", action="store", default=None, dest="config", metavar="FILE", type=str, help="Read configuration from FILE" ) add( "-D", "--debug", action="store_true", default=False, dest="debug", help="Enable debug mode" ) add( "-V", "--verbose", action="store_true", default=False, dest="verbose", help="Enable verbose logging" ) add( "-l", "--logfile", action="store", default="-", dest="logfile", metavar="FILE", type=FileType(mode="w"), help="Write logs to FILE" ) add( "-P", "--plugin", action="append", default=plugins.DEFAULTS, dest="plugins", help="Plugins to load (multiple allowed)" ) add( "-b", "--bind", action="store", type=str, default="0.0.0.0:70", metavar="INT", dest="bind", help="Bind to interface INT" ) add( "-6" "--ipv6", action="store_true", default=False, dest="ipv6", help="Enable IPv6 support" ) add( "-e", "--encoding", action="store", type=str, default="UTF-8", dest="encoding", help="Set default encoding" ) add( "-w", "--width", action="store", type=int, default=70, dest="width", help="Sel default page width" ) add( "-r", "--rootdir", action="store", type=str, default=getcwd(), dest="rootdir", help="Set root directory" ) add( "-u", "--user", action="store", type=str, default="nobody", dest="user", help="Set user to drop privileges to" ) add( "-g", "--group", action="store", type=str, default="nobody", dest="group", help="Set group to drop privileges to" ) add( "-U", "--userdir", action="store", type=str, default="gopher", dest="userdir", help="Set user directory" ) add( "-H", "--host", action="store", type=str, default="localhost", dest="host", help="Set hostname" ) namespace = parser.parse_args() if namespace.config is not None: filename = namespace.config if exists(filename): config = reprconf.as_dict(str(filename)) for option, value in config.pop("globals", {}).items(): if option in namespace: self[option] = value else: warn("Ignoring unknown option %r" % option) self.update(config) for option, value in namespace.__dict__.items(): key = "{}{}".format(self.prefix, option.upper()) if key in environ and environ[key] != parser.get_default(option): continue if option not in self and value is not None: self[option] = value
def reload_config(self): filename = self.get("config") if filename is not None: config = reprconf.as_dict(filename) config.pop("global", None) self.update(config)
def reload_config(self): filename = self.get("config") if filename is not None: config = reprconf.as_dict(filename) self.update(config.get(config.keys()[0], {}))
def parse_options(self): parser = ArgumentParser(sahriswiki.__name__) add = parser.add_argument add("--config", action="store", default=None, dest="config", metavar="FILE", type=str, help="Read configuration from FILE") add("-b", "--bind", action="store", default="0.0.0.0", dest="bind", metavar="INT", type=str, help="Listen on interface INT") add("-p", "--port", action="store", default=8000, dest="port", metavar="PORT", type=int, help="Listen on port PORT") add("-s", "--sock", action="store", default=None, dest="sock", metavar="FILE", type=str, help="Listen on socket FILE") add("-r", "--repo", action="store", default="wiki", dest="repo", metavar="REPO", type=str, help="Store pages in mercurial repository REPO") add("-d", "--database", action="store", default="sqlite:///sahriswiki.db", dest="db", metavar="DB", type=str, help="Store meta data in database DB") add("-t", "--theme", action="store", default=path.join(path.dirname(__file__), "themes", "simple"), dest="theme", metavar="DIR", type=str, help="Set theme (static and templates) path to DIR") add("--frontpage", action="store", default="FrontPage", dest="frontpage", metavar="PAGE", type=str, help="Set default front page to PAGE") add("--index", action="store", default="Index", dest="index", metavar="PAGE", type=str, help="Set default index page to PAGE") add("--indexes", action="store", nargs="+", default=["Index", "index.html", "index.rst"], dest="indexes", metavar="LIST", type=list, help="Set index search list to LIST") add("--menu", action="store", default="SiteMenu", dest="menu", metavar="PAGE", type=str, help="Set default site menu page to PAGE") add("--encoding", action="store", default="utf-8", dest="encoding", metavar="ENC", type=str, help="Use encoding ENC to read and write pages") add("--language", action="store", default="en", dest="language", metavar="LANG", type=str, help="Translate interface to LANG") add("--name", action="store", default=sahriswiki.__name__, dest="name", metavar="NAME", type=str, help="Set site name to NAME") add("--author", action="store", default=sahriswiki.__author__, dest="author", metavar="NAME", type=str, help="Set site author to NAME") add("--description", action="store", default=sahriswiki.__doc__.split("\n")[0], dest="description", metavar="DESC", type=str, help="Set site description to DESC") add("--keywords", action="store", default="sahriswiki", dest="keywords", metavar="KEYWORDS", type=str, help="Set site keywords to KEYWORDS") add("--readonly", action="store_true", default=False, dest="readonly", help="Set the wiki into readonly mode") add("--debug", action="store_true", default=False, dest="debug", help="Enable debugging mode") add("--daemon", action="store_true", default=False, dest="daemon", help="Run as a background process") add("--verbose", action="store_true", default=False, dest="verbose", help="Enable verbose debugging") add("--errorlog", action="store", default=None, dest="errorlog", metavar="FILE", type=str, help="Store debug and error information in FILE") add("--accesslog", action="store", default=None, dest="accesslog", metavar="FILE", type=str, help="Store web server access logs in FILE") add("--pidfile", action="store", default="sahris.pid", dest="pidfile", metavar="FILE", type=str, help="Write process id to FILE") add("--disable-hgweb", action="store_true", default=False, dest="disable-hgweb", help="Disable hgweb interface") add("--disable-logging", action="store_true", default=False, dest="disable-logging", help="Disable access logging") add("--disable-static", action="store_true", default=False, dest="disable-static", help="Disable static file serving") add("--disable-compression", action="store_true", default=False, dest="disable-compression", help="Disable compression") add("--static-baseurl", action="store", default=None, dest="static-baseurl", metavar="URL", type=str, help="Set static baseurl to URL") namespace = parser.parse_args() if namespace.config is not None: filename = path.abspath(path.expanduser(namespace.config)) if path.exists(filename) and path.isfile(filename): config = reprconf.as_dict(filename) if config.keys(): config = config[config.keys()[0]] for option, value in config.iteritems(): if option in namespace: self[option] = value else: warn("Ignoring unknown option %r" % option) for option, value in namespace.__dict__.iteritems(): if option not in self and value is not None: self[option] = value
def parse_options(self): parser = ArgumentParser( formatter_class=ArgumentDefaultsHelpFormatter, version=version, ) add = parser.add_argument add( "--config", action="store", default=None, dest="config", metavar="FILE", type=str, help="read configuration from FILE" ) add( "--debug", action="store_true", default=False, dest="debug", help="enable debugging mode" ) add( "--daemon", action="store_true", default=False, dest="daemon", help="run as a background process" ) add( "--verbose", action="store_true", default=False, dest="verbose", help="enable verbose logging" ) add( "--errorlog", action="store", default=None, dest="errorlog", metavar="FILE", type=str, help="store debug and error logs in FILE" ) add( "--pidfile", action="store", default="kdb.pid", dest="pidfile", metavar="FILE", type=str, help="write process id to FILE" ) add( "-c", "--channel", action="append", default=["#circuits"], dest="channels", help="Channel to join (multiple allowed, or comma separated)" ) add( "-n", "--nick", action="store", default="kdb", dest="nick", help="Nickname to use" ) add( "-p", "--password", action="store", default=None, dest="password", help="Password to use when connecting" ) add( "--plugin", action="append", default=plugins.DEFAULTS, dest="plugins", help="Plugin to load (multiple allowed)" ) add( "host", action="store", nargs="?", default="irc.freenode.net", type=str, metavar="HOST", help="Host to connect to" ) add( "port", action="store", nargs="?", default=6667, type=int, metavar="PORT", help="Port to connect to" ) namespace = parser.parse_args() if namespace.config is not None: filename = namespace.config if exists(filename): config = reprconf.as_dict(str(filename)) for option, value in config.pop("globals", {}).items(): if option in namespace: self[option] = value else: warn("Ignoring unknown option %r" % option) self.update(config) for option, value in namespace.__dict__.items(): if option not in self and value is not None: self[option] = value
def parse_options(self): parser = ArgumentParser( formatter_class=ArgumentDefaultsHelpFormatter, version=version, ) add = parser.add_argument add("--config", action="store", default=None, dest="config", metavar="FILE", type=str, help="read configuration from FILE") add("--debug", action="store_true", default=False, dest="debug", help="enable debugging mode") add("--daemon", action="store_true", default=False, dest="daemon", help="run as a background process") add("--verbose", action="store_true", default=False, dest="verbose", help="enable verbose logging") add("--logfile", action="store", default=None, dest="logfile", metavar="FILE", type=str, help="store logging information to FILE") add("--pidfile", action="store", default="charla.pid", dest="pidfile", metavar="FILE", type=str, help="write process id to FILE") add("--dbhost", action="store", default=environ.get("REDIS_PORT_6379_TCP_ADDR", "localhost"), dest="dbhost", metavar="HOST", type=str, help="set database host to HOST (Redis)") add("--dbport", action="store", default=int(environ.get("REDIS_PORT_6379_TCP_PORT", "6379")), dest="dbport", metavar="PORT", type=int, help="set database port to PORT (Redis)") add("-p", "--plugin", action="append", default=plugins.DEFAULTS, dest="plugins", help="Plugin to load (multiple allowed)") add("-P", "--port", action="store", type=int, default=7000, dest="port", help="Port to listen to") namespace = parser.parse_args() if namespace.config is not None: filename = namespace.config if exists(filename): config = reprconf.as_dict(str(filename)) for option, value in config.pop("globals", {}).items(): if option in namespace: self[option] = value else: warn("Ignoring unknown option %r" % option) self.update(config) for option, value in namespace.__dict__.items(): if option not in self and value is not None: self[option] = value
def parse_options(self): parser = ArgumentParser(sahriswiki.__name__) add = parser.add_argument add( "--config", action="store", default=None, dest="config", metavar="FILE", type=str, help="Read configuration from FILE" ) add( "-b", "--bind", action="store", default="0.0.0.0", dest="bind", metavar="INT", type=str, help="Listen on interface INT" ) add( "-p", "--port", action="store", default=8000, dest="port", metavar="PORT", type=int, help="Listen on port PORT" ) add( "-s", "--sock", action="store", default=None, dest="sock", metavar="FILE", type=str, help="Listen on socket FILE" ) add( "-r", "--repo", action="store", default="wiki", dest="repo", metavar="REPO", type=str, help="Store pages in mercurial repository REPO" ) add( "-d", "--database", action="store", default="sqlite:///sahriswiki.db", dest="db", metavar="DB", type=str, help="Store meta data in database DB" ) add( "-t", "--theme", action="store", default=path.join(path.dirname(__file__), "themes", "simple"), dest="theme", metavar="DIR", type=str, help="Set theme (static and templates) path to DIR" ) add( "--frontpage", action="store", default="FrontPage", dest="frontpage", metavar="PAGE", type=str, help="Set default front page to PAGE" ) add( "--index", action="store", default="Index", dest="index", metavar="PAGE", type=str, help="Set default index page to PAGE" ) add( "--indexes", action="store", nargs="+", default=["Index", "index.html", "index.rst"], dest="indexes", metavar="LIST", type=list, help="Set index search list to LIST" ) add( "--menu", action="store", default="SiteMenu", dest="menu", metavar="PAGE", type=str, help="Set default site menu page to PAGE" ) add( "--encoding", action="store", default="utf-8", dest="encoding", metavar="ENC", type=str, help="Use encoding ENC to read and write pages" ) add( "--language", action="store", default="en", dest="language", metavar="LANG", type=str, help="Translate interface to LANG" ) add( "--name", action="store", default=sahriswiki.__name__, dest="name", metavar="NAME", type=str, help="Set site name to NAME" ) add( "--author", action="store", default=sahriswiki.__author__, dest="author", metavar="NAME", type=str, help="Set site author to NAME" ) add( "--description", action="store", default=sahriswiki.__doc__.split("\n")[0], dest="description", metavar="DESC", type=str, help="Set site description to DESC" ) add( "--keywords", action="store", default="sahriswiki", dest="keywords", metavar="KEYWORDS", type=str, help="Set site keywords to KEYWORDS" ) add( "--readonly", action="store_true", default=False, dest="readonly", help="Set the wiki into readonly mode" ) add( "--debug", action="store_true", default=False, dest="debug", help="Enable debugging mode" ) add( "--daemon", action="store_true", default=False, dest="daemon", help="Run as a background process" ) add( "--verbose", action="store_true", default=False, dest="verbose", help="Enable verbose debugging" ) add( "--errorlog", action="store", default=None, dest="errorlog", metavar="FILE", type=str, help="Store debug and error information in FILE" ) add( "--accesslog", action="store", default=None, dest="accesslog", metavar="FILE", type=str, help="Store web server access logs in FILE" ) add( "--pidfile", action="store", default="sahris.pid", dest="pidfile", metavar="FILE", type=str, help="Write process id to FILE" ) add( "--disable-hgweb", action="store_true", default=False, dest="disable-hgweb", help="Disable hgweb interface" ) add( "--disable-logging", action="store_true", default=False, dest="disable-logging", help="Disable access logging" ) add( "--disable-static", action="store_true", default=False, dest="disable-static", help="Disable static file serving" ) add( "--disable-compression", action="store_true", default=False, dest="disable-compression", help="Disable compression" ) add( "--static-baseurl", action="store", default=None, dest="static-baseurl", metavar="URL", type=str, help="Set static baseurl to URL" ) namespace = parser.parse_args() if namespace.config is not None: filename = path.abspath(path.expanduser(namespace.config)) if path.exists(filename) and path.isfile(filename): config = reprconf.as_dict(filename) if config.keys(): config = config[config.keys()[0]] for option, value in config.iteritems(): if option in namespace: self[option] = value else: warn("Ignoring unknown option %r" % option) for option, value in namespace.__dict__.iteritems(): if option not in self and value is not None: self[option] = value