Merge branch 'fs#75-mysql-flush-error-false-reddisc' into fs#70-refactoring
This commit is contained in:
17
mysqlred.py
17
mysqlred.py
@@ -92,6 +92,9 @@ class MysqlRed:
|
|||||||
"""
|
"""
|
||||||
Run cached querys
|
Run cached querys
|
||||||
"""
|
"""
|
||||||
|
if not cls.connection:
|
||||||
|
raise MysqlRedConnectionError( "No connection exists!" )
|
||||||
|
|
||||||
cursor = cls.connection.cursor()
|
cursor = cls.connection.cursor()
|
||||||
|
|
||||||
# Execute insert query
|
# Execute insert query
|
||||||
@@ -307,3 +310,17 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
|
|||||||
break
|
break
|
||||||
for row in res:
|
for row in res:
|
||||||
yield row
|
yield row
|
||||||
|
|
||||||
|
|
||||||
|
class MysqlRedError(Exception):
|
||||||
|
"""
|
||||||
|
Basic Exception class for this module
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MysqlRedConnectionError(MysqlRedError):
|
||||||
|
"""
|
||||||
|
Raised if there are Errors with Mysql-Connections
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ Script to parse all reddisc pages in configured categories
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
import pywikibot
|
import pywikibot
|
||||||
from pywikibot import pagegenerators
|
from pywikibot import pagegenerators
|
||||||
@@ -46,6 +47,10 @@ class DiscussionParserBot(
|
|||||||
Botclass witch initialises the parsing process of Redundancy Discussions
|
Botclass witch initialises the parsing process of Redundancy Discussions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# RegEx to filter wrong pages
|
||||||
|
onlyinclude_re = re.compile(
|
||||||
|
jogobot.config["redundances"]["reddiscs_onlyinclude_re"] )
|
||||||
|
|
||||||
def __init__( self, generator ):
|
def __init__( self, generator ):
|
||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
@@ -86,24 +91,42 @@ class DiscussionParserBot(
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Exclude pages which does not match pattern
|
||||||
|
if not type(self).onlyinclude_re.search( self.current_page.title() ):
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
# Initiate RedPage object
|
# Initiate RedPage object
|
||||||
red_page = redpage.RedPage( self.current_page )
|
red_page = redpage.RedPage( self.current_page )
|
||||||
|
|
||||||
# Check whether parsing is needed
|
# Check whether parsing is needed
|
||||||
if red_page.is_parsing_needed():
|
if red_page.is_parsing_needed():
|
||||||
|
|
||||||
|
# Count families for failure analysis
|
||||||
|
fam_counter = 0
|
||||||
|
|
||||||
# Iterate over returned generator with redfam sections
|
# Iterate over returned generator with redfam sections
|
||||||
for fam in red_page.parse():
|
for fam in red_page.parse():
|
||||||
|
|
||||||
# Run RedFamParser on section text
|
# Run RedFamParser on section text
|
||||||
redfam.RedFamParser.parser( fam, red_page.page._pageid,
|
redfam.RedFamParser.parser( fam, red_page.page._pageid,
|
||||||
red_page.is_archive() )
|
red_page.is_archive() )
|
||||||
|
|
||||||
|
fam_counter += 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# If successfully parsed whole page, flush
|
# If successfully parsed whole page, flush
|
||||||
# db write cache
|
# db write cache
|
||||||
redfam.RedFamParser.flush_db_cache()
|
if( fam_counter ):
|
||||||
jogobot.output( "Page [[{redisc}]] parsed".format(
|
redfam.RedFamParser.flush_db_cache()
|
||||||
reddisc=red_page.page.title() ) )
|
jogobot.output( "Page [[{reddisc}]] parsed".format(
|
||||||
|
reddisc=red_page.page.title() ) )
|
||||||
|
else:
|
||||||
|
jogobot.output(
|
||||||
|
"\03{red}" + "Page [[{reddisc}]], ".format(
|
||||||
|
reddisc=red_page.page.title() ) +
|
||||||
|
"containing no redfam, parsed!",
|
||||||
|
"WARNING" )
|
||||||
|
|
||||||
|
|
||||||
def apply_conf_cat_generators( genFactory ):
|
def apply_conf_cat_generators( genFactory ):
|
||||||
|
|||||||
Reference in New Issue
Block a user