|
@@ -15,26 +15,48 @@ import base64
|
|
# labkeySlicerPythonExtension
|
|
# labkeySlicerPythonExtension
|
|
#
|
|
#
|
|
|
|
|
|
-def buildGITURL(project,path,server):
|
|
|
|
- pathURL='%2f'.join(path)
|
|
|
|
- projectURL='%2f'.join(project)
|
|
|
|
- return server+'/api/v4/projects/'+projectURL+'/repository/files/'+pathURL+'?ref=master'
|
|
|
|
|
|
+def buildGITURL(server,project,path,branch='master'):
|
|
|
|
+ #copy of buildGITURL from nixWrapper.py
|
|
|
|
+ if server.find('wiscigt')>-1:
|
|
|
|
+ projectURL='%2f'.join(project)
|
|
|
|
+ pathURL='%2f'.join(path)
|
|
|
|
+ return server+'/api/v4/projects/'+projectURL+'/repository/files/'+pathURL+'?ref='+branch
|
|
|
|
+ if server.find('fmf.uni-lj.si')>-1:
|
|
|
|
+ projectURL='/'.join(project)#studen/nixSuite
|
|
|
|
+ pathURL='/'.join(path)
|
|
|
|
+ return '/'.join([server,projectURL,'raw',branch,pathURL])
|
|
|
|
|
|
def getWrapper(name):
|
|
def getWrapper(name):
|
|
project=['labkey','nixsuite']
|
|
project=['labkey','nixsuite']
|
|
if name=='nixWrapper.py':
|
|
if name=='nixWrapper.py':
|
|
path=['wrapper','nixWrapper.py']
|
|
path=['wrapper','nixWrapper.py']
|
|
server='http://wiscigt.powertheword.com'
|
|
server='http://wiscigt.powertheword.com'
|
|
- remoteSourcesURL=buildGITURL(project,path,server)
|
|
|
|
|
|
+ #update to new git server layout
|
|
|
|
+ server='https://git0.fmf.uni-lj.si'
|
|
|
|
+ project=['studen','nixSuite']
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ remoteSourcesURL=buildGITURL(server,project,path)
|
|
http = urllib3.PoolManager()
|
|
http = urllib3.PoolManager()
|
|
r = http.request('GET', remoteSourcesURL)
|
|
r = http.request('GET', remoteSourcesURL)
|
|
- #returns a JSON
|
|
|
|
- encoding=chardet.detect(r.data)['encoding']
|
|
|
|
- jsonData=json.loads(r.data.decode(encoding))
|
|
|
|
|
|
+
|
|
|
|
+ print(r.data)
|
|
|
|
+
|
|
|
|
+ #gogs returns raw data
|
|
|
|
+ if server.find('fmf.uni-lj.si')>-1:
|
|
|
|
+ m_bytes=r.data
|
|
|
|
+
|
|
|
|
+ if server.find('wiscigt')>-1:
|
|
|
|
+ #returns a JSON
|
|
|
|
+ encoding=chardet.detect(r.data)['encoding']
|
|
|
|
+ jsonData=json.loads(r.data.decode(encoding))
|
|
|
|
+ content=jsonData['content']
|
|
|
|
+ #we are interested in content, do looped way of decoding it
|
|
|
|
+ b64_bytes=content.encode('ascii')
|
|
|
|
+ m_bytes=base64.b64decode(b64_bytes)
|
|
|
|
+
|
|
|
|
|
|
#we are interested in content, do looped way of decoding it
|
|
#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')
|
|
m=m_bytes.decode('ascii')
|
|
#m is string coded file that needs to be written to file
|
|
#m is string coded file that needs to be written to file
|
|
pathList=['.nix','software','src']
|
|
pathList=['.nix','software','src']
|