11
11
from .hooks import get_mongodb_uri
12
12
from .store import version_store
13
13
from .tickstore import tickstore , toplevel
14
+ from six import string_types
14
15
15
16
16
17
__all__ = ['Arctic' , 'VERSION_STORE' , 'TICK_STORE' , 'register_library_type' ]
@@ -92,7 +93,7 @@ def __init__(self, mongo_host, app_name=APPLICATION_NAME, allow_secondary=False,
92
93
self ._server_selection_timeout = serverSelectionTimeoutMS
93
94
self ._lock = threading .Lock ()
94
95
95
- if isinstance (mongo_host , basestring ):
96
+ if isinstance (mongo_host , string_types ):
96
97
self .mongo_host = mongo_host
97
98
else :
98
99
self .__conn = mongo_host
@@ -230,7 +231,7 @@ def get_library(self, library):
230
231
error = None
231
232
l = ArcticLibraryBinding (self , library )
232
233
lib_type = l .get_library_type ()
233
- except (OperationFailure , AutoReconnect ), e :
234
+ except (OperationFailure , AutoReconnect ) as e :
234
235
error = e
235
236
236
237
if error :
@@ -249,7 +250,7 @@ def get_library(self, library):
249
250
return self ._library_cache [library ]
250
251
251
252
def __getitem__ (self , key ):
252
- if isinstance (key , basestring ):
253
+ if isinstance (key , string_types ):
253
254
return self .get_library (key )
254
255
else :
255
256
raise ArcticException ("Unrecognised library specification - use [libraryName]" )
@@ -424,18 +425,18 @@ def to_gigabytes(bytes_):
424
425
to_gigabytes (self .quota )))
425
426
426
427
# Quota not exceeded, print an informational message and return
427
- avg_size = size / count if count > 1 else 100 * 1024
428
+ avg_size = size // count if count > 1 else 100 * 1024
428
429
remaining = self .quota - size
429
430
remaining_count = remaining / avg_size
430
431
if remaining_count < 100 :
431
- logger .warn ("Mongo Quota: %.3f / %.0f GB used" % (to_gigabytes (size ),
432
+ logger .warning ("Mongo Quota: %.3f / %.0f GB used" % (to_gigabytes (size ),
432
433
to_gigabytes (self .quota )))
433
434
else :
434
435
logger .info ("Mongo Quota: %.3f / %.0f GB used" % (to_gigabytes (size ),
435
436
to_gigabytes (self .quota )))
436
437
437
438
# Set-up a timer to prevent us for checking for a few writes.
438
- self .quota_countdown = max (remaining_count / 2 , 1 )
439
+ self .quota_countdown = int ( max (remaining_count // 2 , 1 ) )
439
440
440
441
def get_library_type (self ):
441
442
return self .get_library_metadata (ArcticLibraryBinding .TYPE_FIELD )
0 commit comments