def convertDb(sqlDumpFileName): foLog = None try: logEvent("convertDb(%s) called" % sqlDumpFileName) connRoot = wikiToDbConvert.getRootConnection() dbName = wikiToDbConvert.getDbNameFromFileName(sqlDumpFileName) if dbName in wikiToDbConvert.getDbList(): logEvent("db '%s' already exists" % dbName) return logEvent("started creating db %s" % dbName) wikiToDbConvert.createDb(connRoot,dbName) timer = arsutils.Timer(fStart=True) logFileName = wikipediasql.getLogFileName(sqlDumpFileName) # use small buffer so that we can observe changes with tail -w foLog = open(logFileName, "wb", 64) sys.stdout = foLog # sys.stderr = foLog wikiToDbConvert.convertArticles(sqlDumpFileName,articleLimit=None) wikiToDbConvert.calcReverseLinks(sqlDumpFileName) timer.stop() durInSecs = timer.getDurationInSecs() durTxt = arsutils.timeInSecsToTxt(durInSecs) logEvent("db %s created in %s" % (dbName, durTxt)) timer = arsutils.Timer(fStart=True) wikiToDbConvert.createFtIndex() timer.stop() durInSecs = timer.getDurationInSecs() durTxt = arsutils.timeInSecsToTxt(durInSecs) logEvent("full-text index for db %s created in %s" % (dbName, durTxt)) ARTICLE_COUNT_DELTA = 3000 # should be same as in iPediaServer.py articlesCount = wikiToDbConvert.getIpediaArticlesCount() - ARTICLE_COUNT_DELTA logEvent("%d articles in db %s" % (articlesCount, dbName)) finally: wikiToDbConvert.deinitDatabase() if None != foLog: foLog.close()
if len(sys.argv) != 2: usageAndExit() sqlDump = sys.argv[1] if fRevLinksOnly: revLinksOnly(sqlDump) sys.exit(0) foLog = None try: createIpediaDb(sqlDump,fRecreateDb) timer = arsutils.Timer(fStart=True) logFileName = wikipediasql.getLogFileName(sqlDump) # use small buffer so that we can observe changes with tail -w foLog = open(logFileName, "wb", 64) sys.stdout = foLog # sys.stderr = foLog convertArticles(sqlDump,articleLimit) calcReverseLinks(sqlDump) timer.stop() timer.dumpInfo("converting database: ") timer = arsutils.Timer(fStart=True) createFtIndex() timer.stop() timer.dumpInfo("creating full-text index: ") finally: deinitDatabase()
if len(sys.argv) != 2: usageAndExit() sqlDump = sys.argv[1] if fRevLinksOnly: revLinksOnly(sqlDump) sys.exit(0) foLog = None try: createIpediaDb(sqlDump, fRecreateDb) timer = arsutils.Timer(fStart=True) logFileName = wikipediasql.getLogFileName(sqlDump) # use small buffer so that we can observe changes with tail -w foLog = open(logFileName, "wb", 64) sys.stdout = foLog # sys.stderr = foLog convertArticles(sqlDump, articleLimit) calcReverseLinks(sqlDump) timer.stop() timer.dumpInfo("converting database: ") timer = arsutils.Timer(fStart=True) createFtIndex() timer.stop() timer.dumpInfo("creating full-text index: ") finally: deinitDatabase()