Gistrec

Untitled

Nov 25th, 2022
109
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. --- quality/functionality/facts/tools/screenshots/extract_fact_data/__main__.py (index)
  2. +++ quality/functionality/facts/tools/screenshots/extract_fact_data/__main__.py (working tree)
  3. @@ -100,9 +100,12 @@ class DataParser:
  4.          return None
  5.  
  6.      def __call__(self, row):
  7. -        with urllib.request.urlopen(row[self.url_column]) as response:
  8. -            html = response.read().decode(response.headers.get_content_charset()).replace("\\n", "")
  9. -        blender_response = self.read_blender_response(html)
  10. +        try:
  11. +            with urllib.request.urlopen(row[self.url_column]) as response:
  12. +                html = response.read().decode(response.headers.get_content_charset()).replace("\\n", "")
  13. +            blender_response = self.read_blender_response(html)
  14. +        except (urllib.error.HTTPError, TimeoutError, urllib.error.URLError)  as e:
  15. +            blender_response = None
  16.  
  17.          if blender_response is None:
  18.              yield yt.create_table_switch(1)
  19. @@ -112,6 +115,7 @@ class DataParser:
  20.          data = self.transform_response_data(blender_response)
  21.          fact = fact_parser_lib.parse_fact(data, ignore_highlight=True)
  22.          fact[self.url_column] = row[self.url_column]
  23. +        fact["max_answer_mx"] = blender_response.get("data.wizplaces.important.[0].construct.[0]", {}).get("fact_snip_additional_data", {}).get("max_answer_mx", -100.0)
  24.  
  25.          yield yt.create_table_switch(0)
  26.          yield fact
  27. @@ -125,7 +129,8 @@ def main():
  28.          [
  29.              args.output,
  30.              args.errors
  31. -        ]
  32. +        ],
  33. +        job_count = 100
  34.      )
Comments
  • User was banned
Add Comment
Please, Sign In to add comment