-
Notifications
You must be signed in to change notification settings - Fork 370
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
Fix of issue 246 - Make help and helpdesk more robust #688
Changes from 17 commits
bdc87b7
3e33dea
83346c1
e7c9f9c
8a2d69f
64f18a5
7a3b8f8
3edd66e
cdbc3ab
6fe70e5
3e710ae
fc66fe2
508c008
5d47a80
4e124a3
13caa64
3b5e86d
89a5abe
148fdb5
4642c8d
ee5b97d
42da7c3
b82fa50
a86a32c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ | |
""" | ||
|
||
from .hl_api_helper import * | ||
import sys | ||
import os | ||
import webbrowser | ||
|
||
|
||
@check_stack | ||
|
@@ -55,23 +58,36 @@ def authors(): | |
|
||
|
||
@check_stack | ||
def helpdesk(browser="firefox"): | ||
"""Open the NEST helpdesk in the given browser. | ||
def helpdesk(): | ||
"""Open the NEST helpdesk in browser. | ||
|
||
The default browser is firefox. | ||
|
||
Parameters | ||
---------- | ||
browser : str, optional | ||
Name of the browser to use | ||
Use the system default browser. | ||
""" | ||
if 'NEST_DOC_DIR' not in os.environ: | ||
print( | ||
'NEST help needs to know where NEST is installed.' | ||
'Please source nest_vars.sh or define NEST_DOC_DIR manually.') | ||
return | ||
|
||
sr("/helpdesk << /command (%s) >> SetOptions" % browser) | ||
sr("helpdesk") | ||
url = os.path.join(os.environ['NEST_DOC_DIR'] + "/help", "helpindex.html") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provide a useful error message if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you mix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still have some issues with this line:
helpfile = os.path.join(os.environ['NEST_DOC_DIR'], 'help', 'helpindex.html') |
||
""" | ||
Under Windows systems webbrowser.open is incomplete | ||
<https://bugs.python.org/issue8232> | ||
""" | ||
if sys.platform[:3] == "win": | ||
os.startfile(url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you use |
||
""" | ||
Under MacOs we need to ask for the browser explicitly. | ||
See <https://bugs.python.org/issue30392>. | ||
""" | ||
if sys.platform[:3] == "dar": | ||
webbrowser.get('safari').open_new(url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not |
||
else: | ||
webbrowser.open_new(url) | ||
|
||
|
||
@check_stack | ||
def help(obj=None, pager="less"): | ||
def help(obj=None, pager=None): | ||
"""Show the help page for the given object using the given pager. | ||
|
||
The default pager is less. | ||
|
@@ -83,17 +99,17 @@ def help(obj=None, pager="less"): | |
pager : str, optional | ||
Pager to use | ||
""" | ||
hlpobj = obj | ||
if hlpobj is not None: | ||
show_help_with_pager(hlpobj, pager) | ||
|
||
if obj is not None: | ||
sr("/page << /command (%s) >> SetOptions" % pager) | ||
sr("/%s help" % obj) | ||
else: | ||
print("Type 'nest.helpdesk()' to access the online documentation " | ||
"in a browser.") | ||
print("Type 'nest.help(object)' to get help on a NEST object or " | ||
"command.\n") | ||
print("Type 'nest.Models()' to see a list of available models " | ||
"in NEST.\n") | ||
"in NEST.") | ||
print("Type 'nest.authors()' for information about the makers " | ||
"of NEST.") | ||
print("Type 'nest.sysinfo()' to see details on the system " | ||
|
@@ -115,6 +131,7 @@ def get_argv(): | |
tuple: | ||
Argv, as seen by NEST. | ||
""" | ||
|
||
sr('statusdict') | ||
statusdict = spp() | ||
return statusdict['argv'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simplify this to (but see comment above)