@@ -35,6 +35,7 @@ def compact(server, dbnames):
3535 db .resource .post ('_compact' )
3636
3737def main ():
38+
3839 usage = '%prog [options]'
3940 parser = optparse .OptionParser (usage = usage )
4041 parser .add_option ('--source-server' ,
@@ -72,6 +73,7 @@ def main():
7273 options .source_url = options .source_url + '/'
7374 if not options .target_url .endswith ('/' ):
7475 options .target_url = options .target_url + '/'
76+
7577 source_server = couchdb .client .Server (options .source_url )
7678 target_server = couchdb .client .Server (options .target_url )
7779
@@ -82,24 +84,28 @@ def main():
8284
8385 targetdbs = sorted (i for i in target_server )
8486 for dbname in sorted (dbnames , reverse = True ):
87+
8588 start = time .time ()
8689 print dbname ,
8790 sys .stdout .flush ()
8891 if dbname not in targetdbs :
8992 target_server .create (dbname )
9093 print "created" ,
9194 sys .stdout .flush ()
95+
9296 body = {}
9397 if options .continuous :
9498 body ['continuous' ] = True
99+
95100 if options .push :
96101 body .update ({'source' : dbname , 'target' : '%s%s' % (options .target_url , dbname )})
97102 source_server .resource .post ('_replicate' , body )
98103 else :
99104 # pull seems to be more reliable than push
100105 body .update ({'source' : '%s%s' % (options .source_url , dbname ), 'target' : dbname })
101106 target_server .resource .post ('_replicate' , body )
102- print "%.1f s" % (time .time () - start )
107+
108+ print '%.1fs' % (time .time () - start )
103109
104110 if options .compact_target :
105111 compact (target_server , dbnames )
0 commit comments