def GetArtifactKnowledgeBase(client_obj, allow_uninitialized=False):
 client_schema = client_obj.Schema
 kb = client_obj.Get(client_schema.KNOWLEDGE_BASE)
 if (not allow_uninitialized):
  if (not kb):
   raise artifact_utils.KnowledgeBaseUninitializedError(('KnowledgeBase empty for %s.' % client_obj.urn))
  if (not kb.os):
   raise artifact_utils.KnowledgeBaseAttributesMissingError(('KnowledgeBase missing OS for %s. Knowledgebase content: %s' % (client_obj.urn, kb)))
 if (not kb):
  kb = client_schema.KNOWLEDGE_BASE()
  SetCoreGRRKnowledgeBaseValues(kb, client_obj)
 if (kb.os == 'Windows'):
  if ((not kb.environ_allusersappdata) and kb.environ_allusersprofile):
   if (kb.os_major_version >= 6):
    kb.environ_allusersappdata = u'c:\\programdata'
    kb.environ_allusersprofile = u'c:\\programdata'
   else:
    kb.environ_allusersappdata = u'c:\\documents and settings\\All Users\\Application Data'
    kb.environ_allusersprofile = u'c:\\documents and settings\\All Users'
 return kb

def GetArtifactKnowledgeBase ( client_obj , allow_uninitialized = False ) : client_schema = client_obj . Schema kb = client_obj . Get ( client_schema . KNOWLEDGE_BASE ) if ( not allow_uninitialized ) : if ( not kb ) : raise artifact_utils . KnowledgeBaseUninitializedError ( ( 'KnowledgeBase empty for %s.' % client_obj . urn ) ) if ( not kb . os ) : raise artifact_utils . KnowledgeBaseAttributesMissingError ( ( 'KnowledgeBase missing OS for %s. Knowledgebase content: %s' % ( client_obj . urn , kb ) ) ) if ( not kb ) : kb = client_schema . KNOWLEDGE_BASE ( ) SetCoreGRRKnowledgeBaseValues ( kb , client_obj ) if ( kb . os == 'Windows' ) : if ( ( not kb . environ_allusersappdata ) and kb . environ_allusersprofile ) : if ( kb . os_major_version >= 6 ) : kb . environ_allusersappdata = u'c:\\programdata' kb . environ_allusersprofile = u'c:\\programdata' else : kb . environ_allusersappdata = u'c:\\documents and settings\\All Users\\Application Data' kb . environ_allusersprofile = u'c:\\documents and settings\\All Users' return kb
this generates an artifact knowledge base from a grr client .