From d51de549c46d1d07cd550ee62060286b81a8f60d Mon Sep 17 00:00:00 2001 From: Gerrod Date: Tue, 19 Mar 2024 08:04:53 -0400 Subject: [PATCH] Merge pull request #651 from gerrod3/fake-netrc Remove 'missing netrc' log messages when syncing (cherry picked from commit 9befa2383ff63099f9dcfed3d21f7ce304fceff1) --- pulp_python/app/tasks/sync.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pulp_python/app/tasks/sync.py b/pulp_python/app/tasks/sync.py index c4f93dfa..5238c69e 100644 --- a/pulp_python/app/tasks/sync.py +++ b/pulp_python/app/tasks/sync.py @@ -1,9 +1,10 @@ import logging +import tempfile from aiohttp import ClientResponseError, ClientError from lxml.etree import LxmlError from gettext import gettext as _ -from os import environ, path +from os import environ from rest_framework import serializers @@ -111,9 +112,10 @@ async def run(self): """ If includes is specified, then only sync those,else try to sync all other packages """ - # Prevent bandersnatch from reading actual .netrc file, set to nonexistent file + # Prevent bandersnatch from reading actual .netrc file, set to empty file # See discussion on https://github.com/pulp/pulp_python/issues/581 - environ["NETRC"] = f"{path.curdir}/.fake-netrc" + fake_netrc = tempfile.NamedTemporaryFile(dir=".", delete=False) + environ["NETRC"] = fake_netrc.name # TODO Change Bandersnatch internal API to take proxy settings in from config parameters if proxy_url := self.remote.proxy_url: if self.remote.proxy_username or self.remote.proxy_password: