added sync_with_gateway change function in wnf.py

This commit is contained in:
Anand Doshi 2012-02-09 13:34:12 +05:30
parent dae6e1e6a2
commit bae6908bdc
2 changed files with 15 additions and 3 deletions

View File

@ -1 +1 @@
383 384

12
wnf.py
View File

@ -56,6 +56,7 @@ def setup_options():
help="export doc") help="export doc")
parser.add_option('--install', nargs=3, metavar = "rootpassword dbname source", parser.add_option('--install', nargs=3, metavar = "rootpassword dbname source",
help="install fresh db") help="install fresh db")
parser.add_option('--sync_with_gateway', nargs=1, metavar = "1/0", help="Set or Unset Sync with Gateway")
return parser.parse_args() return parser.parse_args()
@ -140,6 +141,17 @@ def run():
inst.import_from_db(options.install[1], source_path=options.install[2], \ inst.import_from_db(options.install[1], source_path=options.install[2], \
password='admin', verbose = 1) password='admin', verbose = 1)
elif options.sync_with_gateway:
if int(options.sync_with_gateway[0]) in [0, 1]:
webnotes.conn.begin()
webnotes.conn.sql("""\
UPDATE `tabSingles` SET value=%s
WHERE field='sync_with_gateway' AND doctype='Control Panel'""", int(options.sync_with_gateway[0]))
webnotes.conn.commit()
webnotes.message_log.append("sync_with_gateway set to %s" % options.sync_with_gateway[0])
else:
webnotes.message_log.append("ERROR: sync_with_gateway can be either 0 or 1")
# print messages # print messages
if webnotes.message_log: if webnotes.message_log:
print '\n'.join(webnotes.message_log) print '\n'.join(webnotes.message_log)