Skip to content

Commit

Permalink
fix: refresh token on 401 (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
polomarcus authored Mar 1, 2024
1 parent 57be39f commit c4d57b5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions quotaclimat/data_processing/mediatree/api_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def get_post_request(media_tree_token, type_sub, start_epoch, channel, page: int
params = get_param_api(media_tree_token, type_sub, start_epoch, channel, page)
logging.info(f"Query {KEYWORDS_URL} page {page} with params:\n {get_param_api('fake_token_for_log', type_sub, start_epoch, channel, page)}")
response = requests.post(KEYWORDS_URL, json=params)
if response.status_code == 401:
logging.warning("Expired token - retrying to get a new one")
media_tree_token = get_auth_token(password, USER)
raise Exception

return parse_raw_json(response)
except Exception as err:
logging.error("Retry - Could not query API :(%s) %s" % (type(err).__name__, err))
Expand Down

1 comment on commit c4d57b5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
postgres
   insert_data.py46785%38–40, 59–61, 66
   insert_existing_data_example.py20385%25–27
postgres/schemas
   models.py721579%74–81, 91–92, 101–111
quotaclimat/data_analytics
   analytics_signataire_charte.py29290%1–67
   bilan.py1081080%2–372
   data_coverage.py34340%1–94
   exploration.py1251250%1–440
   sitemap_analytics.py1181180%1–343
quotaclimat/data_ingestion
   categorization_program_type.py110%1
   config_youtube.py110%1
   scaleway_db_backups.py34340%1–74
   scrap_chartejournalismeecologie_signataires.py50500%1–169
   scrap_sitemap.py1341787%27–28, 33–34, 66–71, 95–97, 138–140, 202, 223–228
   scrap_tv_program.py62620%1–149
   scrap_youtube.py1141140%1–238
quotaclimat/data_ingestion/ingest_db
   ingest_sitemap_in_db.py594131%21–42, 45–65, 69–80
quotaclimat/data_ingestion/scrap_html
   scrap_description_article.py36392%19–20, 32
quotaclimat/data_processing/mediatree
   api_import.py18410941%38–42, 47–53, 57–60, 66, 69–96, 102–117, 122–124, 149–161, 165–168, 172–178, 189–200, 203–207, 213, 239–240, 244, 248–267, 271–282
   config.py15287%7, 16
   detect_keywords.py113397%129–131
   utils.py662267%19, 30–54, 57, 76–77
quotaclimat/data_processing/sitemap
   sitemap_processing.py412734%15–19, 23–25, 29–47, 51–58, 66–96, 101–103
quotaclimat/utils
   channels.py660%1–95
   climate_keywords.py220%3–35
   healthcheck_config.py291452%22–24, 27–38
   logger.py14379%22–24
   plotly_theme.py17170%1–56
   sentry.py10280%21–22
TOTAL159296939% 

Tests Skipped Failures Errors Time
54 0 💤 0 ❌ 0 🔥 51.645s ⏱️

Please sign in to comment.