Skip to content

Commit

Permalink
Merge branch 'updater' into 'py3k'
Browse files Browse the repository at this point in the history
Updater

Closes #51.  The updater works with pre-packaged binaries from anaconda.org through the conda-client.

See merge request !10
  • Loading branch information
nckz committed Nov 1, 2015
2 parents e197ecb + 7ddd1f2 commit e6cf01d
Show file tree
Hide file tree
Showing 4 changed files with 506 additions and 0 deletions.
42 changes: 42 additions & 0 deletions bin/gpi_update
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

# Copyright (C) 2014 Dignity Health
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# NO CLINICAL USE. THE SOFTWARE IS NOT INTENDED FOR COMMERCIAL PURPOSES
# AND SHOULD BE USED ONLY FOR NON-COMMERCIAL RESEARCH PURPOSES. THE
# SOFTWARE MAY NOT IN ANY EVENT BE USED FOR ANY CLINICAL OR DIAGNOSTIC
# PURPOSES. YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE IS NOT INTENDED FOR
# USE IN ANY HIGH RISK OR STRICT LIABILITY ACTIVITY, INCLUDING BUT NOT
# LIMITED TO LIFE SUPPORT OR EMERGENCY MEDICAL OPERATIONS OR USES. LICENSOR
# MAKES NO WARRANTY AND HAS NOR LIABILITY ARISING FROM ANY USE OF THE
# SOFTWARE IN ANY HIGH RISK OR STRICT LIABILITY ACTIVITIES.

import sys, os

# Check for Anaconda PREFIX, or assume that THIS file location is the CWD.
GPI_PREFIX = '/opt/anaconda1anaconda2anaconda3' # ANACONDA
if GPI_PREFIX == '/opt/'+''.join(['anaconda'+str(i) for i in range(1,4)]):
GPI_PREFIX, _ = os.path.split(os.path.dirname(os.path.realpath(__file__)))

GPI_LIB_DIR = os.path.join(GPI_PREFIX, 'lib')
if GPI_LIB_DIR not in sys.path:
sys.path.insert(0, GPI_LIB_DIR)

# gpi
from gpi import update

if __name__ == '__main__':
update.update()
9 changes: 9 additions & 0 deletions lib/gpi/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from .logger import manager
from .widgets import DisplayBox, TextBox, TextEdit
from .sysspecs import Specs
from .update import UpdateWindow

# start logger for this module
log = manager.getLogger(__name__)
Expand Down Expand Up @@ -452,12 +453,20 @@ def createMenus(self):
self.helpMenu = QtGui.QMenu("&Help", self)
aboutAction = self.helpMenu.addAction("&About")
self.connect(aboutAction, QtCore.SIGNAL("triggered()"), self.about)
self.checkForUpdate = QtGui.QAction("Check For Updates...", self, triggered=self.openUpdater)
self.checkForUpdate.setMenuRole(QtGui.QAction.ApplicationSpecificRole)
self.helpMenu.addAction(self.checkForUpdate)
self.helpMenu_openDocs = QtGui.QAction("Documentation", self, triggered=self.openWebsite)
self.helpMenu.addAction(self.helpMenu_openDocs)
self.helpMenu_openDocs = QtGui.QAction("Examples", self, triggered=self.openExamplesFolder)
self.helpMenu.addAction(self.helpMenu_openDocs)
self.menuBar().addMenu(self.helpMenu)

def openUpdater(self):
self._updateWin = UpdateWindow(dry_run=False)
self._updateWin.show()
self._updateWin.raise_()

# TODO: move this and others like it to a common help-object that can errorcheck.
def openWebsite(self):
if not QtGui.QDesktopServices.openUrl(QtCore.QUrl('http://docs.gpilab.com')):
Expand Down
39 changes: 39 additions & 0 deletions lib/gpi/runnable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2014 Dignity Health
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# NO CLINICAL USE. THE SOFTWARE IS NOT INTENDED FOR COMMERCIAL PURPOSES
# AND SHOULD BE USED ONLY FOR NON-COMMERCIAL RESEARCH PURPOSES. THE
# SOFTWARE MAY NOT IN ANY EVENT BE USED FOR ANY CLINICAL OR DIAGNOSTIC
# PURPOSES. YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE IS NOT INTENDED FOR
# USE IN ANY HIGH RISK OR STRICT LIABILITY ACTIVITY, INCLUDING BUT NOT
# LIMITED TO LIFE SUPPORT OR EMERGENCY MEDICAL OPERATIONS OR USES. LICENSOR
# MAKES NO WARRANTY AND HAS NOR LIABILITY ARISING FROM ANY USE OF THE
# SOFTWARE IN ANY HIGH RISK OR STRICT LIABILITY ACTIVITIES.

# A quick way to spawn a thread for function objects and bound methods
# Example:
# ExecRunnable(Runnable(<myfunc>))

from gpi import QtCore

def ExecRunnable(runnable):
tp = QtCore.QThreadPool.globalInstance()
tp.start(runnable)

class Runnable(QtCore.QRunnable):
def __init__(self, func):
super().__init__()
self.run = func
self.setAutoDelete(True)
Loading

0 comments on commit e6cf01d

Please sign in to comment.