Skip to content

Commit

Permalink
See CHANGELOG v2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnavarro committed Nov 1, 2023
1 parent d0f6676 commit accff0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v2.0.9 2023-11-01 JP
- Implement Logging_Muted to not repease Undefined ResourceID messages
- Fix Get_HTTP status_code error logging

v2.0.8 2023-11-01 JP
- Convert to using resource_v4/processing.py

Expand Down
27 changes: 20 additions & 7 deletions bin/router_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def Setup(self, peak_sleep=10, offpeak_sleep=60, max_stale=24 * 60):
self.Affiliation = 'access-ci.org'
self.DefaultValidity = timedelta(days = 14)

self.RSPGW_NAME_URNMAP = {} # RSP Gateway Name map to URN
self.RSPSUPPORT_GLOBALID_URNMAP = {} # RSP Support GlobalID map to URN
self.RSPSUPPORT_URL_URNMAP = {} # RSP Support Information Services URL map to URN

Expand All @@ -232,7 +231,7 @@ def Setup(self, peak_sleep=10, offpeak_sleep=60, max_stale=24 * 60):
# Used in Get_HTTP as memory cache for contents
self.HTTP_CACHE = {}
self.URL_USE_COUNT = {}

# Loading all the Catalog entries for our affiliation
self.CATALOGS = {}
for cat in ResourceV4Catalog.objects.filter(Affiliation__exact=self.Affiliation):
Expand Down Expand Up @@ -347,7 +346,7 @@ def Get_HTTP(self, url, contype):
return(None)

status_code = content.get('status_code')
if status_code and status_code != '200':
if status_code and str(status_code) != '200':
self.logger.error('Response status_code error: {}'.format(status_code))

if content.get('results'):
Expand Down Expand Up @@ -394,6 +393,17 @@ def Read_CACHE(self, file, contype):
self.logger.error('Error "{}" parsing file={}'.format(e, file))
self.exit(1)

def Logger_Muted(self, logger_function, prefix, extra):
if prefix not in self.LOGGER_PREFIXES: # First time, log normally
logger_function(prefix if not extra else ' '.join([prefix, extra]))
self.LOGGER_PREFIXES[prefix] = 1
elif self.LOGGER_PREFIXES[prefix] == 1: # Second time, log will MUTE
logger_function(' '.join([prefix, 'MUTING FUTURE MESSAGES ...']))
self.LOGGER_PREFIXES[prefix] += 1
else: # MUTE additional
self.LOGGER_PREFIXES[prefix] += 1
return

########## CUSTOMIZATIONS START ##########
#
# Delete old items (those in 'cur') that weren't updated (those in 'new')
Expand Down Expand Up @@ -589,8 +599,9 @@ def Write_Glue2_Network_Service(self, content, contype, config):
try:
myResourceURN = self.CIDERRESOURCE_INFOID_URNMAP[item['ResourceID']]
except:
msg = 'Undefined ResourceID={} in Local ID={}'.format(item['ResourceID'], myGLOBALURN)
self.logger.error(msg)
self.Logger_Muted(self.logger.error,
'Undefined ResourceID={} in Local'.format(item['ResourceID']),
'ID={}'.format(myGLOBALURN) )
continue
providerURN = self.CIDERRESOURCE_URN_INFO[myResourceURN]['ProviderID']
# The new relations for this item, key=related ID, value=type of relation
Expand Down Expand Up @@ -708,8 +719,9 @@ def Write_Glue2_Executable_Software(self, content, contype, config):
try:
myResourceURN = self.CIDERRESOURCE_INFOID_URNMAP[item['ResourceID']]
except:
msg = 'Undefined ResourceID={} in Local ID={}'.format(item['ResourceID'], myGLOBALURN)
self.logger.error(msg)
self.Logger_Muted(self.logger.error,
'Undefined ResourceID={} in Local'.format(item['ResourceID']),
'ID={}'.format(myGLOBALURN) )
continue
providerURN = self.CIDERRESOURCE_URN_INFO[myResourceURN]['ProviderID']
# The new relations for this item, key=related ID, value=type of relation
Expand Down Expand Up @@ -1270,6 +1282,7 @@ def Run(self):
loop_start_utc = datetime.now(timezone.utc)
self.STATS = Counter()
self.PROCESSING_SECONDS = {}
self.LOGGER_PREFIXES = {} # Used by Logger_Muted

for stepconf in self.STEPS:
step_start_utc = datetime.now(timezone.utc)
Expand Down

0 comments on commit accff0d

Please sign in to comment.