prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Check for new conda packages in Anaconda's repos instead of Github
  Right now we're looking for new releases only on Github. But this gives a bad UX in Anaconda because they take several days to create new conda packages for Spyder.
  
  So in that case we need to look for new packages (for example) in
  
  https://repo.continuum.io/pkgs/main/win-64/
  
  to only show the update message when new packages are placed there.
  
  @dalthviz, please work on this one.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `spyder/workers/updates.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright © Spyder Project Contributors
  4 # Licensed under the terms of the MIT License
  5 # (see spyder/__init__.py for details)
  6 
  7 # Standard library imports
  8 import json
  9 import ssl
  10 
  11 # Third party imports
  12 from qtpy.QtCore import QObject, Signal
  13 
  14 # Local imports
  15 from spyder import __version__
  16 from spyder.config.base import _
  17 from spyder.py3compat import PY3
  18 from spyder.utils.programs import check_version, is_stable_version
  19 
  20 
  21 if PY3:
  22     from urllib.request import urlopen
  23     from urllib.error import URLError, HTTPError
  24 else:
  25     from urllib2 import urlopen, URLError, HTTPError
  26 
  27 
  28 class WorkerUpdates(QObject):
  29     """
  30     Worker that checks for releases using the Github API without blocking the
  31     Spyder user interface, in case of connections issues.
  32     """
  33     sig_ready = Signal()
  34 
  35     def __init__(self, parent, startup):
  36         QObject.__init__(self)
  37         self._parent = parent
  38         self.error = None
  39         self.latest_release = None
  40         self.startup = startup
  41 
  42     def check_update_available(self, version, releases):
  43         """Checks if there is an update available.
  44 
  45         It takes as parameters the current version of Spyder and a list of
  46         valid cleaned releases in chronological order (what github api returns
  47         by default). Example: ['2.3.4', '2.3.3' ...]
  48         """
  49         if is_stable_version(version):
  50             # Remove non stable versions from the list
  51             releases = [r for r in releases if is_stable_version(r)]
  52 
  53         latest_release = releases[0]
  54 
  55         if version.endswith('dev'):
  56             return (False, latest_release)
  57 
  58         return (check_version(version, latest_release, '<'), latest_release)
  59 
  60     def start(self):
  61         """Main method of the WorkerUpdates worker"""
  62         self.url = 'https://api.github.com/repos/spyder-ide/spyder/releases'
  63         self.update_available = False
  64         self.latest_release = __version__
  65 
  66         error_msg = None
  67 
  68         try:
  69             if hasattr(ssl, '_create_unverified_context'):
  70                 # Fix for issue # 2685 [Works only with Python >=2.7.9]
  71                 # More info: https://www.python.org/dev/peps/pep-0476/#opting-out
  72                 context = ssl._create_unverified_context()
  73                 page = urlopen(self.url, context=context)
  74             else:
  75                 page = urlopen(self.url)
  76             try:
  77                 data = page.read()
  78 
  79                 # Needed step for python3 compatibility
  80                 if not isinstance(data, str):
  81                     data = data.decode()
  82 
  83                 data = json.loads(data)
  84                 releases = [item['tag_name'].replace('v', '') for item in data]
  85                 version = __version__
  86 
  87                 result = self.check_update_available(version, releases)
  88                 self.update_available, self.latest_release = result
  89             except Exception:
  90                 error_msg = _('Unable to retrieve information.')
  91         except HTTPError:
  92             error_msg = _('Unable to retrieve information.')
  93         except URLError:
  94             error_msg = _('Unable to connect to the internet. <br><br>Make '
  95                           'sure the connection is working properly.')
  96         except Exception:
  97             error_msg = _('Unable to check for updates.')
  98 
  99         # Don't show dialog when starting up spyder and an error occur
  100         if not (self.startup and error_msg is not None):
  101             self.error = error_msg
  102             self.sig_ready.emit()
  103
  ```
  --- 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/spyder/workers/updates.py b/spyder/workers/updates.py
  --- a/spyder/workers/updates.py
  +++ b/spyder/workers/updates.py
  @@ -6,7 +6,9 @@
   
   # Standard library imports
   import json
  +import os
   import ssl
  +import sys
   
   # Third party imports
   from qtpy.QtCore import QObject, Signal
  @@ -15,6 +17,7 @@
   from spyder import __version__
   from spyder.config.base import _
   from spyder.py3compat import PY3
  +from spyder.config.utils import is_anaconda
   from spyder.utils.programs import check_version, is_stable_version
   
   
  @@ -27,30 +30,36 @@
   
   class WorkerUpdates(QObject):
       """
  -    Worker that checks for releases using the Github API without blocking the
  -    Spyder user interface, in case of connections issues.
  +    Worker that checks for releases using either the Anaconda
  +    default channels or the Github Releases page without
  +    blocking the Spyder user interface, in case of connection
  +    issues.
       """
       sig_ready = Signal()
   
  -    def __init__(self, parent, startup):
  +    def __init__(self, parent, startup, version=""):
           QObject.__init__(self)
           self._parent = parent
           self.error = None
           self.latest_release = None
           self.startup = startup
  +        self.version = version
   
  -    def check_update_available(self, version, releases):
  +    def check_update_available(self, version, releases, github=False):
           """Checks if there is an update available.
   
           It takes as parameters the current version of Spyder and a list of
  -        valid cleaned releases in chronological order (what github api returns
  -        by default). Example: ['2.3.4', '2.3.3' ...]
  +        valid cleaned releases in chronological order.
  +        Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...]
           """
           if is_stable_version(version):
               # Remove non stable versions from the list
               releases = [r for r in releases if is_stable_version(r)]
   
  -        latest_release = releases[0]
  +        if github:
  +            latest_release = releases[0]
  +        else:
  +            latest_release = releases[-1]
   
           if version.endswith('dev'):
               return (False, latest_release)
  @@ -59,7 +68,17 @@
   
       def start(self):
           """Main method of the WorkerUpdates worker"""
  -        self.url = 'https://api.github.com/repos/spyder-ide/spyder/releases'
  +        if is_anaconda():
  +            self.url = 'https://repo.anaconda.com/pkgs/main'
  +            if os.name == 'nt':
  +                self.url += '/win-64/repodata.json'
  +            elif sys.platform == 'darwin':
  +                self.url += '/osx-64/repodata.json'
  +            else:
  +                self.url += '/linux-64/repodata.json'
  +        else:
  +            self.url = ('https://api.github.com/repos/'
  +                        'spyder-ide/spyder/releases')
           self.update_available = False
           self.latest_release = __version__
   
  @@ -81,10 +100,22 @@
                       data = data.decode()
   
                   data = json.loads(data)
  -                releases = [item['tag_name'].replace('v', '') for item in data]
  -                version = __version__
  -
  -                result = self.check_update_available(version, releases)
  +                if not self.version:
  +                    self.version = __version__
  +
  +                if is_anaconda():
  +                    releases = []
  +                    for item in data['packages']:
  +                        if 'spyder' in item and 'spyder-kernels' not in item:
  +                            releases.append(item.split('-')[1])
  +                    result = self.check_update_available(self.version,
  +                                                         releases)
  +                else:
  +                    releases = [item['tag_name'].replace('v', '')
  +                                for item in data]
  +                    result = self.check_update_available(self.version,
  +                                                         releases,
  +                                                         github=True)
                   self.update_available, self.latest_release = result
               except Exception:
                   error_msg = _('Unable to retrieve information.')
  
verification_info: {"golden_diff": "diff --git a/spyder/workers/updates.py b/spyder/workers/updates.py\n--- a/spyder/workers/updates.py\n+++ b/spyder/workers/updates.py\n@@ -6,7 +6,9 @@\n \n # Standard library imports\n import json\n+import os\n import ssl\n+import sys\n \n # Third party imports\n from qtpy.QtCore import QObject, Signal\n@@ -15,6 +17,7 @@\n from spyder import __version__\n from spyder.config.base import _\n from spyder.py3compat import PY3\n+from spyder.config.utils import is_anaconda\n from spyder.utils.programs import check_version, is_stable_version\n \n \n@@ -27,30 +30,36 @@\n \n class WorkerUpdates(QObject):\n     \"\"\"\n-    Worker that checks for releases using the Github API without blocking the\n-    Spyder user interface, in case of connections issues.\n+    Worker that checks for releases using either the Anaconda\n+    default channels or the Github Releases page without\n+    blocking the Spyder user interface, in case of connection\n+    issues.\n     \"\"\"\n     sig_ready = Signal()\n \n-    def __init__(self, parent, startup):\n+    def __init__(self, parent, startup, version=\"\"):\n         QObject.__init__(self)\n         self._parent = parent\n         self.error = None\n         self.latest_release = None\n         self.startup = startup\n+        self.version = version\n \n-    def check_update_available(self, version, releases):\n+    def check_update_available(self, version, releases, github=False):\n         \"\"\"Checks if there is an update available.\n \n         It takes as parameters the current version of Spyder and a list of\n-        valid cleaned releases in chronological order (what github api returns\n-        by default). Example: ['2.3.4', '2.3.3' ...]\n+        valid cleaned releases in chronological order.\n+        Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...]\n         \"\"\"\n         if is_stable_version(version):\n             # Remove non stable versions from the list\n             releases = [r for r in releases if is_stable_version(r)]\n \n-        latest_release = releases[0]\n+        if github:\n+            latest_release = releases[0]\n+        else:\n+            latest_release = releases[-1]\n \n         if version.endswith('dev'):\n             return (False, latest_release)\n@@ -59,7 +68,17 @@\n \n     def start(self):\n         \"\"\"Main method of the WorkerUpdates worker\"\"\"\n-        self.url = 'https://api.github.com/repos/spyder-ide/spyder/releases'\n+        if is_anaconda():\n+            self.url = 'https://repo.anaconda.com/pkgs/main'\n+            if os.name == 'nt':\n+                self.url += '/win-64/repodata.json'\n+            elif sys.platform == 'darwin':\n+                self.url += '/osx-64/repodata.json'\n+            else:\n+                self.url += '/linux-64/repodata.json'\n+        else:\n+            self.url = ('https://api.github.com/repos/'\n+                        'spyder-ide/spyder/releases')\n         self.update_available = False\n         self.latest_release = __version__\n \n@@ -81,10 +100,22 @@\n                     data = data.decode()\n \n                 data = json.loads(data)\n-                releases = [item['tag_name'].replace('v', '') for item in data]\n-                version = __version__\n-\n-                result = self.check_update_available(version, releases)\n+                if not self.version:\n+                    self.version = __version__\n+\n+                if is_anaconda():\n+                    releases = []\n+                    for item in data['packages']:\n+                        if 'spyder' in item and 'spyder-kernels' not in item:\n+                            releases.append(item.split('-')[1])\n+                    result = self.check_update_available(self.version,\n+                                                         releases)\n+                else:\n+                    releases = [item['tag_name'].replace('v', '')\n+                                for item in data]\n+                    result = self.check_update_available(self.version,\n+                                                         releases,\n+                                                         github=True)\n                 self.update_available, self.latest_release = result\n             except Exception:\n                 error_msg = _('Unable to retrieve information.')\n", "issue": "Check for new conda packages in Anaconda's repos instead of Github\nRight now we're looking for new releases only on Github. But this gives a bad UX in Anaconda because they take several days to create new conda packages for Spyder.\r\n\r\nSo in that case we need to look for new packages (for example) in\r\n\r\nhttps://repo.continuum.io/pkgs/main/win-64/\r\n\r\nto only show the update message when new packages are placed there.\r\n\r\n@dalthviz, please work on this one.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright \u00a9 Spyder Project Contributors\n# Licensed under the terms of the MIT License\n# (see spyder/__init__.py for details)\n\n# Standard library imports\nimport json\nimport ssl\n\n# Third party imports\nfrom qtpy.QtCore import QObject, Signal\n\n# Local imports\nfrom spyder import __version__\nfrom spyder.config.base import _\nfrom spyder.py3compat import PY3\nfrom spyder.utils.programs import check_version, is_stable_version\n\n\nif PY3:\n    from urllib.request import urlopen\n    from urllib.error import URLError, HTTPError\nelse:\n    from urllib2 import urlopen, URLError, HTTPError\n\n\nclass WorkerUpdates(QObject):\n    \"\"\"\n    Worker that checks for releases using the Github API without blocking the\n    Spyder user interface, in case of connections issues.\n    \"\"\"\n    sig_ready = Signal()\n\n    def __init__(self, parent, startup):\n        QObject.__init__(self)\n        self._parent = parent\n        self.error = None\n        self.latest_release = None\n        self.startup = startup\n\n    def check_update_available(self, version, releases):\n        \"\"\"Checks if there is an update available.\n\n        It takes as parameters the current version of Spyder and a list of\n        valid cleaned releases in chronological order (what github api returns\n        by default). Example: ['2.3.4', '2.3.3' ...]\n        \"\"\"\n        if is_stable_version(version):\n            # Remove non stable versions from the list\n            releases = [r for r in releases if is_stable_version(r)]\n\n        latest_release = releases[0]\n\n        if version.endswith('dev'):\n            return (False, latest_release)\n\n        return (check_version(version, latest_release, '<'), latest_release)\n\n    def start(self):\n        \"\"\"Main method of the WorkerUpdates worker\"\"\"\n        self.url = 'https://api.github.com/repos/spyder-ide/spyder/releases'\n        self.update_available = False\n        self.latest_release = __version__\n\n        error_msg = None\n\n        try:\n            if hasattr(ssl, '_create_unverified_context'):\n                # Fix for issue # 2685 [Works only with Python >=2.7.9]\n                # More info: https://www.python.org/dev/peps/pep-0476/#opting-out\n                context = ssl._create_unverified_context()\n                page = urlopen(self.url, context=context)\n            else:\n                page = urlopen(self.url)\n            try:\n                data = page.read()\n\n                # Needed step for python3 compatibility\n                if not isinstance(data, str):\n                    data = data.decode()\n\n                data = json.loads(data)\n                releases = [item['tag_name'].replace('v', '') for item in data]\n                version = __version__\n\n                result = self.check_update_available(version, releases)\n                self.update_available, self.latest_release = result\n            except Exception:\n                error_msg = _('Unable to retrieve information.')\n        except HTTPError:\n            error_msg = _('Unable to retrieve information.')\n        except URLError:\n            error_msg = _('Unable to connect to the internet. <br><br>Make '\n                          'sure the connection is working properly.')\n        except Exception:\n            error_msg = _('Unable to check for updates.')\n\n        # Don't show dialog when starting up spyder and an error occur\n        if not (self.startup and error_msg is not None):\n            self.error = error_msg\n            self.sig_ready.emit()\n", "path": "spyder/workers/updates.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright \u00a9 Spyder Project Contributors\n# Licensed under the terms of the MIT License\n# (see spyder/__init__.py for details)\n\n# Standard library imports\nimport json\nimport os\nimport ssl\nimport sys\n\n# Third party imports\nfrom qtpy.QtCore import QObject, Signal\n\n# Local imports\nfrom spyder import __version__\nfrom spyder.config.base import _\nfrom spyder.py3compat import PY3\nfrom spyder.config.utils import is_anaconda\nfrom spyder.utils.programs import check_version, is_stable_version\n\n\nif PY3:\n    from urllib.request import urlopen\n    from urllib.error import URLError, HTTPError\nelse:\n    from urllib2 import urlopen, URLError, HTTPError\n\n\nclass WorkerUpdates(QObject):\n    \"\"\"\n    Worker that checks for releases using either the Anaconda\n    default channels or the Github Releases page without\n    blocking the Spyder user interface, in case of connection\n    issues.\n    \"\"\"\n    sig_ready = Signal()\n\n    def __init__(self, parent, startup, version=\"\"):\n        QObject.__init__(self)\n        self._parent = parent\n        self.error = None\n        self.latest_release = None\n        self.startup = startup\n        self.version = version\n\n    def check_update_available(self, version, releases, github=False):\n        \"\"\"Checks if there is an update available.\n\n        It takes as parameters the current version of Spyder and a list of\n        valid cleaned releases in chronological order.\n        Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...]\n        \"\"\"\n        if is_stable_version(version):\n            # Remove non stable versions from the list\n            releases = [r for r in releases if is_stable_version(r)]\n\n        if github:\n            latest_release = releases[0]\n        else:\n            latest_release = releases[-1]\n\n        if version.endswith('dev'):\n            return (False, latest_release)\n\n        return (check_version(version, latest_release, '<'), latest_release)\n\n    def start(self):\n        \"\"\"Main method of the WorkerUpdates worker\"\"\"\n        if is_anaconda():\n            self.url = 'https://repo.anaconda.com/pkgs/main'\n            if os.name == 'nt':\n                self.url += '/win-64/repodata.json'\n            elif sys.platform == 'darwin':\n                self.url += '/osx-64/repodata.json'\n            else:\n                self.url += '/linux-64/repodata.json'\n        else:\n            self.url = ('https://api.github.com/repos/'\n                        'spyder-ide/spyder/releases')\n        self.update_available = False\n        self.latest_release = __version__\n\n        error_msg = None\n\n        try:\n            if hasattr(ssl, '_create_unverified_context'):\n                # Fix for issue # 2685 [Works only with Python >=2.7.9]\n                # More info: https://www.python.org/dev/peps/pep-0476/#opting-out\n                context = ssl._create_unverified_context()\n                page = urlopen(self.url, context=context)\n            else:\n                page = urlopen(self.url)\n            try:\n                data = page.read()\n\n                # Needed step for python3 compatibility\n                if not isinstance(data, str):\n                    data = data.decode()\n\n                data = json.loads(data)\n                if not self.version:\n                    self.version = __version__\n\n                if is_anaconda():\n                    releases = []\n                    for item in data['packages']:\n                        if 'spyder' in item and 'spyder-kernels' not in item:\n                            releases.append(item.split('-')[1])\n                    result = self.check_update_available(self.version,\n                                                         releases)\n                else:\n                    releases = [item['tag_name'].replace('v', '')\n                                for item in data]\n                    result = self.check_update_available(self.version,\n                                                         releases,\n                                                         github=True)\n                self.update_available, self.latest_release = result\n            except Exception:\n                error_msg = _('Unable to retrieve information.')\n        except HTTPError:\n            error_msg = _('Unable to retrieve information.')\n        except URLError:\n            error_msg = _('Unable to connect to the internet. <br><br>Make '\n                          'sure the connection is working properly.')\n        except Exception:\n            error_msg = _('Unable to check for updates.')\n\n        # Don't show dialog when starting up spyder and an error occur\n        if not (self.startup and error_msg is not None):\n            self.error = error_msg\n            self.sig_ready.emit()\n", "path": "spyder/workers/updates.py"}]}