def diagnose():
 print('')
 print('KA Lite diagnostics')
 print('')
 print('Calculating diagnostics...')
 sys.stdout.flush()
 print('')
 diagnostics = []
 diag = (lambda x, y: diagnostics.append((x, y)))
 diag('KA Lite version', kalite.__version__)
 diag('python', sys.version)
 diag('platform', platform.platform())
 (status_code, urls) = get_urls()
 for addr in urls:
  diag('server address', addr)
 for addr in get_urls_proxy():
  diag('server proxy', addr)
 diag('server status', status.codes[status_code])
 settings_imported = True
 try:
  from django.conf import settings
  from django.template.defaultfilters import filesizeformat
 except:
  settings_imported = False
  diag('Settings failure', traceback.format_exc())
 if settings_imported:
  diag('installed in', os.path.dirname(kalite.__file__))
  diag('content root', settings.CONTENT_ROOT)
  diag('content size', filesizeformat(get_size(settings.CONTENT_ROOT)))
  diag('user database', settings.DATABASES['default']['NAME'])
  try:
   from securesync.models import Device
   device = Device.get_own_device()
   sync_sessions = device.client_sessions.all()
   zone = device.get_zone()
   diag('device name', str(device.name))
   diag('device ID', str(device.id))
   diag('device registered', str(device.is_registered()))
   diag('synced', str((sync_sessions.latest('timestamp').timestamp if sync_sessions.exists() else 'Never')))
   diag('sync result', (('OK' if (sync_sessions.latest('timestamp').errors == 0) else 'Error') if sync_sessions.exists() else '-'))
   diag('zone ID', (str(zone.id) if zone else 'Unset'))
  except:
   diag('Device failure', traceback.format_exc())
 for (k, v) in diagnostics:
  values = str(v).split('\n')
  values = '\n'.join(([values[0]] + map((lambda x: ((' ' * 22) + x)), values[1:])))
  print((k.upper() + ': ').ljust(21), values)

def diagnose ( ) : print ( '' ) print ( 'KA Lite diagnostics' ) print ( '' ) print ( 'Calculating diagnostics...' ) sys . stdout . flush ( ) print ( '' ) diagnostics = [ ] diag = ( lambda x , y : diagnostics . append ( ( x , y ) ) ) diag ( 'KA Lite version' , kalite . __version__ ) diag ( 'python' , sys . version ) diag ( 'platform' , platform . platform ( ) ) ( status_code , urls ) = get_urls ( ) for addr in urls : diag ( 'server address' , addr ) for addr in get_urls_proxy ( ) : diag ( 'server proxy' , addr ) diag ( 'server status' , status . codes [ status_code ] ) settings_imported = True try : from django . conf import settings from django . template . defaultfilters import filesizeformat except : settings_imported = False diag ( 'Settings failure' , traceback . format_exc ( ) ) if settings_imported : diag ( 'installed in' , os . path . dirname ( kalite . __file__ ) ) diag ( 'content root' , settings . CONTENT_ROOT ) diag ( 'content size' , filesizeformat ( get_size ( settings . CONTENT_ROOT ) ) ) diag ( 'user database' , settings . DATABASES [ 'default' ] [ 'NAME' ] ) try : from securesync . models import Device device = Device . get_own_device ( ) sync_sessions = device . client_sessions . all ( ) zone = device . get_zone ( ) diag ( 'device name' , str ( device . name ) ) diag ( 'device ID' , str ( device . id ) ) diag ( 'device registered' , str ( device . is_registered ( ) ) ) diag ( 'synced' , str ( ( sync_sessions . latest ( 'timestamp' ) . timestamp if sync_sessions . exists ( ) else 'Never' ) ) ) diag ( 'sync result' , ( ( 'OK' if ( sync_sessions . latest ( 'timestamp' ) . errors == 0 ) else 'Error' ) if sync_sessions . exists ( ) else '-' ) ) diag ( 'zone ID' , ( str ( zone . id ) if zone else 'Unset' ) ) except : diag ( 'Device failure' , traceback . format_exc ( ) ) for ( k , v ) in diagnostics : values = str ( v ) . split ( '\n' ) values = '\n' . join ( ( [ values [ 0 ] ] + map ( ( lambda x : ( ( ' ' * 22 ) + x ) ) , values [ 1 : ] ) ) ) print ( ( k . upper ( ) + ': ' ) . ljust ( 21 ) , values )
report diagnosis for any symptoms we find .