def handle(self, *args, **options): reload(sys) sys.setdefaultencoding('iso-8859-1') path = options.get('taxo_file') if path == None: raise CommandError('You need to provide the taxonomy file path --taxo-file or -f') f = open(path, 'rw') #first delete all nodes Node.objects.all().delete() taxonomy = pickle.load(f) msni = MySQLNodeImporter() for i in taxonomy: count = 0 while count < 3 : try: msni.importNode(taxonomy[i]) break except: count += 1 Command.logger.error('could not import :' . taxonomy[i]) if count == 3 : Command.logger.warning('skipping node ' . taxonomy[i])
def handle(self, *args, **options): sys.setdefaultencoding('iso-8859-1') reload(sys) taxonomy = {} BASE_DIR = options.get('base_dir') if not options.get('index') == None : Command.logger.debug('got index param') if not options.get('structure') == None : Command.logger.debug('got structure param') if BASE_DIR == None: raise CommandError('You need to provide a base directory where the taxonomy will be stored and indexed use --base-dir or -b') FreebaseIndex.buildTaxonomy(taxonomy, BASE_DIR + Command.TAXONOMY_RAW) if not options.get('index') == None : FreebaseIndex.indexTaxonomy(taxonomy, BASE_DIR + Command.TAXONOMY_INDEX) Command.logger.debug('--DONE INDEXING--') if not options.get('structure') == None : msni = MySQLNodeImporter() for node in taxonomy: msni.importNode(taxonomy[node])