Commit 39a684c9 authored by Sriram Karra's avatar Sriram Karra

Ensure --cduser and --cdpwd args are parsed and handled properly

This is a regression from a recent refactoring in a related area.
Fixes: https://github.com/skarra/ASynK/issues/87
parent fa1486d4
......@@ -561,8 +561,7 @@ class Asynk:
if pname:
if not pname in conf.get_profile_names():
logging.error('Profile "%s" not found. Nothing to do.', pname)
return None
raise AsynkParserError('Profile "%s" not found' % pname)
self.set_name(pname)
......@@ -572,7 +571,10 @@ class Asynk:
db1c = coll_id_class[db1id]
db2c = coll_id_class[db2id]
assert len(self.colls) == 0
if len(self.colls) != 0:
## FIXME: this looks ugly but unless the command line flags
## handling is rewritten in whole hard to avoid.
self.colls = []
## FIXME: Why were we not setting fid?
self.add_coll(db1c(config=conf, stid=conf.get_stid1(pname),
......
......@@ -270,7 +270,7 @@ class Config:
def _get_profile_prop (self, profile, key):
if not profile in self.state['state']['profiles']:
raise AsynkConfigError('Profile %s not found in state.json'
% profile)
% profile)
try:
return self.state['state']['profiles'][profile][key]
......@@ -281,7 +281,7 @@ class Config:
def _set_profile_prop (self, profile, key, val, sync=True):
if not profile in self.state['state']['profiles']:
raise AsynkConfigError('Profile %s not found in state.json'
% profile)
% profile)
self.state['state']['profiles'][profile].update({key : val})
......
......@@ -202,6 +202,9 @@ class AsynkBuilderC:
raise AsynkParserError('--cdpwd and --gcpwd should together have'
'only 2 values')
if len(self.asynk.get_colls()) == 0:
self.asynk._load_profile()
if uinps.gcuser:
for i, gcuser in enumerate(uinps.gcuser):
coll = self.asynk.get_colls()[i]
......@@ -283,13 +286,13 @@ class AsynkBuilderC:
self.asynk.set_sync_all(uinps.sync_all)
self._snarf_store_ids(uinps)
self._snarf_auth_creds(uinps)
self._snarf_folder_ids(uinps)
self._snarf_sync_dir(uinps)
self.asynk.set_label_re(uinps.label_regex)
self.asynk.set_conflict_resolve(uinps.conflict_resolve)
self.asynk.set_item_id(uinps.item)
self._snarf_auth_creds(uinps)
# self.asynk.set_port(uinps.port)
def main (argv=sys.argv):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment