diff options
author | Marko Kreen | 2013-03-30 18:27:26 +0000 |
---|---|---|
committer | Marko Kreen | 2013-04-17 15:35:08 +0000 |
commit | 25f2525c1005a0155299d1fb652b5c313128e324 (patch) | |
tree | a369ab547617723e981cf213bc3a06edf3c74358 | |
parent | d33f3ae9e971fc1957ec6280d16708280f55d498 (diff) |
londiste add: --skip-non-existing option
-rwxr-xr-x | python/londiste.py | 2 | ||||
-rw-r--r-- | python/londiste/setup.py | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/python/londiste.py b/python/londiste.py index 6582abea..8860a313 100755 --- a/python/londiste.py +++ b/python/londiste.py @@ -148,6 +148,8 @@ class Londiste(skytools.DBScript): help="don't merge tables from source queues", default=False) g.add_option("--max-parallel-copy", metavar = "NUM", type = "int", help="max number of parallel copy processes") + g.add_option("--skip-non-existing", action="store_true", + help="add: skip object that does not exist") p.add_option_group(g) g = optparse.OptionGroup(p, "other options") diff --git a/python/londiste/setup.py b/python/londiste/setup.py index a7dbb13e..204850b6 100644 --- a/python/londiste/setup.py +++ b/python/londiste/setup.py @@ -81,6 +81,8 @@ class LondisteSetup(CascadeAdmin): help="max number of parallel copy processes") p.add_option("--dest-table", metavar = "NAME", help="add: name for actual table") + p.add_option("--skip-non-existing", action="store_true", + help="add: skip object that does not exist") return p def extra_init(self, node_type, node_db, provider_db): @@ -184,6 +186,7 @@ class LondisteSetup(CascadeAdmin): src_curs = src_db.cursor() dst_curs = dst_db.cursor() tbl_exists = skytools.exists_table(dst_curs, dest_table) + dst_db.commit() if dest_table == tbl: desc = tbl @@ -211,6 +214,9 @@ class LondisteSetup(CascadeAdmin): if src_dest_table != dest_table: newname = dest_table s.create(dst_curs, create_flags, log = self.log, new_table_name = newname) + elif not tbl_exists and self.options.skip_non_existing: + self.log.warning('Table %s does not exist on local node, skipping', desc) + return tgargs = self.build_tgargs() @@ -395,8 +401,11 @@ class LondisteSetup(CascadeAdmin): src_db.commit() s.create(dst_curs, create_flags, log = self.log) elif not seq_exists: - self.log.warning('Sequence "%s" missing on subscriber, use --create if necessary', seq) - return + if self.options.skip_non_existing: + self.log.warning('Sequence "%s" missing on local node, skipping', seq) + return + else: + raise skytools.UsageError("Sequence %r missing on local node", seq) q = "select * from londiste.local_add_seq(%s, %s)" self.exec_cmd(dst_curs, q, [self.set_name, seq]) |