-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fixes #2306: Add a restart method #2312
Conversation
|
||
if any([not spyder_args, not pid, not is_bootstrap, not spyder_folder]): | ||
error = "This script can only be called from within a Spyder instance" | ||
raise Exception(error) |
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.
RuntimeException is maybe cleaner
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.
Yes sure
@Nodd, I included your suggestions and completed support on Linux and Windows. Still need Mac check and python3 check. There is no way around the |
|
It's also a bit slower but it doesn't apply here either. |
system = platform.system().lower() | ||
|
||
startupinfo = None | ||
if 'win' in system: |
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.
This picks up darwin
, you can use win32
here or put darwin
first.
I tested this on OSX. It works after I made the two changes highlighted above. |
Thanks @blink1073 😄 Did you check with python3 as well? I will push the changes shortly |
Ok so I checked with Py3 on linux as well and made corrections as suggested by @blink1073. Thanks @blink1073, and @Nodd for comments 😸 Any suggestions/comments/concerns @ccordoba12? |
@goanpeca, I had used Python 3. Python 2 works now as well on OSX. |
@blink1073 Ok great, then I guess is up to @ccordoba12 and @SylvainCorlay now ;-) to give some feedback |
@ccordoba12, have you had time to check this? |
@@ -477,6 +477,7 @@ def is_ubuntu(): | |||
'_/save current layout': "Shift+Alt+S", | |||
'_/toggle default layout': "Shift+Alt+Home", | |||
'_/layout preferences': "Shift+Alt+P", | |||
'_/restart': "Shift+Ctrl+R", |
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.
Shift+Ctrl+<foo>
is used to focus plugins. Could you think of a different shortcut?
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.
Hmm I can try... @Nodd, ideas?
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.
Shift+Ctrl+Alt+AltGr+Meta+R ?
A bit more seriously, the other shortcuts use Shift+Alt, so it should be OK.
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.
Ctrl+Shift+Alt+R ?
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.
Shift+Alt+R only ?
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.
Sure.. why not, @ccordoba12 ?
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.
That's ok for me
Ok, first (quick) review is over :-) |
try: | ||
subprocess.Popen(command, shell=shell, env=env, | ||
startupinfo=startupinfo) | ||
self.console.quit() |
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.
@ccordoba12 here is where it is closed
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.
Ok, thanks for pointing it out! ;-)
But why not call self.closing()
instead of self.console.quit()
? That's the method I was looking for in my review :-)
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.
Oops... Got it
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.
Hmm @ccordoba12, self.closing() return True, or False... but does not close... so how does it work?
@ccordoba12, made suggested corrections |
|
||
# Maybe --new-instance should always be included to cope with corner cases | ||
# where someone has one running version without and and another with | ||
# If the user the one without (--new...) it would not start |
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.
Do you plan to address this comment?
Also, could reworded a bit? It's not easy to understand what it means :-)
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.
Do you think it is a good idea to enforce upon restart the use of new instance? to avoid any weird cases? For most use cases it wont make a difference, but if for some reason people are using that option, then it would help.
Thoughts?
New review done :-) This is shaping nicely! |
@ccordoba12 added latest suggestions ;-) |
env['SPYDER_ARGS'] = spyder_args | ||
env['SPYDER_PID'] = str(pid) | ||
env['SPYDER_IS_BOOTSTRAP'] = str(is_bootstrap) | ||
env['SPYDER_FOLDER'] = spyder_folder |
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.
It seems to me there is no need to pass SPYDER_FOLDER
as an env var because it can be computed from the __file__
attribute of spyder_restart.py
.
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.
The other env vars are fine by the way :-)
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.
True!
@ccordoba12 added latest suggestions. |
import sys | ||
import time | ||
|
||
from spyderlib.py3compat import to_text_string |
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.
I just tested this PR and it's not working with bootstrap
because of this line.
The thing is this assumes Spyder is installed in your virtualenv or globally. But that's almost always not true (at least for me :-), when you're using bootstrap
.
The only alternative I see is to copy/paste to_text_string
here and use it below. It's a simple function, so I don't see any problem with that :-)
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.
Ok, fixed!
@ccordoba12 can you check again :-) ? |
Great! This is working for me now :-) |
Add restart functionality to the application
Fixes #2306
Description
Add a restart method. Used the restart image as the ones used by the consoles. The shortcut for restarting is set as
Shift+Alt+R
.Tasks