prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  CONAN_LOGIN_USERNAME and CONAN_PASSWORD are ignored in non-interactive mode
  Conan 1.3.2
  
  To reproduce:
  1. Run `conan user -c`
  2. Set `CONAN_LOGIN_USERNAME`, `CONAN_PASSWORD` and `CONAN_NON_INTERACTIVE` environment variables.
  3. Run `conan upload -r staging` to remove which requires authentication.
  
  **Expected result**: Conan uses credentials stored in environment variables (as was in Conan 1.2)
  **Actual result**: Upload fails with message:
  ```
  Please log in to "staging" to perform this action. Execute "conan user" command.
  ERROR: Conan interactive mode disabled. [Remote: staging]
  ```
  
  My best guess is that in `userio.py`
  ```python
      def request_login(self, remote_name, username=None):
          """Request user to input their name and password
          :param username If username is specified it only request password"""
          self._raise_if_non_interactive()
  ```
  call to `self._raise_if_non_interactive()` is unnecessary as this check performed by functions called from it (Having prompt printed is not that ugly, or move this check closer to `conan user` command).
  
  Option to always require explicit `conan user` is also possible, although feels little bit inconsistent and makes use of credentials variables pointless.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `conans/client/userio.py`
  Content:
  ```
  1 import os
  2 import sys
  3 from conans.client.output import ConanOutput
  4 from conans.model.username import Username
  5 from conans.errors import InvalidNameException, ConanException
  6 import getpass
  7 from six.moves import input as raw_input
  8 
  9 
  10 class UserIO(object):
  11     """Class to interact with the user, used to show messages and ask for information"""
  12 
  13     def __init__(self, ins=sys.stdin, out=None):
  14         """
  15         Params:
  16             ins: input stream
  17             out: ConanOutput, should have "write" method
  18         """
  19         self._ins = ins
  20         if not out:
  21             out = ConanOutput(sys.stdout)
  22         self.out = out
  23         self._interactive = True
  24 
  25     def disable_input(self):
  26         self._interactive = False
  27 
  28     def _raise_if_non_interactive(self):
  29         if not self._interactive:
  30             raise ConanException("Conan interactive mode disabled")
  31 
  32     def raw_input(self):
  33         self._raise_if_non_interactive()
  34         return raw_input()
  35 
  36     def get_pass(self):
  37         self._raise_if_non_interactive()
  38         return getpass.getpass("")
  39 
  40     def request_login(self, remote_name, username=None):
  41         """Request user to input their name and password
  42         :param username If username is specified it only request password"""
  43         self._raise_if_non_interactive()
  44         user_input = ''
  45         while not username:
  46             try:
  47                 self.out.write("Remote '%s' username: " % remote_name)
  48                 user_input = self.get_username(remote_name)
  49                 username = Username(user_input)
  50             except InvalidNameException:
  51                 self.out.error('%s is not a valid username' % user_input)
  52 
  53         self.out.write('Please enter a password for "%s" account: ' % username)
  54         try:
  55             pwd = self.get_password(remote_name)
  56         except ConanException:
  57             raise
  58         except Exception as e:
  59             raise ConanException('Cancelled pass %s' % e)
  60         return username, pwd
  61 
  62     def get_username(self, remote_name):
  63         """Overridable for testing purpose"""
  64         return self._get_env_username(remote_name) or self.raw_input()
  65 
  66     def get_password(self, remote_name):
  67         """Overridable for testing purpose"""
  68         return self._get_env_password(remote_name) or self.get_pass()
  69 
  70     def request_string(self, msg, default_value=None):
  71         """Request user to input a msg
  72         :param msg Name of the msg
  73         """
  74         self._raise_if_non_interactive()
  75 
  76         if default_value:
  77             self.out.input_text('%s (%s): ' % (msg, default_value))
  78         else:
  79             self.out.input_text('%s: ' % msg)
  80         s = self._ins.readline().replace("\n", "")
  81         if default_value is not None and s == '':
  82             return default_value
  83         return s
  84 
  85     def request_boolean(self, msg, default_option=None):
  86         """Request user to input a boolean"""
  87         ret = None
  88         while ret is None:
  89             if default_option is True:
  90                 s = self.request_string("%s (YES/no)" % msg)
  91             elif default_option is False:
  92                 s = self.request_string("%s (NO/yes)" % msg)
  93             else:
  94                 s = self.request_string("%s (yes/no)" % msg)
  95             if default_option is not None and s == '':
  96                 return default_option
  97             if s.lower() in ['yes', 'y']:
  98                 ret = True
  99             elif s.lower() in ['no', 'n']:
  100                 ret = False
  101             else:
  102                 self.out.error("%s is not a valid answer" % s)
  103         return ret
  104 
  105     def _get_env_password(self, remote_name):
  106         """
  107         Try CONAN_PASSWORD_REMOTE_NAME or CONAN_PASSWORD or return None
  108         """
  109         remote_name = remote_name.replace("-", "_").upper()
  110         var_name = "CONAN_PASSWORD_%s" % remote_name
  111         ret = os.getenv(var_name, None) or os.getenv("CONAN_PASSWORD", None)
  112         if ret:
  113             self.out.info("Got password '******' from environment")
  114         return ret
  115 
  116     def _get_env_username(self, remote_name):
  117         """
  118         Try CONAN_LOGIN_USERNAME_REMOTE_NAME or CONAN_LOGIN_USERNAME or return None
  119         """
  120         remote_name = remote_name.replace("-", "_").upper()
  121         var_name = "CONAN_LOGIN_USERNAME_%s" % remote_name
  122         ret = os.getenv(var_name, None) or os.getenv("CONAN_LOGIN_USERNAME", None)
  123 
  124         if ret:
  125             self.out.info("Got username '%s' from environment" % ret)
  126         return ret
  127
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/conans/client/userio.py b/conans/client/userio.py
  --- a/conans/client/userio.py
  +++ b/conans/client/userio.py
  @@ -40,17 +40,17 @@
       def request_login(self, remote_name, username=None):
           """Request user to input their name and password
           :param username If username is specified it only request password"""
  -        self._raise_if_non_interactive()
           user_input = ''
           while not username:
               try:
  -                self.out.write("Remote '%s' username: " % remote_name)
  +                if self._interactive:
  +                    self.out.write("Remote '%s' username: " % remote_name)
                   user_input = self.get_username(remote_name)
                   username = Username(user_input)
               except InvalidNameException:
                   self.out.error('%s is not a valid username' % user_input)
  -
  -        self.out.write('Please enter a password for "%s" account: ' % username)
  +        if self._interactive:
  +            self.out.write('Please enter a password for "%s" account: ' % username)
           try:
               pwd = self.get_password(remote_name)
           except ConanException:
  
verification_info: {"golden_diff": "diff --git a/conans/client/userio.py b/conans/client/userio.py\n--- a/conans/client/userio.py\n+++ b/conans/client/userio.py\n@@ -40,17 +40,17 @@\n     def request_login(self, remote_name, username=None):\n         \"\"\"Request user to input their name and password\n         :param username If username is specified it only request password\"\"\"\n-        self._raise_if_non_interactive()\n         user_input = ''\n         while not username:\n             try:\n-                self.out.write(\"Remote '%s' username: \" % remote_name)\n+                if self._interactive:\n+                    self.out.write(\"Remote '%s' username: \" % remote_name)\n                 user_input = self.get_username(remote_name)\n                 username = Username(user_input)\n             except InvalidNameException:\n                 self.out.error('%s is not a valid username' % user_input)\n-\n-        self.out.write('Please enter a password for \"%s\" account: ' % username)\n+        if self._interactive:\n+            self.out.write('Please enter a password for \"%s\" account: ' % username)\n         try:\n             pwd = self.get_password(remote_name)\n         except ConanException:\n", "issue": "CONAN_LOGIN_USERNAME and CONAN_PASSWORD are ignored in non-interactive mode\nConan 1.3.2\r\n\r\nTo reproduce:\r\n1. Run `conan user -c`\r\n2. Set `CONAN_LOGIN_USERNAME`, `CONAN_PASSWORD` and `CONAN_NON_INTERACTIVE` environment variables.\r\n3. Run `conan upload -r staging` to remove which requires authentication.\r\n\r\n**Expected result**: Conan uses credentials stored in environment variables (as was in Conan 1.2)\r\n**Actual result**: Upload fails with message:\r\n```\r\nPlease log in to \"staging\" to perform this action. Execute \"conan user\" command.\r\nERROR: Conan interactive mode disabled. [Remote: staging]\r\n```\r\n\r\nMy best guess is that in `userio.py`\r\n```python\r\n    def request_login(self, remote_name, username=None):\r\n        \"\"\"Request user to input their name and password\r\n        :param username If username is specified it only request password\"\"\"\r\n        self._raise_if_non_interactive()\r\n```\r\ncall to `self._raise_if_non_interactive()` is unnecessary as this check performed by functions called from it (Having prompt printed is not that ugly, or move this check closer to `conan user` command).\r\n\r\nOption to always require explicit `conan user` is also possible, although feels little bit inconsistent and makes use of credentials variables pointless.\n", "before_files": [{"content": "import os\nimport sys\nfrom conans.client.output import ConanOutput\nfrom conans.model.username import Username\nfrom conans.errors import InvalidNameException, ConanException\nimport getpass\nfrom six.moves import input as raw_input\n\n\nclass UserIO(object):\n    \"\"\"Class to interact with the user, used to show messages and ask for information\"\"\"\n\n    def __init__(self, ins=sys.stdin, out=None):\n        \"\"\"\n        Params:\n            ins: input stream\n            out: ConanOutput, should have \"write\" method\n        \"\"\"\n        self._ins = ins\n        if not out:\n            out = ConanOutput(sys.stdout)\n        self.out = out\n        self._interactive = True\n\n    def disable_input(self):\n        self._interactive = False\n\n    def _raise_if_non_interactive(self):\n        if not self._interactive:\n            raise ConanException(\"Conan interactive mode disabled\")\n\n    def raw_input(self):\n        self._raise_if_non_interactive()\n        return raw_input()\n\n    def get_pass(self):\n        self._raise_if_non_interactive()\n        return getpass.getpass(\"\")\n\n    def request_login(self, remote_name, username=None):\n        \"\"\"Request user to input their name and password\n        :param username If username is specified it only request password\"\"\"\n        self._raise_if_non_interactive()\n        user_input = ''\n        while not username:\n            try:\n                self.out.write(\"Remote '%s' username: \" % remote_name)\n                user_input = self.get_username(remote_name)\n                username = Username(user_input)\n            except InvalidNameException:\n                self.out.error('%s is not a valid username' % user_input)\n\n        self.out.write('Please enter a password for \"%s\" account: ' % username)\n        try:\n            pwd = self.get_password(remote_name)\n        except ConanException:\n            raise\n        except Exception as e:\n            raise ConanException('Cancelled pass %s' % e)\n        return username, pwd\n\n    def get_username(self, remote_name):\n        \"\"\"Overridable for testing purpose\"\"\"\n        return self._get_env_username(remote_name) or self.raw_input()\n\n    def get_password(self, remote_name):\n        \"\"\"Overridable for testing purpose\"\"\"\n        return self._get_env_password(remote_name) or self.get_pass()\n\n    def request_string(self, msg, default_value=None):\n        \"\"\"Request user to input a msg\n        :param msg Name of the msg\n        \"\"\"\n        self._raise_if_non_interactive()\n\n        if default_value:\n            self.out.input_text('%s (%s): ' % (msg, default_value))\n        else:\n            self.out.input_text('%s: ' % msg)\n        s = self._ins.readline().replace(\"\\n\", \"\")\n        if default_value is not None and s == '':\n            return default_value\n        return s\n\n    def request_boolean(self, msg, default_option=None):\n        \"\"\"Request user to input a boolean\"\"\"\n        ret = None\n        while ret is None:\n            if default_option is True:\n                s = self.request_string(\"%s (YES/no)\" % msg)\n            elif default_option is False:\n                s = self.request_string(\"%s (NO/yes)\" % msg)\n            else:\n                s = self.request_string(\"%s (yes/no)\" % msg)\n            if default_option is not None and s == '':\n                return default_option\n            if s.lower() in ['yes', 'y']:\n                ret = True\n            elif s.lower() in ['no', 'n']:\n                ret = False\n            else:\n                self.out.error(\"%s is not a valid answer\" % s)\n        return ret\n\n    def _get_env_password(self, remote_name):\n        \"\"\"\n        Try CONAN_PASSWORD_REMOTE_NAME or CONAN_PASSWORD or return None\n        \"\"\"\n        remote_name = remote_name.replace(\"-\", \"_\").upper()\n        var_name = \"CONAN_PASSWORD_%s\" % remote_name\n        ret = os.getenv(var_name, None) or os.getenv(\"CONAN_PASSWORD\", None)\n        if ret:\n            self.out.info(\"Got password '******' from environment\")\n        return ret\n\n    def _get_env_username(self, remote_name):\n        \"\"\"\n        Try CONAN_LOGIN_USERNAME_REMOTE_NAME or CONAN_LOGIN_USERNAME or return None\n        \"\"\"\n        remote_name = remote_name.replace(\"-\", \"_\").upper()\n        var_name = \"CONAN_LOGIN_USERNAME_%s\" % remote_name\n        ret = os.getenv(var_name, None) or os.getenv(\"CONAN_LOGIN_USERNAME\", None)\n\n        if ret:\n            self.out.info(\"Got username '%s' from environment\" % ret)\n        return ret\n", "path": "conans/client/userio.py"}], "after_files": [{"content": "import os\nimport sys\nfrom conans.client.output import ConanOutput\nfrom conans.model.username import Username\nfrom conans.errors import InvalidNameException, ConanException\nimport getpass\nfrom six.moves import input as raw_input\n\n\nclass UserIO(object):\n    \"\"\"Class to interact with the user, used to show messages and ask for information\"\"\"\n\n    def __init__(self, ins=sys.stdin, out=None):\n        \"\"\"\n        Params:\n            ins: input stream\n            out: ConanOutput, should have \"write\" method\n        \"\"\"\n        self._ins = ins\n        if not out:\n            out = ConanOutput(sys.stdout)\n        self.out = out\n        self._interactive = True\n\n    def disable_input(self):\n        self._interactive = False\n\n    def _raise_if_non_interactive(self):\n        if not self._interactive:\n            raise ConanException(\"Conan interactive mode disabled\")\n\n    def raw_input(self):\n        self._raise_if_non_interactive()\n        return raw_input()\n\n    def get_pass(self):\n        self._raise_if_non_interactive()\n        return getpass.getpass(\"\")\n\n    def request_login(self, remote_name, username=None):\n        \"\"\"Request user to input their name and password\n        :param username If username is specified it only request password\"\"\"\n        user_input = ''\n        while not username:\n            try:\n                if self._interactive:\n                    self.out.write(\"Remote '%s' username: \" % remote_name)\n                user_input = self.get_username(remote_name)\n                username = Username(user_input)\n            except InvalidNameException:\n                self.out.error('%s is not a valid username' % user_input)\n        if self._interactive:\n            self.out.write('Please enter a password for \"%s\" account: ' % username)\n        try:\n            pwd = self.get_password(remote_name)\n        except ConanException:\n            raise\n        except Exception as e:\n            raise ConanException('Cancelled pass %s' % e)\n        return username, pwd\n\n    def get_username(self, remote_name):\n        \"\"\"Overridable for testing purpose\"\"\"\n        return self._get_env_username(remote_name) or self.raw_input()\n\n    def get_password(self, remote_name):\n        \"\"\"Overridable for testing purpose\"\"\"\n        return self._get_env_password(remote_name) or self.get_pass()\n\n    def request_string(self, msg, default_value=None):\n        \"\"\"Request user to input a msg\n        :param msg Name of the msg\n        \"\"\"\n        self._raise_if_non_interactive()\n\n        if default_value:\n            self.out.input_text('%s (%s): ' % (msg, default_value))\n        else:\n            self.out.input_text('%s: ' % msg)\n        s = self._ins.readline().replace(\"\\n\", \"\")\n        if default_value is not None and s == '':\n            return default_value\n        return s\n\n    def request_boolean(self, msg, default_option=None):\n        \"\"\"Request user to input a boolean\"\"\"\n        ret = None\n        while ret is None:\n            if default_option is True:\n                s = self.request_string(\"%s (YES/no)\" % msg)\n            elif default_option is False:\n                s = self.request_string(\"%s (NO/yes)\" % msg)\n            else:\n                s = self.request_string(\"%s (yes/no)\" % msg)\n            if default_option is not None and s == '':\n                return default_option\n            if s.lower() in ['yes', 'y']:\n                ret = True\n            elif s.lower() in ['no', 'n']:\n                ret = False\n            else:\n                self.out.error(\"%s is not a valid answer\" % s)\n        return ret\n\n    def _get_env_password(self, remote_name):\n        \"\"\"\n        Try CONAN_PASSWORD_REMOTE_NAME or CONAN_PASSWORD or return None\n        \"\"\"\n        remote_name = remote_name.replace(\"-\", \"_\").upper()\n        var_name = \"CONAN_PASSWORD_%s\" % remote_name\n        ret = os.getenv(var_name, None) or os.getenv(\"CONAN_PASSWORD\", None)\n        if ret:\n            self.out.info(\"Got password '******' from environment\")\n        return ret\n\n    def _get_env_username(self, remote_name):\n        \"\"\"\n        Try CONAN_LOGIN_USERNAME_REMOTE_NAME or CONAN_LOGIN_USERNAME or return None\n        \"\"\"\n        remote_name = remote_name.replace(\"-\", \"_\").upper()\n        var_name = \"CONAN_LOGIN_USERNAME_%s\" % remote_name\n        ret = os.getenv(var_name, None) or os.getenv(\"CONAN_LOGIN_USERNAME\", None)\n\n        if ret:\n            self.out.info(\"Got username '%s' from environment\" % ret)\n        return ret\n", "path": "conans/client/userio.py"}]}