Changeset 2929 in products
- Timestamp:
- Oct 26, 2010 2:55:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/keywords.py
r2927 r2929 38 38 if isExternal: 39 39 # Not pass timeout option because: 40 # 1. its value get from the global default timeout settings by default.40 # 1. its value get from the global default timeout settings. 41 41 # 2. timeout option added in python 2.6 (so acceptable only in plone4+) 42 42 try: … … 45 45 html = resp.read() 46 46 finally: 47 'resp' in locals().keys() and resp.close() 47 if 'resp' in locals().keys(): 48 resp.close() 48 49 except (urllib2.URLError, urllib2.HTTPError), e: 49 50 # In case of exceed timeout period or other URL connection errors. … … 58 59 # If no html - information about problem with page retrieval should be returned 59 60 result = [] 60 if html is not None: 61 if html is None: 62 sfx = error_url and ", details at %s." % error_url or "." 63 result.append("Problem with page retrieval" + sfx) 64 else: 61 65 page_text = transforms.convert("html_to_text", html).getData() 62 66 # check every keyword on appearing in body of html page … … 64 68 keyword_on_page = unicode(len(re.findall(u'\\b%s\\b' % keyword, page_text, re.I|re.U))) 65 69 result.append(' - '.join((keyword, keyword_on_page))) 66 else:67 sfx = error_url and ", details at %s." % error_url or "."68 result.append("Problem with page retrieval" + sfx)69 70 70 71 return ts.utranslate(domain='quintagroup.seoptimizer',
Note: See TracChangeset
for help on using the changeset viewer.