Make code compatible with Python 2.6+ and Python 3
This commit is contained in:
parent
769d02b2a2
commit
856adada79
@ -8,13 +8,14 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
from StringIO import StringIO
|
||||
from io import BytesIO
|
||||
import sys
|
||||
import zipfile
|
||||
import dateutil
|
||||
import dateutil.parser
|
||||
import os.path
|
||||
from functools import wraps
|
||||
from builtins import range
|
||||
|
||||
#
|
||||
# Note: For more detailed information about the API services
|
||||
@ -163,7 +164,7 @@ class GarminClient(object):
|
||||
batch_size = 100
|
||||
# fetch in batches since the API doesn't allow more than a certain
|
||||
# number of activities to be retrieved on every invocation
|
||||
for start_index in xrange(0, sys.maxint, batch_size):
|
||||
for start_index in range(0, sys.maxsize, batch_size):
|
||||
next_batch = self._fetch_activity_ids_and_ts(start_index, batch_size)
|
||||
if not next_batch:
|
||||
break
|
||||
@ -328,7 +329,7 @@ class GarminClient(object):
|
||||
|
||||
# return the first entry from the zip archive where the filename is
|
||||
# activity_id (should be the only entry!)
|
||||
zip = zipfile.ZipFile(StringIO(response.content), mode="r")
|
||||
zip = zipfile.ZipFile(BytesIO(response.content), mode="r")
|
||||
for path in zip.namelist():
|
||||
fn, ext = os.path.splitext(path)
|
||||
if fn==str(activity_id):
|
||||
|
@ -1,5 +1,6 @@
|
||||
requests==2.9.1
|
||||
python-dateutil==2.4.1
|
||||
future==0.16.0
|
||||
|
||||
nose==1.3.7
|
||||
coverage==4.2
|
||||
|
@ -74,7 +74,7 @@ class TestRetryer(unittest.TestCase):
|
||||
func = lambda : int(time.time())
|
||||
|
||||
returnval = retryer.call(func)
|
||||
print returnval
|
||||
print(returnval)
|
||||
|
||||
|
||||
class TestFixedDelayStrategy(unittest.TestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user