Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add Troubleshooting links and blurb to various appropriate places in Spyder and doc #6137

Merged
merged 5 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spyder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
__license__ = __doc__
__project_url__ = 'https://github.com/spyder-ide/spyder'
__forum_url__ = 'http://groups.google.com/group/spyderlib'
__trouble_url__ = __project_url__ + '/wiki/Troubleshooting-Guide-and-FAQ'

# Dear (Debian, RPM, ...) package makers, please feel free to customize the
# following path to module's data (images) and translations:
Expand Down
33 changes: 23 additions & 10 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
#==============================================================================
# Local utility imports
#==============================================================================
from spyder import __version__, __project_url__, __forum_url__, get_versions
from spyder import (__version__, __project_url__, __forum_url__,
__trouble_url__, get_versions)
from spyder.config.base import (get_conf_path, get_module_data_path,
get_module_source_path, STDERR, DEBUG,
debug_print, MAC_APP_NAME, get_home_dir,
Expand Down Expand Up @@ -936,6 +937,9 @@ def create_edit_action(text, tr_text, icon):
self.set_splash(_("Setting up main window..."))

# Help menu
trouble_action = create_action(self,
_("Troubleshooting..."),
triggered=self.trouble_guide)
dep_action = create_action(self, _("Dependencies..."),
triggered=self.show_dependencies,
icon=ima.icon('advanced'))
Expand Down Expand Up @@ -1010,7 +1014,8 @@ def trigger(i=i, self=self): # closure needed!

self.help_menu_actions = [doc_action, tut_action, shortcuts_action,
self.tours_menu,
MENU_SEPARATOR, report_action, dep_action,
MENU_SEPARATOR, trouble_action,
report_action, dep_action,
self.check_updates_action, support_action,
MENU_SEPARATOR]
# Python documentation
Expand Down Expand Up @@ -2349,9 +2354,10 @@ def about(self):
<br>Developed and maintained by the
<a href="%s/blob/master/AUTHORS">Spyder Project Contributors</a>.
<br>Many thanks to all the Spyder beta testers and regular users.
<p>For bug reports and feature requests, please go
to our <a href="%s">Github website</a>. For discussions around the
project, please go to our <a href="%s">Google Group</a>
<p>For help with Spyder errors and crashes, please read our
<a href="%s">Troubleshooting page</a>, and for bug reports and
feature requests, visit our <a href="%s">Github website</a>.
For project discussion, see our <a href="%s">Google Group</a>.
<p>This project is part of a larger effort to promote and
facilitate the use of Python for scientific and engineering
software development. The popular Python distributions
Expand All @@ -2367,7 +2373,7 @@ def about(self):
<a href="http://www.oxygen-icons.org/">
The Oxygen icon theme</a></small>.
"""
% (versions['spyder'], revlink, __project_url__,
% (versions['spyder'], revlink, __project_url__, __trouble_url__,
__project_url__, __forum_url__, versions['python'],
versions['bitness'], versions['qt'], versions['qt_api'],
versions['qt_api_ver'], versions['system']))
Expand Down Expand Up @@ -2457,6 +2463,9 @@ def report_issue(self, body=None, title=None):
if title:
url.addEncodedQueryItem("title", quote(title))

@Slot()
def trouble_guide(self):
url = QUrl(__trouble_url__)
QDesktopServices.openUrl(url)

@Slot()
Expand Down Expand Up @@ -3123,7 +3132,8 @@ def main():
CONF.set('main', 'crash', False)
if SPLASH is not None:
SPLASH.hide()
QMessageBox.information(None, "Spyder",
QMessageBox.information(
None, "Spyder",
"Spyder crashed during last session.<br><br>"
"If Spyder does not start at all and <u>before submitting a "
"bug report</u>, please try to reset settings to defaults by "
Expand All @@ -3133,12 +3143,15 @@ def main():
"<span style=\'color: #ff5555\'><b>Warning:</b></span> "
"this command will remove all your Spyder configuration files "
"located in '%s').<br><br>"
"If restoring the default settings does not help, please take "
"If Spyder still fails to launch, you should consult our "
"comprehensive <b><a href=\"%s\">Troubleshooting Guide</a></b>, "
"which when followed carefully solves the vast majority of "
"crashes; also, take "
"the time to search for <a href=\"%s\">known bugs</a> or "
"<a href=\"%s\">discussions</a> matching your situation before "
"eventually creating a new issue <a href=\"%s\">here</a>. "
"submitting a report to our <a href=\"%s\">issue tracker</a>. "
"Your feedback will always be greatly appreciated."
"" % (get_conf_path(), __project_url__,
"" % (get_conf_path(), __trouble_url__, __project_url__,
__forum_url__, __project_url__))

# Create main window
Expand Down
43 changes: 42 additions & 1 deletion spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from sys import version_info
import shutil
import tempfile
try:
from unittest.mock import Mock, MagicMock
except ImportError:
from mock import Mock, MagicMock # Python 2

from flaky import flaky
from jupyter_client.manager import KernelManager
Expand All @@ -24,15 +28,24 @@
from qtpy.QtTest import QTest
from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit

from spyder import __trouble_url__
from spyder.app.cli_options import get_options
from spyder.app.mainwindow import initialize, run_spyder
from spyder.app.mainwindow import initialize, run_spyder, MainWindow
from spyder.config.base import get_home_dir
from spyder.config.main import CONF
from spyder.plugins.runconfig import RunConfiguration
from spyder.py3compat import PY2, to_text_string
from spyder.utils.ipython.kernelspec import SpyderKernelSpec
from spyder.utils.programs import is_module_installed

# For testing various Spyder urls
if not PY2:
from urllib.request import urlopen
from urllib.error import URLError
else:
from urllib2 import urlopen, URLError


#==============================================================================
# Constants
#==============================================================================
Expand Down Expand Up @@ -1142,5 +1155,33 @@ def test_run_static_code_analysis(main_window, qtbot):
main_window.editor.close_file()


@flaky(max_runs=3)
def test_troubleshooting_menu_item_and_url(monkeypatch):
"""Test that the troubleshooting menu item calls the valid URL."""
MockMainWindow = MagicMock(spec=MainWindow)
mockMainWindow_instance = MockMainWindow()
mockMainWindow_instance.__class__ = MainWindow
MockQDesktopServices = Mock()
mockQDesktopServices_instance = MockQDesktopServices()
attr_to_patch = ('spyder.app.mainwindow.QDesktopServices')
monkeypatch.setattr(attr_to_patch, MockQDesktopServices)

# Unit test of help menu item: Make sure the correct URL is called.
MainWindow.trouble_guide(mockMainWindow_instance)
assert MockQDesktopServices.openUrl.call_count == 1
mockQDesktopServices_instance.openUrl.called_once_with(__trouble_url__)

# Check that the URL resolves correctly. Ignored if no internet connection.
try:
urlopen("https://www.github.com", timeout=1)
except Exception:
pass
else:
try:
urlopen(__trouble_url__, timeout=1)
except URLError:
raise


if __name__ == "__main__":
pytest.main()