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 os
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
import dateutil
|
import dateutil
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import os.path
|
import os.path
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from builtins import range
|
||||||
|
|
||||||
#
|
#
|
||||||
# Note: For more detailed information about the API services
|
# Note: For more detailed information about the API services
|
||||||
@ -163,7 +164,7 @@ class GarminClient(object):
|
|||||||
batch_size = 100
|
batch_size = 100
|
||||||
# fetch in batches since the API doesn't allow more than a certain
|
# fetch in batches since the API doesn't allow more than a certain
|
||||||
# number of activities to be retrieved on every invocation
|
# 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)
|
next_batch = self._fetch_activity_ids_and_ts(start_index, batch_size)
|
||||||
if not next_batch:
|
if not next_batch:
|
||||||
break
|
break
|
||||||
@ -328,7 +329,7 @@ class GarminClient(object):
|
|||||||
|
|
||||||
# return the first entry from the zip archive where the filename is
|
# return the first entry from the zip archive where the filename is
|
||||||
# activity_id (should be the only entry!)
|
# 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():
|
for path in zip.namelist():
|
||||||
fn, ext = os.path.splitext(path)
|
fn, ext = os.path.splitext(path)
|
||||||
if fn==str(activity_id):
|
if fn==str(activity_id):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
requests==2.9.1
|
requests==2.9.1
|
||||||
python-dateutil==2.4.1
|
python-dateutil==2.4.1
|
||||||
|
future==0.16.0
|
||||||
|
|
||||||
nose==1.3.7
|
nose==1.3.7
|
||||||
coverage==4.2
|
coverage==4.2
|
||||||
|
@ -74,7 +74,7 @@ class TestRetryer(unittest.TestCase):
|
|||||||
func = lambda : int(time.time())
|
func = lambda : int(time.time())
|
||||||
|
|
||||||
returnval = retryer.call(func)
|
returnval = retryer.call(func)
|
||||||
print returnval
|
print(returnval)
|
||||||
|
|
||||||
|
|
||||||
class TestFixedDelayStrategy(unittest.TestCase):
|
class TestFixedDelayStrategy(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user