class SpotAliens:
def __init__(self,verbose):
- print "==================== initializing ..",
+ print("==================== initializing ..", end=' ')
self.verbose=verbose
self.all_sites=GetSites({},['peer_id','site_id','login_base','name'])
self.all_nodes=GetNodes({},['peer_id','node_id','site_id','hostname'])
self.site_hash=dict ( [ (site['site_id'],site) for site in self.all_sites ] )
self.key_hash=dict ( [ (key['key_id'],key) for key in self.all_keys ] )
self.slice_hash=dict ( [ (slice['slice_id'],slice) for slice in self.all_slices ] )
- print "done"
+ print("done")
def spot_nodes (self):
"nodes are expected to be in the same peer as their owning site"
site=self.site_hash[node['site_id']]
if node['peer_id'] != site['peer_id']:
counter+=1
- if self.verbose: print "NODE-SITE mismatch %r IN SITE %r"%(node,site)
- print '==================== Found %d inconsistent nodes'%counter
+ if self.verbose: print("NODE-SITE mismatch %r IN SITE %r"%(node,site))
+ print('==================== Found %d inconsistent nodes'%counter)
def spot_slices (self):
"slices are expected to be in the same peer as their owning site"
site=self.site_hash[slice['site_id']]
if slice['peer_id'] != site['peer_id']:
counter+=1
- if self.verbose: print "SLICE-SITE mismatch %r IN SITE %r"%(slice,site)
- print '==================== Found %d inconsistent slices'%counter
+ if self.verbose: print("SLICE-SITE mismatch %r IN SITE %r"%(slice,site))
+ print('==================== Found %d inconsistent slices'%counter)
def spot_persons (self):
"persons are expected to be in the same peer as their owning site"
site=self.site_hash[site_id]
if person['peer_id'] != site['peer_id']:
counter+=1
- if self.verbose: print "PERSON-SITE mismatch %r IN SITE %r"%(person,site)
- print '==================== Found %d inconsistent persons'%counter
+ if self.verbose: print("PERSON-SITE mismatch %r IN SITE %r"%(person,site))
+ print('==================== Found %d inconsistent persons'%counter)
def spot_keys (self):
"persons are expected to be in the same peer as their attached keys"
key=self.key_hash[key_id]
if person['peer_id'] != key['peer_id']:
counter+=1
- if self.verbose: print "PERSON-KEY mismatch %r & KEY %r"%(person,key)
- print '==================== Found %d inconsistent keys'%counter
+ if self.verbose: print("PERSON-KEY mismatch %r & KEY %r"%(person,key))
+ print('==================== Found %d inconsistent keys'%counter)
def spot_foreign (self):
"foreign persons should not have a site"
counter=1
for person in self.all_persons:
if person['peer_id'] and person['site_ids']:
- if self.verbose: print "WARNING Foreign person %r attached on sites:"%person
+ if self.verbose: print("WARNING Foreign person %r attached on sites:"%person)
for site_id in person['site_ids']:
counter+=1
- if self.verbose: print " %r"%self.site_hash[site_id]
- print '==================== Found %d foreign persons with a site'%counter
+ if self.verbose: print(" %r"%self.site_hash[site_id])
+ print('==================== Found %d foreign persons with a site'%counter)
def main ():
usage="""Usage: %prog [-- options]