Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of 868a8b4f to 0.9.x - Optionally specify fixed 'now' to fetch #80

Merged
merged 3 commits into from
Jun 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python

python:
- 2.5
- 2.6
- 2.7
- pypy
Expand Down
9 changes: 5 additions & 4 deletions whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def info(path):
return info


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

path is a string
Expand All @@ -708,12 +708,13 @@ def fetch(path,fromTime,untilTime=None):
Returns None if no data can be returned
"""
fh = open(path,'rb')
return file_fetch(fh, fromTime, untilTime)
return file_fetch(fh, fromTime, untilTime, now)


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