|
@@ -6,19 +6,36 @@ import zipfile
|
|
|
import pathlib
|
|
|
import json
|
|
|
import getpass
|
|
|
+import chardet
|
|
|
+import base64
|
|
|
+
|
|
|
#this is meant to be used as a startup script
|
|
|
#all commands will be executed when python -m script -i is used
|
|
|
|
|
|
|
|
|
#generic function to load library from gitlab
|
|
|
+
|
|
|
def getSuitePath():
|
|
|
installDir=os.path.join(os.path.expanduser('~'),'.labkey','software','src')
|
|
|
if not os.path.isdir(installDir):
|
|
|
os.makedirs(installDir)
|
|
|
return installDir
|
|
|
|
|
|
-
|
|
|
-def loadModule(slicer,name,moduleName):
|
|
|
+def getResources():
|
|
|
+ remoteSourcesURL="http://wiscigt.powertheword.com/api/v4/projects/labkey%2fnixsuite/repository/files/remoteResources%2fresources.json?ref=master"
|
|
|
+ http = urllib3.PoolManager()
|
|
|
+ r = http.request('GET', remoteSourcesURL)
|
|
|
+ #returns a JSON
|
|
|
+ encoding=chardet.detect(r.data)['encoding']
|
|
|
+ jsonData=json.loads(r.data.decode(encoding))
|
|
|
+
|
|
|
+ #we are interested in content, do looped way of decoding it
|
|
|
+ b64_bytes=jsonData['content'].encode('ascii')
|
|
|
+ m_bytes=base64.b64decode(b64_bytes)
|
|
|
+ m=m_bytes.decode('ascii')
|
|
|
+ return json.loads(m)
|
|
|
+
|
|
|
+def loadModule(slicer,qt,name,moduleName):
|
|
|
loadLibrary(name)
|
|
|
modulePath=os.path.join(getSuitePath(),name,'slicerModule',moduleName+'.py')
|
|
|
factoryManager = slicer.app.moduleManager().factoryManager()
|
|
@@ -32,13 +49,8 @@ def loadModule(slicer,name,moduleName):
|
|
|
def loadLibrary(name):
|
|
|
#load library from git, store it at a default location and
|
|
|
#add path to the python sys
|
|
|
-
|
|
|
- remoteSourcesURL={
|
|
|
- "labkeyInterface":\
|
|
|
- "http://wiscigt.powertheword.com/labkey/labkeyinterface/-/archive/master/labkeyinterface-master.zip"
|
|
|
- "iraeMM":
|
|
|
+ remoteSources=getResources()
|
|
|
|
|
|
- }
|
|
|
#two steps:
|
|
|
#1 Download
|
|
|
|