Skip to content

Commit 951573d

Browse files
author
Tim Vaillancourt
committed
merge from origin/replsethandler_to_backup_py
2 parents 686f0ed + dbffeb2 commit 951573d

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

MongoBackup/Replset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from math import ceil
44

5+
from Common import DB
6+
57

68
class Replset:
79
def __init__(self, db, user=None, password=None, authdb='admin', max_lag_secs=5):
@@ -18,10 +20,10 @@ def __init__(self, db, user=None, password=None, authdb='admin', max_lag_secs=5)
1820

1921
# Get a DB connection
2022
try:
21-
if self.db.__class__.__name__ == "DB":
23+
if isinstance(self.db, DB):
2224
self.connection = self.db.connection()
2325
else:
24-
raise Exception, "'db' field is an instance of %s, not 'DB'!" % self.db.__class__.__name__, None
26+
raise Exception, "'db' field is not an instance of class: 'DB'!", None
2527
except Exception, e:
2628
logging.fatal("Could not get DB connection! Error: %s" % e)
2729
raise e

MongoBackup/ReplsetSharded.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ def __init__(self, sharding, db, user=None, password=None, authdb='admin', max_l
1818
self.replset_conns = {}
1919

2020
# Check Sharding class:
21-
if not self.sharding.__class__.__name__ == "Sharding":
22-
raise Exception, "'sharding' field is an instance of %s, not 'Sharding'!" % self.sharding.__class__.__name__, None
21+
if not isinstance(self.sharding, Sharding):
22+
raise Exception, "'sharding' field is not an instance of class: 'Sharding'!", None
2323

2424
# Get a DB connection
2525
try:
26-
if self.db.__class__.__name__ == "DB":
26+
if isinstance(self.db, DB):
2727
self.connection = self.db.connection()
2828
if not self.connection.is_mongos:
2929
raise Exception, 'MongoDB connection is not to a mongos!', None
3030
else:
31-
raise Exception, "'db' field is an instance of %s, not 'DB'!" % self.db.__class__.__name__, None
31+
raise Exception, "'db' field is not an instance of class: 'DB'!", None
3232
except Exception, e:
3333
logging.fatal("Could not get DB connection! Error: %s" % e)
3434
raise e

MongoBackup/Sharding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def __init__(self, db, user=None, password=None, authdb='admin', balancer_wait_s
2121

2222
# Get a DB connection
2323
try:
24-
if self.db.__class__.__name__ == "DB":
24+
if isinstance(self.db, DB):
2525
self.connection = self.db.connection()
2626
if not self.connection.is_mongos:
2727
raise Exception, 'MongoDB connection is not to a mongos!', None
2828
else:
29-
raise Exception, "'db' field is an instance of %s, not 'DB'!" % self.db.__class__.__name__, None
29+
raise Exception, "'db' field is not an instance of class: 'DB'!", None
3030
except Exception, e:
3131
logging.fatal("Could not get DB connection! Error: %s" % e)
3232
raise e

0 commit comments

Comments
 (0)