2

我正在尝试使用耳语合并来合并 2 个wsp文件。他们有相同的保留策略,一个只是比另一个拥有更旧的数据。

当我运行时whisper-merge oldfile.wsp newfile.wsp出现此错误

Traceback (most recent call last):
  File "/usr/local/src/whisper-0.9.12/bin/whisper-merge.py", line 32, in <module>
    whisper.merge(path_from, path_to)
  File "/usr/local/lib/python2.7/dist-packages/whisper.py", line 821, in merge
    (timeInfo, values) = fetch(path_from, fromTime, untilTime)
TypeError: 'NoneType' object is not iterable

有任何想法吗?

这是 2 个文件的元数据输出:

4

2 回答 2

7

对于包含多个档案的文件,whisper.py 中的第 812 行已损坏。 https://github.com/graphite-project/whisper/blob/0.9.12/whisper.py#L812

fromTime = int(time.time()) - headerFrom['maxRetention']

要修复,紧跟第 813 行,根据存档保留分配 fromTime。 https://github.com/graphite-project/whisper/blob/0.9.12/whisper.py#L813

for archive in archives: # this line already exists
  fromTime = int(time.time()) - archive['retention'] # add this line
于 2014-07-31T00:32:36.083 回答
1

Snippet from whisper.py

def fetch(path,fromTime,untilTime=None):
    """fetch(path,fromTime,untilTime=None)

    path is a string
    fromTime is an epoch time
    untilTime is also an epoch time, but defaults to now.

    Returns a tuple of (timeInfo, valueList)
    where timeInfo is itself a tuple of (fromTime, untilTime, step)

    Returns None if no data can be returned
    """
    fh = open(path,'rb')
    return file_fetch(fh, fromTime, untilTime)

Suggests that whisper.fetch() is returning None, which in turn, (along with the final line in the traceback) suggests that there is a problem with your path_from file.
Looking a little deeper, whisper.file_fetch() appears to have two places where it can return None (explicitly, at least):

def file_fetch(fh, fromTime, untilTime):
    header = __readHeader(fh)
    now = int( time.time() )
    if untilTime is None:
        untilTime = now
    fromTime = int(fromTime)
    untilTime = int(untilTime)

    # Here we try and be flexible and return as much data as we can.
    # If the range of data is from too far in the past or fully in the future, we
    # return nothing
    if (fromTime > untilTime):
        raise InvalidTimeInterval("Invalid time interval: from time '%s' is after until time '%s'" % (fromTime, untilTime))

    oldestTime = now - header['maxRetention']
    # Range is in the future
    if fromTime > now:
        return None               # <== Here
    # Range is beyond retention
    if untilTime < oldestTime:
        return None               # <== ...and here
    ...
于 2014-07-30T07:21:29.617 回答