@@ -32,15 +32,6 @@ def main():
32
32
33
33
usage = '%prog [options]'
34
34
parser = optparse .OptionParser (usage = usage )
35
- parser .add_option ('--source-server' ,
36
- action = 'store' ,
37
- dest = 'source_url' ,
38
- help = 'the url of the server to replicate from' )
39
- parser .add_option ('--target-server' ,
40
- action = 'store' ,
41
- dest = 'target_url' ,
42
- default = "http://127.0.0.1:5984" ,
43
- help = 'the url of the server to replicate to [%default]' )
44
35
parser .add_option ('--database' ,
45
36
action = 'append' ,
46
37
dest = 'dbnames' ,
@@ -55,17 +46,17 @@ def main():
55
46
help = 'trigger continuous replication in cochdb' )
56
47
57
48
options , args = parser .parse_args ()
58
- if not options .target_url or (not options .source_url ):
59
- parser .error ("Need at least --source-server and --target-server" )
60
- sys .exit (1 )
49
+ if len (args ) != 2 :
50
+ raise parser .error ('need source and target arguments' )
61
51
62
- if not options .source_url .endswith ('/' ):
63
- options .source_url = options .source_url + '/'
64
- if not options .target_url .endswith ('/' ):
65
- options .target_url = options .target_url + '/'
52
+ src , tgt = args
53
+ if not src .endswith ('/' ):
54
+ src += '/'
55
+ if not tgt .endswith ('/' ):
56
+ tgt += '/'
66
57
67
- source_server = couchdb .client .Server (options . source_url )
68
- target_server = couchdb .client .Server (options . target_url )
58
+ source_server = couchdb .client .Server (src )
59
+ target_server = couchdb .client .Server (tgt )
69
60
70
61
if not options .dbnames :
71
62
dbnames = sorted (i for i in source_server )
@@ -87,7 +78,7 @@ def main():
87
78
if options .continuous :
88
79
body ['continuous' ] = True
89
80
90
- body .update ({'source' : '%s%s' % (options . source_url , dbname ), 'target' : dbname })
81
+ body .update ({'source' : '%s%s' % (src , dbname ), 'target' : dbname })
91
82
target_server .resource .post ('_replicate' , body )
92
83
print '%.1fs' % (time .time () - start )
93
84
0 commit comments