예제 #1
0
파일: runbot.py 프로젝트: B-Rich/SleekBot
    if OPTS.loglevel == logging.DEBUG:
        fmt = '%(levelname)-8s %(filename)s:%(lineno)-4d: %(message)s'
    else:
        fmt = '%(levelname)-8s %(message)s'

    logging.basicConfig(level=OPTS.loglevel,
                        format=fmt)


    sys.path.append(os.path.dirname(os.path.abspath(ARGS[0])))

    try:
        SHOULD_RESTART = True
        while SHOULD_RESTART:
            SHOULD_RESTART = False
            logging.info('Loading config file: %s', ARGS[0])

            BOT = SleekBot(ARGS[0])
            BOT.start()
            BOT.process(threaded=False)
            while not BOT.state['disconnecting'] or BOT.state['disconnected']:
                time.sleep(1)
            #this does not work properly. Some thread is runnng
            SHOULD_RESTART = (BOT.end_status == END_STATUS.restart)
    except KeyboardInterrupt:
        BOT.die()
        logging.info("End requested")

    logging.info("SleekBot finished")
예제 #2
0
    optp.add_option('-v','--verbose', help='set logging to COMM', action='store_const', dest='loglevel', const=5, default=logging.INFO)
    opts,args = optp.parse_args()
    if not args:
        optp.print_help()
        exit()
    if opts.new:
        import sleekbot.sleekbot
        shutil.copy(os.path.join(os.path.dirname(globals()['sleekbot'].__file__ ), 'config_template.xml'), args[0])
        print("\n  A configuration file named %s was created. Edit it and then start your bot by running:\n\n\t runbot.py %s\n" % (args[0], args[0]))
        exit()

    logging.basicConfig(level=opts.loglevel, format='%(levelname)-8s %(message)s')

    sys.path.append(os.path.dirname(os.path.abspath(args[0])))

    global shouldRestart
    shouldRestart = True
    while shouldRestart:
        shouldRestart = False
        logging.info("Loading config file: %s" % args[0])

        bot = SleekBot(args[0])
        bot.connect()
        bot.process(threaded=False)
        while not bot.state['disconnecting']:
            time.sleep(1)
        #this does not work properly. Some thread is runnng

    logging.info("SleekBot finished")

예제 #3
0
        exit()
    if opts.new:
        import sleekbot.sleekbot
        shutil.copy(
            os.path.join(os.path.dirname(globals()['sleekbot'].__file__),
                         'config_template.xml'), args[0])
        print(
            "\n  A configuration file named %s was created. Edit it and then start your bot by running:\n\n\t runbot.py %s\n"
            % (args[0], args[0]))
        exit()

    logging.basicConfig(level=opts.loglevel,
                        format='%(levelname)-8s %(message)s')

    sys.path.append(os.path.dirname(os.path.abspath(args[0])))

    global shouldRestart
    shouldRestart = True
    while shouldRestart:
        shouldRestart = False
        logging.info("Loading config file: %s" % args[0])

        bot = SleekBot(args[0])
        bot.connect()
        bot.process(threaded=False)
        while not bot.state['disconnecting']:
            time.sleep(1)
        #this does not work properly. Some thread is runnng

    logging.info("SleekBot finished")
예제 #4
0
              (ARGS[0], ARGS[0]))
        exit()

    if OPTS.loglevel == logging.DEBUG:
        fmt = '%(levelname)-8s %(filename)s:%(lineno)-4d: %(message)s'
    else:
        fmt = '%(levelname)-8s %(message)s'

    logging.basicConfig(level=OPTS.loglevel, format=fmt)

    sys.path.append(os.path.dirname(os.path.abspath(ARGS[0])))

    try:
        SHOULD_RESTART = True
        while SHOULD_RESTART:
            SHOULD_RESTART = False
            logging.info('Loading config file: %s', ARGS[0])

            BOT = SleekBot(ARGS[0])
            BOT.start()
            BOT.process(threaded=False)
            while not BOT.state['disconnecting'] or BOT.state['disconnected']:
                time.sleep(1)
            #this does not work properly. Some thread is runnng
            SHOULD_RESTART = (BOT.end_status == END_STATUS.restart)
    except KeyboardInterrupt:
        BOT.die()
        logging.info("End requested")

    logging.info("SleekBot finished")