예제 #1
0
def setup(in_service=False):
    config.init(sys.argv[1:])
    config.init_logging()
    sys.excepthook = exceptionLogger

    port = config.getPort()

    httpd = httpserver.TivoHTTPServer(('', int(port)),
        httpserver.TivoHTTPHandler)

    logger = logging.getLogger('pyTivo')
    commit = get_cur_commit()
    logger.info('Using commit: iluvatar-%s' % commit[:7])
    logger.info('Last modified: ' + last_date())
    logger.info('Python: ' + platform.python_version())
    logger.info('System: ' + platform.platform())

    for section, settings in config.getShares():
        httpd.add_container(section, settings)

    b = beacon.Beacon()
    b.add_service('TiVoMediaServer:%s/http' % port)
    b.start()
    if 'listen' in config.getBeaconAddresses():
        b.listen()

    httpd.set_beacon(b)
    httpd.set_service_status(in_service)
    config.config_check()

    logger.info('pyTivo is ready.')
    return httpd
예제 #2
0
def main():
    if not cfg.config_check():
        return
    with Pool(processes=16) as pool:
        pool.map(parse_person, os.listdir(cfg.RESULTS_DIRECTORY))
예제 #3
0
import logging
import os
import sys

from telegram.ext import Updater

from config import config_check
from handler.kb_callback import kb_callback
from handler.receive import receive
from handler.remove_default_service import remove_default_service
from handler.set_default_service import set_default_service
from handler.start import start

# check is exist upload services
check_res = config_check()
if not check_res[0]:
    print(check_res[1])
    sys.exit(0)

# logger
logging.basicConfig(level=logging.INFO, format="%(name)s: %(message)s")
bot_logger = logging.getLogger("telegram.bot")
bot_logger.setLevel(logging.INFO)

updater = Updater(token=os.environ.get('BOT_TOKEN'))
dispatcher = updater.dispatcher

# handlers
dispatcher.add_handler(start)
dispatcher.add_handler(receive)
            print '请求失败,错误代码为: ' + str(resp_code)
            sqlunit.remove()


def start_connect(connect):
    result = sqlunit.query()
    if result:
        print '正在断开...'
        enc_str = ''.join(result.pop())
        response = connect.logout(enc_str)

    else:
        print '正在连接...'
        response = connect.login()

    connect.response_handle(response)
    sqlunit.close()


if __name__ == '__main__':
    if config.config_check():
        connect = Connect()
        info = config.read_config()
        connect.otherUser = info[0]
        connect.otherUserPwd = info[1]
        connect.regArea = info[2]
        start_connect(connect)
    else:
        sys.exit()