summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2016-07-04 13:11:44 -0400
committerFélix Sipma <felix.sipma@no-log.org>2016-07-04 13:11:44 -0400
commit33c1edda4eb40ecf890c51752f547ac3fe3948b0 (patch)
treeaca2911ad805fe7c33047d7ad099683ef9e7516e
parent126b7b4d291245f7e11b671a697c57d678c8cae6 (diff)
get page by config section name in db (API change)
-rwxr-xr-xwebdiff12
1 files changed, 7 insertions, 5 deletions
diff --git a/webdiff b/webdiff
index f9a67f8..73cd638 100755
--- a/webdiff
+++ b/webdiff
@@ -136,6 +136,7 @@ metadata = schema.MetaData()
page_table = schema.Table(
'page', metadata,
schema.Column('page_id', types.Integer, primary_key=True),
+ schema.Column('section', types.String),
schema.Column('url', types.String),
schema.Column('content', types.PickleType(protocol=2)), # python2
schema.Column('last_check', types.DateTime(), default=now),
@@ -255,17 +256,18 @@ def diff(old_list, new_list, old_title, new_title):
return difflib.unified_diff(old_list, new_list, old_title, new_title)
-def check_page(url, data, timeout, interval, block_from, block_to, block_skip,
- format_html):
+def check_page(section, url, data, timeout, interval, block_from, block_to,
+ block_skip, format_html):
"""
call check_url if interval is exceed.
"""
- query = session.query(Page).filter_by(url=url)
+ query = session.query(Page).filter_by(section=section)
output = None
if query.all() == []:
content, last_check = check_url(url, data, timeout, block_from,
block_to, block_skip, format_html)
page = Page()
+ page.section = section
page.url = url
page.content = content
page.last_check = last_check
@@ -352,8 +354,8 @@ if __name__ == "__main__":
global_block_skip))
format_html = option_or_default(section, 'format_html_command',
global_format_html)
- page, output = check_page(url=url, data=data, timeout=timeout,
- interval=interval,
+ page, output = check_page(section=section, url=url, data=data,
+ timeout=timeout, interval=interval,
block_from=block_from, block_to=block_to,
block_skip=block_skip,
format_html=format_html)