Skip to content

Commit d3f82de

Browse files
committed
IDURL fix in contacts/contactsdb.py and small fix in main/config.py
1 parent 20b06e6 commit d3f82de

File tree

6 files changed

+35
-12
lines changed

6 files changed

+35
-12
lines changed

bitdust/contacts/contactsdb.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ def set_suppliers(idlist, customer_idurl=None):
169169
if customer_idurl not in _SuppliersList:
170170
_SuppliersList[customer_idurl] = []
171171
lg.info('created new suppliers list in memory for customer %r' % customer_idurl)
172-
_SuppliersList[customer_idurl] = id_url.fields_list(idlist)
172+
try:
173+
_SuppliersList[customer_idurl] = id_url.fields_list(idlist)
174+
except:
175+
pass
173176
if _Debug:
174177
lg.args(_DebugLevel, suppliers=_SuppliersList[customer_idurl], customer_idurl=customer_idurl)
175178

@@ -308,7 +311,10 @@ def set_customers(idlist):
308311
Set customers list.
309312
"""
310313
global _CustomersList
311-
_CustomersList = id_url.fields_list(idlist)
314+
try:
315+
_CustomersList = id_url.fields_list(idlist)
316+
except:
317+
pass
312318

313319

314320
def update_customers(idslist):

bitdust/interface/api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def config_get(key, include_info=False):
10491049
return ERROR('empty key')
10501050
if _Debug:
10511051
lg.out(_DebugLevel, 'api.config_get [%s]' % key)
1052-
if not config.conf().exist(key):
1052+
if not config.conf().registered(key):
10531053
return ERROR('option %s does not exist' % key)
10541054
if not config.conf().hasChilds(key):
10551055
return RESULT([
@@ -1085,6 +1085,8 @@ def config_set(key, value):
10851085
"""
10861086
key = strng.to_text(key)
10871087
v = {}
1088+
if not config.conf().registered(key):
1089+
return ERROR('option %s does not exist' % key)
10881090
if config.conf().exist(key):
10891091
v['old_value'] = config.conf().getValueOfType(key)
10901092
typ_label = config.conf().getTypeLabel(key)

bitdust/main/config.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def getConfigDir(self):
104104
def exist(self, entryPath):
105105
return self._get(entryPath) is not None
106106

107+
def registered(self, entryPath):
108+
return self._exists(entryPath)
109+
107110
def remove(self, entryPath):
108111
elemList = self._parseEntryPath(entryPath)
109112
fpath = os.path.join(self.configDir, *elemList)
@@ -285,6 +288,15 @@ def _parseEntryPath(self, entryPath):
285288
self._validateElemList(elemList)
286289
return elemList
287290

291+
def _exists(self, entryPath):
292+
elemList = self._parseEntryPath(entryPath)
293+
fpath = os.path.join(self.configDir, *elemList)
294+
if os.path.isdir(fpath):
295+
return True
296+
elif os.path.isfile(fpath):
297+
return True
298+
return False
299+
288300
def _get(self, entryPath):
289301
elemList = self._parseEntryPath(entryPath)
290302
fpath = os.path.join(self.configDir, *elemList)
@@ -406,9 +418,6 @@ def __init__(self, configDir):
406418
self._types = {}
407419
self._labels = {}
408420

409-
def types(self):
410-
return
411-
412421
def listKnownTypes(self):
413422
return list(self._types.keys())
414423

bitdust/main/initializer.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,13 @@ def A(event=None, *args, **kwargs):
228228
"""
229229
global _Initializer
230230
if _Initializer is None:
231-
_Initializer = Initializer('initializer', 'AT_STARTUP', 2, True)
231+
_Initializer = Initializer(
232+
name='initializer',
233+
state='AT_STARTUP',
234+
debug_level=_DebugLevel,
235+
log_events=_Debug,
236+
log_transitions=_Debug,
237+
)
232238
if event is not None:
233239
if kwargs.get('use_reactor', True):
234240
_Initializer.automat(event, *args, **kwargs)

bitdust/userid/id_server.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def A(event=None, *args, **kwargs):
101101
_IdServer = IdServer(
102102
name='id_server',
103103
state='AT_STARTUP',
104-
debug_level=_Debug,
105-
log_events=True,
106-
log_transitions=True,
104+
debug_level=_DebugLevel,
105+
log_events=_Debug,
106+
log_transitions=_Debug,
107107
)
108108
if event is None:
109109
return _IdServer

bitdust/userid/id_url.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def idurl_to_id(idurl_text, by_parts=False):
741741
class ID_URL_FIELD(object):
742742
"""
743743
A class represents a valid, verified and synced IDURL identifier of a device.
744-
The IDURL is always corresponds to your own identity file.
744+
The IDURL is always corresponding to the identity file.
745745
746746
When your identity file is updated due to rotation to another identity server,
747747
the "host" component of your IDURL is changed:
@@ -944,7 +944,7 @@ def refresh(self, replace_original=True):
944944
caller_modul = os.path.basename(caller_code.co_filename).replace('.py', '')
945945
if caller_method.count('lambda') or caller_method == 'field':
946946
caller_method = sys._getframe(1).f_back.f_code.co_name
947-
exc = ValueError('tried to modify username of the identity %r -> %r' % (self.current, self.latest))
947+
exc = ValueError('while refreshing tried to modify username of the identity %r -> %r' % (self.current, self.latest))
948948
lg.exc(msg='called from %s.%s()' % (caller_modul, caller_method), exc_value=exc)
949949
raise exc
950950
self.latest_host = latest_host

0 commit comments

Comments
 (0)