示例#1
0
文件: datadir.py 项目: buzzworkers/tl
def makeconfigs():
    from tl.lib.config import makedefaultconfig
    fleet = getfleet()
    makedefaultconfig('irc', ddir)
    fleet.addnametype("default-irc", "irc")
    makedefaultconfig('sleek', ddir)
    fleet.addnametype("default-sleek", "sleek")
示例#2
0
文件: opts.py 项目: buzzworkers/tl
def do_opts(type="console", args=[], *argslist, **kwargs):
    from tl.version import getversion
    if not args: args = sys.argv
    if type != "console": print("TIMELINE %s" % getversion(type.upper()))
    cfg = None
    if type == "irc": target = api_opts + bot_opts + irc_opts
    elif type == "xmpp": target = api_opts + bot_opts + xmpp_opts
    elif type == "fleet": target = api_opts + fleet_opts
    elif type == "init": target = []
    elif type == "console": target = bot_opts + console_opts
    else: target = []
    opts =  make_opts(args, target, *argslist, **kwargs)
    if type == "console": ll = "error"
    else: ll = "warn" 
    if opts.datadir: setdatadir(opts.datadir)
    else: setdatadir(homedir + os.sep + ".tl")
    setloglevel(opts.loglevel or ll)
    if opts.bork: tl.utils.exception.bork = True ; logging.warn("bork mode enabled")
    if opts.nourl: tl.utils.url.enabled = False ; logging.warn("url fetching disabled")
    if opts.nocolors: tl.utils.log.docolor = False ; logging.warn("colors in logging is disabled")
    from tl.lib.users import getusers
    u = getusers()
    if opts.owner and u: u.make_owner(opts.owner)
    from tl.lib.config import getmainconfig
    maincfg = getmainconfig(opts.datadir)
    if type == "irc": cfg = makeircconfig(opts, opts.name)
    elif type == "xmpp" or type == "xmpp": cfg = makexmppconfig(opts, opts.name)
    elif type == "console": cfg = makeconsoleconfig(opts, opts.name)
    else: cfg = makedefaultconfig(opts, opts.name) 
    if opts.anon: cfg.auto_register = True ; cfg.guestasuser = True
    else: cfg.auto_register = False
    if maincfg.dbtype: logging.warn("database type is %s" % maincfg.dbtype)
    return (opts, cfg)