Add check for update

* Add check for latest release in IDE.
This commit is contained in:
iabdalkader 2015-09-23 05:04:55 +02:00
parent d11e8f7212
commit 9398ae0248
2 changed files with 102 additions and 0 deletions

View File

@ -181,6 +181,11 @@
<property name="step_increment">1</property>
<signal name="value-changed" handler="on_ctrl_scale_value_changed" swapped="no"/>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-sort-ascending</property>
</object>
<object class="GtkListStore" id="pref_board_liststore">
<columns>
<!-- column-name Text -->
@ -1142,6 +1147,80 @@
<action-widget response="-6">button12</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="update_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">An Update is Available!</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="transient_for">top_window</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox56">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="rn_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area56">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkLinkButton" id="download_button">
<property name="label" translatable="yes">Download</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="image">image1</property>
<property name="uri">http://www.google.com</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button22">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">download_button</action-widget>
<action-widget response="0">button22</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="save_descriptor_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>

View File

@ -10,6 +10,7 @@ from time import sleep
from os.path import expanduser
import gtksourceview2 as gtksourceview
from glob import glob
import urllib2, json
#import pydfu on Linux
if platform.system() == "Linux":
@ -54,6 +55,8 @@ recent =
last_fw_path =
baudrate = 921600
'''
RELEASE_TAG_NAME = 'v1.0'
RELEASE_URL = 'https://api.github.com/repos/openmv/openmv/releases/latest'
class OMVGtk:
def __init__(self):
@ -688,6 +691,25 @@ class OMVGtk:
return serial_ports
def check_for_updates(self):
try:
url = urllib2.urlopen(RELEASE_URL)
release = json.loads(url.read())
url.close()
if (release['tag_name'] != RELEASE_TAG_NAME):
dialog = self.builder.get_object("update_dialog")
dn_button = self.builder.get_object("download_button")
# Set release notes
self.builder.get_object("rn_label").\
set_text('Release notes (%s):\n\n%s'%(release['tag_name'], release['body']))
# Set URL
dn_button.set_uri(release['html_url'])
dialog.run()
dialog.hide()
except:
pass #pass quietly
def quit(self, widget):
try:
# disconnect
@ -702,5 +724,6 @@ class OMVGtk:
if __name__ == "__main__":
omvgtk = OMVGtk()
omvgtk.window.show_all()
omvgtk.check_for_updates()
gobject.gobject.timeout_add(30, omvgtk.update_drawing)
gtk.main()