Repository: bokeh/bokeh

Issue:
simplify bokeh/__init__.py even more

Discussion:

Patch:
diff --git a/bokeh/__init__.py b/bokeh/__init__.py
index d561ab1c0..51c521ab5 100644
--- a/bokeh/__init__.py
+++ b/bokeh/__init__.py
@@ -10,7 +10,7 @@ and data applications.
 For full documentation, please visit: http://bokeh.pydata.org
 
 """
-from __future__ import absolute_import, print_function
+from __future__ import absolute_import
 
 # configure Bokeh version
 from .util.version import __version__; __version__
@@ -23,7 +23,4 @@ del logconfig
 # module as transitive imports
 
 from . import sampledata; sampledata
-from .settings import settings; settings
-from .util.testing import print_versions; print_versions
-from .util.testing import report_issue; report_issue
 from .util.testing import runtests as test; test
diff --git a/bokeh/browserlib.py b/bokeh/browserlib.py
index a97bbdf17..64ffa4f56 100644
--- a/bokeh/browserlib.py
+++ b/bokeh/browserlib.py
@@ -3,7 +3,7 @@ from __future__ import absolute_import
 from os.path import abspath
 import webbrowser
 
-from . import settings
+from .settings import settings
 
 def get_browser_controller(browser=None):
     browser = settings.browser(browser)
diff --git a/bokeh/resources.py b/bokeh/resources.py
index e78522e5d..53e2e58ae 100644
--- a/bokeh/resources.py
+++ b/bokeh/resources.py
@@ -19,7 +19,8 @@ logger = logging.getLogger(__name__)
 
 import six
 
-from . import __version__, settings
+from . import __version__
+from .settings import settings
 
 def _server_static_dir():
     return join(abspath(split(__file__)[0]), "server", "static")
diff --git a/sphinx/source/conf.py b/sphinx/source/conf.py
index d0ebd93f9..928bf0780 100644
--- a/sphinx/source/conf.py
+++ b/sphinx/source/conf.py
@@ -59,23 +59,14 @@ master_doc = 'index'
 project = u'Bokeh'
 copyright = u'2013, Continuum Analytics'
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# Let's try to automatically get the version
-from bokeh._version import get_versions
-from bokeh import settings
-
-try:
-    from bokeh.__conda_version__ import conda_version
-    __version__ = conda_version.replace("'","")
-    del conda_version
-except ImportError:
-    __version__ = get_versions()['version']
-    del get_versions
-
-# if you need to redeploy the released docs, you only need the x.x.x version
+# Get the standard computed Bokeh version string to use for |version|
+# and |release|
+from bokeh import __version__
+
+# Check for version override (e.g. when re-deploying a previously released
+# docs, or when pushing test docs that do not have a corresponding BokehJS
+# available on CDN)
+from bokeh.settings import settings
 if settings.released_docs():
     __version__ = __version__.split('-')[0]
 
diff --git a/sphinx/source/docs/reference/plot_objects.rst b/sphinx/source/docs/reference/plot_objects.rst
index 9cfcd71f6..84f3dddf6 100644
--- a/sphinx/source/docs/reference/plot_objects.rst
+++ b/sphinx/source/docs/reference/plot_objects.rst
@@ -14,8 +14,6 @@ Plot Objects
 The ``bokeh`` module itself contains a few useful functions for testing
 and reporting issues:
 
-.. autofunction:: bokeh.print_versions
-.. autofunction:: bokeh.report_issue
 .. autofunction:: bokeh.test
 
 .. _bokeh.document:
diff --git a/sphinx/source/docs/user_guide.rst b/sphinx/source/docs/user_guide.rst
index f951011e7..173c6630a 100644
--- a/sphinx/source/docs/user_guide.rst
+++ b/sphinx/source/docs/user_guide.rst
@@ -20,5 +20,4 @@ the kinds of low-level object attributes that can be set to really customize a p
    user_guide/widgets.rst
    user_guide/ar.rst
    user_guide/examples.rst
-   user_guide/issues.rst
 
diff --git a/sphinx/source/docs/user_guide/issues.rst b/sphinx/source/docs/user_guide/issues.rst
deleted file mode 100644
index 40c49ab9b..000000000
--- a/sphinx/source/docs/user_guide/issues.rst
+++ /dev/null
@@ -1,55 +0,0 @@
-.. _userguide_issues:
-
-Reporting Issues
-================
-
-You can report possible bugs, start discussions, or ask for features on our
-`issue tracker <https://github.com/bokeh/bokeh/issues>`_.
-To start a new issue, you will find a ``New issue`` green button at the top
-right area of the page.
-
-Bokeh also provides the :func:`bokeh.report_issue()` function to easily open
-issues from an interactive console prompt::
-
-
-    In [1]: bokeh.report_issue()
-    This is the Bokeh reporting engine.
-
-    You will be guided to build a GitHub issue.
-
-    Issue title: A Short Issue Title
-    Description: Some additional details and description
-    GitHub username: SomeUser
-    GitHub password: xxxxxxxx
-
-    Preview:
-
-    Title:  A Short Issue Title
-    Description:
-
-    Some additional details and description
-
-    System information:
-       Bokeh version: 0.5.2-436-g831adf5-dirty
-      Python version: 2.7.8-CPython
-            Platform: Darwin-13.3.0-x86_64-i386-64bit
-
-    Submit (y/n)?
-
-This will open a new issue on our issue tracker as well as open a new browser tab
-showing the issue, in case you want to add more comments. As you can see, this
-automatically appends useful information about versions and architecture that can
-help us to reproduce the problem.
-
-Finally, you can also make a comment on any issue using this tool just by passing
-the issue number as an argument::
-
-    In [3]: bokeh.report_issue(555)
-    This is the Bokeh reporting engine.
-
-    You will be guided to build a GitHub issue.
-
-    Write your comment here: Some new information!
-
-
-


Test patch:
diff --git a/bokeh/tests/test_bokeh_init.py b/bokeh/tests/test_bokeh_init.py
index e47ad7f0b..628987bf4 100644
--- a/bokeh/tests/test_bokeh_init.py
+++ b/bokeh/tests/test_bokeh_init.py
@@ -1,49 +1,19 @@
 from __future__ import absolute_import
 
 import unittest
-import sys
-import platform
-import os
-import mock
 
+class TestContents(unittest.TestCase):
 
-class CaptureString():
-    value = ""
-
-    def write(self, string):
-        self.value += string
-
-    def flush(self):
-        pass
-
-
-def CaptureStdOut():
-    # replace stdout with something we can capture
-    out = CaptureString()
-    sys.stdout = out
-    return out
-
-
-class TestPrintVersions(unittest.TestCase):
-
-    def setUp(self):
-        self.out = CaptureStdOut()
-
-    def test_print(self):
+    def test_dir(self):
         import bokeh
-        bokeh.print_versions()
-        # check the correct info is present
-        sysinfo = [platform.python_version(),
-                   platform.python_implementation(),
-                   platform.platform(),
-                   bokeh.__version__]
-        for info in sysinfo:
-            self.assertIn(info, self.out.value)
+        names = dir(bokeh)
+        self.assertTrue("__version__" in names)
+        self.assertTrue("test" in names)
+        self.assertTrue("sampledata" in names)
 
     def test_version_defined(self):
         import bokeh
         self.assertTrue(bokeh.__version__ != 'unknown')
 
-
 if __name__ == "__main__":
     unittest.main()
diff --git a/bokeh/util/testing.py b/bokeh/util/testing.py
index 9c7ab39f5..a0f7adfd6 100644
--- a/bokeh/util/testing.py
+++ b/bokeh/util/testing.py
@@ -20,7 +20,13 @@ def skipIfPyPy(message):
     from .platform import is_pypy
     return skipIf(is_pypy(), message)
 
-def _print_versions():
+def print_versions():
+    """ Print the versions for Bokeh and the current Python and OS.
+
+    Returns:
+        None
+
+    """
     import platform as pt
     from .. import __version__
     message = """
@@ -29,16 +35,7 @@ def _print_versions():
         Platform: %s
     """ % (__version__, pt.python_version(),
            pt.python_implementation(), pt.platform())
-    return(message)
-
-def print_versions():
-    """ Print the versions for Bokeh and the current Python and OS.
-
-    Returns:
-        None
-
-    """
-    print(_print_versions())
+    print(message)
 
 def runtests(verbosity=1, xunitfile=None, exit=False):
     """ Run the full Bokeh test suite, and output the results of the tests
@@ -89,115 +86,3 @@ def runtests(verbosity=1, xunitfile=None, exit=False):
 
     # Run the tests
     return nose.main(argv=argv, exit=exit)
-
-
-def report_issue(number=None, owner="bokeh", repo="bokeh",
-                 versions=True, browser=True):
-    """ Open or add to a Github issue programmatically.
-
-    This interactive function will ask you for some minimal content
-    and submit a new Github issue, adding information about your
-    current environment.
-
-    You can also call this function with a specific issue number to
-    add a comment to an already open issue.
-
-    Args:
-        number (int, optional) :
-            Omit to create a new issue, otherwise supply to comment on an
-            already created issue. (default: None)
-
-        owner (str, optional) : owner username (default: "bokeh")
-
-        repo (str, optional) : repository name (default: "bokeh")
-
-        versions (bool, optional) :
-            Whether to print system information. If True, add the current
-            system info to the end of the issue description. (default: True)
-
-        browser (bool, optional) :
-            Whether to open a browser automatically. If True, open a browser
-            to the GitHub issue page (default: True)
-
-    .. note::
-        Setting the environment variables GHUSER (Github username) and
-        GHPASS (Github password) will supply those values automatically
-        and streamline the dialog. Additionally, this function can report
-        on any GitHub project by changing the default parameters.
-
-    Returns:
-        None
-
-    """
-
-    import requests
-    import json
-    import os
-    import webbrowser
-
-    from six.moves import input
-    from six.moves.urllib.parse import urljoin
-
-    print("This is the Bokeh reporting engine.\n\n"
-          "You will be guided to build a GitHub issue.\n")
-
-    if number is None:
-        title = input('Issue title: ')
-        body = input('Description: ')
-    else:
-        body = input('Write your comment here: ')
-
-    ghuser, ghpass = (os.environ.get(x) for x in ["GHUSER", "GHPASS"])
-
-    if ghuser is None:
-        ghuser = input('GitHub username: ')
-    else:
-        print("Found GHUSER, using for GitHub username")
-
-    if ghpass is None:
-        ghpass = input('GitHub password: ')
-    else:
-        print("Found GHPASS, using for GitHub password")
-
-    base = "https://api.github.com"
-    if number is None:
-        url = "/".join(["repos", owner, repo, "issues"])
-        if versions:
-            data = {"title": title, "body": body + "\nSystem information:" + _print_versions()}
-        else:
-            data = {"title": title, "body": body}
-    else:
-        url = "/".join(["repos", owner, repo, "issues", str(number), "comments"])
-        if versions:
-            data = {"body": body + "\nSystem information:" + _print_versions()}
-        else:
-            data = {"body": body}
-    issues_url = urljoin(base, url)
-
-    print("\nPreview:\n")
-    print("Title: ", data["title"])
-    print("Description:\n\n")
-    print(data["body"])
-    value = input('Submit (y/n)? ')
-    if value.lower() in ["true", "yes", "y", "1"]:
-        r = requests.post(issues_url,
-                          auth=(ghuser, ghpass),
-                          headers={'Content-Type': 'application/json'},
-                          data=json.dumps(data))
-        if r.status_code == 201:
-            g = requests.get(issues_url)
-            if number is None:
-                print("Issue successfully submitted.")
-                if browser:
-                    webbrowser.open_new(g.json()[0].get("html_url"))
-            else:
-                print("Comment successfully submitted.")
-                g = requests.get(issues_url)
-                if browser:
-                    webbrowser.open_new(g.json()[-1].get("html_url"))
-        else:
-            print("Something failed, please check your username and password.")
-    else:
-        print("Issue not submitted.")
-
-
diff --git a/bokeh/util/tests/test_testing.py b/bokeh/util/tests/test_testing.py
new file mode 100644
index 000000000..817b4e30c
--- /dev/null
+++ b/bokeh/util/tests/test_testing.py
@@ -0,0 +1,41 @@
+from __future__ import absolute_import
+
+import unittest
+import sys
+import platform
+
+import bokeh.util.testing as testing
+
+class _CaptureString():
+    value = ""
+
+    def write(self, string):
+        self.value += string
+
+    def flush(self):
+        pass
+
+def _CaptureStdOut():
+    # replace stdout with something we can capture
+    out = _CaptureString()
+    sys.stdout = out
+    return out
+
+class TestPrintVersions(unittest.TestCase):
+
+    def setUp(self):
+        self.out = _CaptureStdOut()
+
+    def test_print(self):
+        import bokeh
+        testing.print_versions()
+        # check the correct info is present
+        sysinfo = [platform.python_version(),
+                   platform.python_implementation(),
+                   platform.platform(),
+                   bokeh.__version__]
+        for info in sysinfo:
+            self.assertIn(info, self.out.value)
+
+if __name__ == "__main__":
+    unittest.main()