首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有找到记录器“洪水”的处理程序。

没有找到记录器“洪水”的处理程序。
EN

Stack Overflow用户
提问于 2014-07-01 01:01:52
回答 1查看 1.6K关注 0票数 2

我有一个用于cronjob的python脚本,它可以删除3天以上的洪流。如果我从终端运行这个脚本,那么这个脚本就能工作了,但是crontab给了我这个错误No handlers could be found for logger "deluge"。有人能告诉我如何解决这个问题吗?

这是python脚本:

代码语言:javascript
复制
    #!/usr/bin/python

    from deluge.log import LOG as log
    from deluge.ui.client import client
    import deluge.component as component
    from twisted.internet import reactor, defer
    import time

    ############
    cliconnect = client.connect(host='127.0.0.1',port=58846)
    seeddir = "/home/mou/CPDownloads" # Directory to ignore for torrents to remain seeding
    timedifference = 3 # Remove torrents older than this this time (in days)
    is_interactive = False # Set this to True to allow direct output or set to False for cron
    do_remove_data = True # Set to True to delete torrent data as well, false to leave it
    ###############

    oldcount = 0
    skipcount = 0
    seedcount = 0
    errorcount = 0
    torrent_ids = []

    def printSuccess(dresult, is_success, smsg):
        global is_interactive
        if is_interactive:
            if is_success:
                print "[+]", smsg
            else:
                print "[i]", smsg

    def printError(emsg):
        global is_interactive
        if is_interactive:
            print "[e]", emsg

    def endSession(esresult):
        if esresult:
            print esresult
            reactor.stop()
        else:
            client.disconnect()
            printSuccess(None, False, "Client disconnected.")
            reactor.stop()

    def printReport(rresult):
        if errorcount > 0:
            printError(None, "Failed! Number of errors: %i" % (errorcount))
        else:
            if oldcount > 0:
                printSuccess(None, True, "Removed %i torrents -- Skipped %i torrents -- Seeding %i torrents" % (oldcount, skipcount, seedcount))
            else:
                printSuccess(None, True, "No old torrents! -- Skipped %i torrents -- Seeding %i torrents" % (skipcount, seedcount))
        endSession(None)

    def on_torrents_status(torrents):
        global filtertime
        tlist=[]
        for torrent_id, status in torrents.items():
            if status["save_path"] == seeddir:
                global seedcount
                seedcount += 1
            else:
                unixtime = "%s" % (status["time_added"])
                numunixtime = int(unixtime[:-2])
                humantime = time.ctime(numunixtime)
                if numunixtime < filtertime:
                    global do_remove_data
                    global oldcount
                    oldcount += 1
                    successmsg = " Removed %s:  %s from %s" % (humantime, status["name"], status["save_path"])
            errormsg = "Error removing %s" % (status["name"])
            tlist.append(client.core.remove_torrent(torrent_id, do_remove_data).addCallbacks(printSuccess, printError, callbackArgs = (True, successmsg), errbackArgs = (errormsg)))
                else:
                    global skipcount
                    skipcount += 1
                    printSuccess(None, False, " Skipping %s: %s from %s" % (humantime, status["name"], status["save_path"]))
        defer.DeferredList(tlist).addCallback(printReport)

    def on_session_state(result):
        client.core.get_torrents_status({"id": result}, ["name","time_added","save_path",]).addCallback(on_torrents_status)

    def on_connect_success(result):
        printSuccess(None, True, "Connection was successful!")
        global timedifference
        global filtertime
        curtime = time.time()
        filtertime = curtime - (timedifference * 24 * 60 * 60)
        printSuccess(None, False, "Current unix time is %i" % (curtime))
        printSuccess(None, False, "Filtering torrents older than %s" % (time.ctime(int(filtertime))))
        client.core.get_session_state().addCallback(on_session_state)

    cliconnect.addCallbacks(on_connect_success, endSession, errbackArgs=("Connection failed: check settings and try again."))

    reactor.run()

这是我从终端运行它时的输出:

代码语言:javascript
复制
    mou@mou-lanister:~/scripts$ ./cpmanagertest.py 
    [+] Connection was successful!
    [i] Current unix time is 1404169193
    [i] Filtering torrents older than Sun Jun 29 18:59:53 2014
    [i]  Skipping Mon Jun 30 03:57:52 2014: War.Horse.2011.1080p.MKV.x264.AC3.DTS.NL.Subs from /home/mou/CPDownloads/
    [i]  Skipping Mon Jun 30 04:00:00 2014: The Legend Of Hercules 2014 1080p BluRay DTS x264 PublicHD from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 16:52:16 2014:  Paranormal.Activity.The.Marked.Ones.2014.EXTENDED.1080p.BluRay.x264-SPARKS [PublicHD] from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 17:07:12 2014:  The.Hobbit.The.Desolation.Of.Smaug.2013.1080p.BluRay.DTS.x264-PublicHD from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 17:22:08 2014:  thor the dark world 2013 1080p bluray x264 sparks publichd from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 16:24:32 2014:  The.Conjuring.2013.1080p.BluRay.x264-ALLiANCE [PublicHD] from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 17:00:48 2014:  Her.2013.1080p.BluRay.x264-SPARKS [PublicHD] from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 17:20:00 2014:  Rush 2013 1080p 60fps BluRay x264-zologne from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 17:22:08 2014:  Escape.Plan.2013.1080p.BluRay.DTS-HD.MA.7.1.x264-PublicHD from /home/mou/CPDownloads/
    [+]  Removed Sun Jun 29 17:05:04 2014:  The.Fifth.Estate.2013.1080p.BluRay.x264-SPARKS [PublicHD] from /home/mou/CPDownloads/
    [+] Removed 8 torrents -- Skipped 2 torrents -- Seeding 0 torrents
    [i] Client disconnected.

这是crontab作业的日志:

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

对于记录器“洪水”,找不到任何处理程序。

添加调试代码后,我得到以下错误:

代码语言:javascript
复制
DEBUG:deluge:ConfigManager started..
INFO:deluge:Connecting to daemon at 127.0.0.1:58846..
INFO:deluge:Connected to daemon at 127.0.0.1:58846..
ERROR:deluge:RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: daemon.login(localclient, f4f86361c7b9443464d0078f8d7c012e2ed63ce9)
--------------------------------------------------------------------------------
  File "/usr/lib/python2.7/dist-packages/deluge/core/rpcserver.py", line 259, in dispatch
    ret = component.get("AuthManager").authorize(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/deluge/core/authmanager.py", line 93, in authorize
    raise BadLoginError("Password does not match")

BadLoginError: Password does not match
--------------------------------------------------------------------------------
DEBUG:deluge:_on_login_fail(): [Failure instance: Traceback (failure with no frames): <class 'deluge.ui.client.DelugeRPCError'>: <deluge.ui.client.DelugeRPCError object at 0x7f58263f6150>
]
DEBUG:deluge:on_connect_fail: [Failure instance: Traceback (failure with no frames): <class 'deluge.ui.client.DelugeRPCError'>: <deluge.ui.client.DelugeRPCError object at 0x7f58263f6150>
]
INFO:deluge:Connection lost to daemon at 127.0.0.1:58846 reason: Connection was closed cleanly.
EN

Stack Overflow用户

回答已采纳

发布于 2014-07-01 01:08:51

啊,这是巨蟒疣之一。

添加此选项可以抑制以下消息:

代码语言:javascript
复制
import logging 
logging.getLogger('deluge').addHandler(logging.NullHandler())

或者把所有的东西都写给stderr:

代码语言:javascript
复制
import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
票数 3
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24501071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档