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

Add a check for updates method #2321

Merged
merged 5 commits into from
Apr 22, 2015
Merged

Add a check for updates method #2321

merged 5 commits into from
Apr 22, 2015

Conversation

goanpeca
Copy link
Member

Fixes #2307

(Note from @ccordoba12: Please leave Fixes instead of Implements because that way when I merge the PR, GH will automatically close the corresponding issue. If you don't like Fixes, here are the other words you can use to make this happen)

Description

Add a method to check for updates querying the Github API, using a QThread and Worker to avoid blocking the GUI.

The method is called on startup if running from installed version and will only display a message if there is an update. If running in DEV mode versions it will not be triggered on startup.

There is also an entry in the Help menu to check for updates at any moment, unlike the one on startup, this action will give feedback also if no updates are available, or if there is some internet error.

Messages

Ubuntu
image

Ubuntu
image

Windows
image

New option in the general preferences

This option is on by default and then the user can decide by checking or unchecking the checkbox.

Windows
image

Checklist

  • Agree on location in menu
  • Agree on message
  • Add preferences option to disable this check on startup (on by default)
  • Adjust check to handle stable and dev/beta cases.
    • If using a beta release display message if higher beta release or higher stable
    • If using a stable version check only against stable versions

@goanpeca goanpeca added this to the v3.0 milestone Apr 11, 2015
@goanpeca goanpeca self-assigned this Apr 11, 2015
@goanpeca goanpeca changed the title Enhancement #2307: Add a check for updates method Implements #2307: Add a check for updates method Apr 11, 2015
@@ -942,6 +948,12 @@ def create_edit_action(text, tr_text, icon_name):
support_action = create_action(self,
_("Spyder support..."),
triggered=self.google_group)
check_updates_trig = lambda: self.check_updates(True)
check_updates_action = create_action(self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should use here self.check_updates_action directly and remove the line below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@ccordoba12
Copy link
Member

Thanks for working on this!! It's really useful.

About your todo's:

  1. I think putting the action on the Help menu is fine.
  2. I also think the QMessageBox is fine, except for my little comment.

@goanpeca
Copy link
Member Author

@blink1073 being the closest thing to a native speaker 😸, could you check if the messages (in the description) make sense to you? Thanks

@goanpeca
Copy link
Member Author

@ccordoba12, what about release candidates? Will those be listed as well in the releases page? I have not taken any measures to test for those.

@blink1073
Copy link
Contributor

👍 from the 'Murican

if update_available:
msg = _('Spyder {0} is available. <br><br>Please use your '
'package manager to update Spyder or go to our '
'<a href="{1}">Releases</a> page to download Spyder '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not be too repetitive, please change this text to

'<a href="{1}">Releases</a> page to download this '
'new version'

Also, please use double quotes to build this whole string. It's better because using single quotes in written English is quite common (while not so much for double ones).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what would be cool here too? To add a link to the Installation page in our documentation. It could something like

If you don't know to update Spyder, please refer to our Installation instructions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍

@ccordoba12
Copy link
Member

@goanpeca, GH allows us to tag betas and release candidates as pre-releases.

That's exposed through the GH API, as can be seen here, so you should check for it when determining the latest release.

@goanpeca
Copy link
Member Author

@ccordoba12 what should be default behavior when checking with betas or release candidates?

If the newest is a beta (or rc), ignore it and check the next one until an official non beta release is found and compare to that?

@Nodd
Copy link
Contributor

Nodd commented Apr 12, 2015

I think that at first we should just warn about stable versions. If we include beta or rc versions, sit should be an option, disabled by default.
It should be possible to disable the check. Imagine if the installation is managed by an administrator, a user would see the popup at each start until the admin does his job. Depending on the situation it can take a while (on some Linux distros old packages are kept for a long time, think CentOS or debian stable).
Maybe packagers should have an easy option to disable this ? Checking new versions automatically when the system already has a package manager could be redundant.

@goanpeca
Copy link
Member Author

  1. I would prefer NOT including beta or rc in the comparison.
  2. Ok, I can add an option to have it disabled. (but it should be ON by default, otherwise it defeats the purpose)

There are too many use cases to decide when it makes sense to have it on or off... package managers in linux distros.. pips condas.. python xy... winpython etc... so I think it is still sensible to have ON by default and only check against stable versions. The message box can include a checkbox and ask the user, if he wants to continue receiving this messages... that would make it more obvious and easy to correct.

What do you think?

@Nodd
Copy link
Contributor

Nodd commented Apr 12, 2015

The "off by default" part is about beta versions. Of course the check about stable versions should be on.

Including a checkbox in the message box in addition to the preferences is OK for me.

@goanpeca
Copy link
Member Author

Yes @Nodd , now I understood what you meant. Will make the changes soon.

@ccordoba12 just to confirm, are these the expected tags (structure in downward order of release) to be found in Spyder releases:

  • Development: '3.0.0dev'
  • Alpha: '3.0.0alpha1', '3.0.0alpha2'
  • Beta: '3.0.0beta1', '3.0.0beta2'
  • Release candidate: '3.0.0rc1', '3.0.0rc2'
  • Stable: '3.0.0', '3.0.1' etc...

@goanpeca
Copy link
Member Author

@Nodd @ccordoba12, take a look at the description for the updated look.

Should all the other boxes contain the checkbox asking? (Error box, or Uptodate Box?)

@goanpeca
Copy link
Member Author

Ok so this is the logic I coded

  1. If running in bootstrap (DEV, no matter what type.. beta, dev, rc, or stable) then never check on startup, and when ran with the menu, it will always display up to date... (another option would be to disable this option in DEV mode). This ignores whatever setting is on the preferences menu.
  2. If the user has a stable version installed (2.3.4 for instance) then check for updates will only check against stable versions (3.0.0, 2.3.5 etc..) and will respect the entry on the preferences menu.
  3. If the user has an alpha, beta, or release candidate installed (3.0.0rc1...) then check for updates will check against stable version (3.0.0) or higher non stable versions (3.0.0rc2...), and it will respect the entry on the preferences menu
  4. Finally, If the user has a dev version installed (for whatever reason!!) then check for updates will respect the entry on the preferences menu but will always give up to date. Another option is that if the user installed a dev version, then never check on startup (similar to DEV bootstrap) and maybe disable the action in the help menu.

Comments?

@goanpeca
Copy link
Member Author

I also added the extra needed logic inside the Worker class, but now I think the worker should go out of the spyder.py file otherwsie it will keep growing..., do you agree on creating a new folder called 'spyderlib\workers' or maybe spyderlib\widgets\workers and put this one there there? and any other eventual worker that arises?

@@ -190,7 +190,9 @@ def is_ubuntu():
'cpu_usage/timeout': 2000,
'use_custom_margin': True,
'custom_margin': 0,
'show_internal_console_if_traceback': True
'show_internal_console_if_traceback': True,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this blank line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍

return (False, latest_release)

if self.is_stable_version(latest) and \
version.startswith(latest) and latest != version:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be indented only two spaces, i.e. like this

if self.is_stable_version(latest) and \
  version.startswith(latest) and latest != version:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I do this, pep8 complains... if I use 8 spaces, pep8 does not complain...

@goanpeca goanpeca changed the title Implements #2307: Add a check for updates method Fixes #2307: Add a check for updates method Apr 19, 2015
@goanpeca
Copy link
Member Author

@ccordoba12 made suggested changes.


# check_version is based on LooseVersion, so a small hack is needed so
# that LooseVersion understands that '3.0.0' is in fact bigger than
# '3.0.0rc1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing: please move this hack to check_version. It'll be more useful there :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bear in mind, that also, is_stable_version will be moved to utils.programs

@ccordoba12
Copy link
Member

Another thing: are you squashing commits? I don't like that too much because it doesn't let us see the evolution of the PR in git log.

@goanpeca
Copy link
Member Author

For small changes, having too many commits seems messy, but for this one you are right.

I will stop squashing, when a PR is relatively big like this one.

@goanpeca
Copy link
Member Author

@ccordoba12 added latest suggestions.

feedback = True
elif self.thread_updates is not None:
self.thread_updates.terminate()
feedback = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel at ease with this feedback variable. It's passed to the worker, but it doesn't do anything with it. It seems the worker just holds it, so that _check_updates_ready can later read it.

But wouldn't it be better to move this block to _check_updates_ready directly and get rid of this passing around process?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, these are the leftovers of the original way I did it, when the method accepted parameters. Will move it

@goanpeca goanpeca changed the title Fixes #2307: Add a check for updates method Add a check for updates method Apr 22, 2015
@goanpeca
Copy link
Member Author

@ccordoba12 I think this one is good to go :-)

self.check_updates_action = None
self.thread_updates = None
self.worker_updates = None
self.flag_updates_feedback = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, last thing :-) I don't like too much this variable name.

Suggestions:

  1. self.updates_feedback
  2. self.give_updates_feedback

I think any of those would convey its meaning better ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@goanpeca
Copy link
Member Author

Next... :-)?

@ccordoba12
Copy link
Member

Wait for Travis ;-)

@goanpeca
Copy link
Member Author

;- |

@ccordoba12
Copy link
Member

I just tested it locally and it's working as expected :-)

This is great addition, thanks a lot for working on it!!

ccordoba12 added a commit that referenced this pull request Apr 22, 2015
Add a check for updates method
@ccordoba12 ccordoba12 merged commit 8d3b985 into spyder-ide:master Apr 22, 2015
@goanpeca goanpeca deleted the updates branch April 23, 2015 09:06
@goanpeca
Copy link
Member Author

👍 in the release candidates we will check for sure if it is working as it should

@stonebig
Copy link
Contributor

stonebig commented Aug 9, 2015

Hi all,

I discovered recently that:

  • I can't rebuild Spyder in a Windows/Python3/not-anaconda environnement.
  • some users (or teachers) may not feel comfortable with unsolicited web traffic like this check for updates, and students randomly acting on this.

Would it be possible to set this option to "no" by default ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Add check for updates and allow for autoupdating inside spyder
5 participants