@@ -35,6 +35,7 @@ def compact(server, dbnames):
35
35
db .resource .post ('_compact' )
36
36
37
37
def main ():
38
+
38
39
usage = '%prog [options]'
39
40
parser = optparse .OptionParser (usage = usage )
40
41
parser .add_option ('--source-server' ,
@@ -72,6 +73,7 @@ def main():
72
73
options .source_url = options .source_url + '/'
73
74
if not options .target_url .endswith ('/' ):
74
75
options .target_url = options .target_url + '/'
76
+
75
77
source_server = couchdb .client .Server (options .source_url )
76
78
target_server = couchdb .client .Server (options .target_url )
77
79
@@ -82,24 +84,28 @@ def main():
82
84
83
85
targetdbs = sorted (i for i in target_server )
84
86
for dbname in sorted (dbnames , reverse = True ):
87
+
85
88
start = time .time ()
86
89
print dbname ,
87
90
sys .stdout .flush ()
88
91
if dbname not in targetdbs :
89
92
target_server .create (dbname )
90
93
print "created" ,
91
94
sys .stdout .flush ()
95
+
92
96
body = {}
93
97
if options .continuous :
94
98
body ['continuous' ] = True
99
+
95
100
if options .push :
96
101
body .update ({'source' : dbname , 'target' : '%s%s' % (options .target_url , dbname )})
97
102
source_server .resource .post ('_replicate' , body )
98
103
else :
99
104
# pull seems to be more reliable than push
100
105
body .update ({'source' : '%s%s' % (options .source_url , dbname ), 'target' : dbname })
101
106
target_server .resource .post ('_replicate' , body )
102
- print "%.1f s" % (time .time () - start )
107
+
108
+ print '%.1fs' % (time .time () - start )
103
109
104
110
if options .compact_target :
105
111
compact (target_server , dbnames )
0 commit comments