Readynas python'版本'参考

时间:2013-11-08 09:39:47

标签: python python-2.6

我正在尝试使用Python 2.6在我的Readynas二重奏上运行耳机,但遇到与确定操作系统版本有关的错误。作为一名非python专家,我想知道是否有人可以通过以下堆栈跟踪帮助我:

[   couchpotato.core.event] Error in event "app.version", that wasn't caught: Traceback (most recent call last):   File "/usr/share/cpserver/couchpotato/core/event.py", line 12, in runHandler
    return handler(*args, **kwargs)   File "/usr/share/cpserver/couchpotato/core/_base/_core/main.py", line 167, in version
    elif 'Darwin' in platform.platform(): platf = 'osx'   File "/usr/local/lib/python2.6/platform.py", line 1520, in platform
    elif system in ('Linux',):   File "/usr/local/lib/python2.6/platform.py", line 361, in dist
    return linux_distribution(distname, version, id,   File "/usr/local/lib/python2.6/platform.py", line 333, in linux_distribution
    firstline = f.readline()   File "/usr/local/lib/python2.6/platform.py", line 269, in
_parse_release_file
    else: UnboundLocalError: local variable 'version' referenced before assignment encoding=UTF-8 debug=False args=['--daemon', '--data_dir', '/media/UsenetTmp/.couchpotato', '--pid_file=/var/run/cpserver/server.pid'] app_dir=/usr/share/cpserver data_dir=/media/UsenetTmp/.couchpotato desktop=None options=Namespace(config_file='/media/UsenetTmp/.couchpotato/settings.conf', console_log=False, daemon=True, data_dir='/media/UsenetTmp/.couchpotato', debug=False, pid_file='/var/run/cpserver/server.pid', quiet=False)

1 个答案:

答案 0 :(得分:0)

这是一个python2.6错误(无法找到问题编号atm,但它已在2.7中修复)。检查Linux系统上详细操作系统版本信息的代码是以这种方式编码的:

def _parse_release_file(firstline):
    #some code
    l = string.split(string.strip(firstline))
    if l:
        version = l[0]
    #more code
    return '', version, id

因此,如果发布文件为空,则永远不会分配version变量,这会导致UnboundLocalError尝试返回它。

要解决此问题,您可以修补platform.py文件以避免此错误,最好在version = ''开头添加行id = ''_parse_release_file - 这它是如何在2.7中修复的。如果您无法在NAS上修改该文件,请尝试修改couchpotato来源,并使用platform.platform()这样的硬编码字符串替换"Linux-generic-x86"的呼叫。