- Timestamp:
- Jun 16, 2017, 12:22:02 AM (4 years ago)
- Location:
- lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/appImageManager.py
r5187 r5188 18 18 #action=example 19 19 #package='*' (in this case all packages) 20 self.pluginInfo={'install':'appimage','remove':'appimage','pkginfo':'appimage' ,'loadCatalogue':'appimage'}20 self.pluginInfo={'install':'appimage','remove':'appimage','pkginfo':'appimage'} 21 21 self.result={} 22 22 self.result['data']={} … … 155 155 #def _get_info 156 156 157 def _download_appImg_catalogue(self):158 outfile='appimage.yml'159 outdir="/usr/share/metainfo"160 outdir="/tmp"161 content=''162 applist=[]163 repolist=['https://dl.bintray.com/probono/AppImages']164 self.descDict={}165 for repo in repolist:166 self._debug(("Fetching repo %s")%(repo))167 applist=self._generate_applist(self._fetch_repo(repo))168 self._debug("Processing info...")169 self._th_generate_xml_catalog(applist,outdir)170 self._debug("Fetched repo "+repo)171 self._debug("Setting status to 0")172 self._set_status(0)173 return("Repo fetched")174 175 def _fetch_repo(self,repo):176 with urllib.request.urlopen('https://dl.bintray.com/probono/AppImages') as f:177 content=(f.read().decode('utf-8'))178 return(content)179 180 def _generate_applist(self,content):181 garbageList=[]182 applist=[]183 garbageList=content.split(' ')184 for garbageLine in garbageList:185 if garbageLine.endswith('AppImage"'):186 app=garbageLine.replace('href=":','')187 applist.append(app.replace('"',''))188 return(applist)189 190 def _get_description(self,appName):191 desc=''192 self._debug("Getting description from 'https://bintray.com/probono/AppImages/'"+appName)193 try:194 with urllib.request.urlopen('https://bintray.com/probono/AppImages/'+appName) as f:195 content=(f.read().decode('utf-8'))196 soup=BeautifulSoup(content,"html.parser")197 descDiv=soup.findAll('div', attrs={ "class" : "description-text"})198 if len(descDiv)>0:199 desc=descDiv[0].text200 desc=desc.replace(':','.')201 desc=desc.replace('&','&')202 except:203 pass204 return(desc)205 206 def _th_generate_xml_catalog(self,applist,outdir):207 oldName=''208 oldDesc=''209 maxconnections = 10210 semaphore = threading.BoundedSemaphore(value=maxconnections)211 randomList = list(applist)212 random.shuffle(randomList)213 lenAppList=len(randomList)214 self.progress=25215 for app in randomList:216 th=threading.Thread(target=self._th_write_xml, args = (app,outdir,semaphore))217 th.start()218 self._callback(1,len(randomList))219 while (len(threading.enumerate())>3):220 self._callback()221 time.sleep(0.5)222 223 def _th_write_xml(self,app,outdir,semaphore):224 semaphore.acquire()225 lock=threading.Lock()226 self._debug("Generating "+app+" xml")227 nameSplitted=app.split('-')228 name=nameSplitted[0]229 version=nameSplitted[1]230 arch=nameSplitted[2]231 f=open(outdir+'/'+name+"_"+version+".appdata.xml",'w')232 f.write('<?xml version="1.0" encoding="UTF-8"?>'+"\n")233 f.write("<components version=\"0.10\">\n")234 f.write("<component type=\"desktop-application\">\n")235 f.write(" <id>"+app.lower()+"</id>\n")236 f.write(" <pkgname>"+app+"</pkgname>\n")237 f.write(" <name>"+name+"</name>\n")238 f.write(" <summary>"+name+" AppImage Bundle</summary>\n")239 f.write(" <metadata_license>CC0-1.0</metadata_license>\n")240 f.write(" <provides><binary>"+app+"</binary></provides>\n")241 f.write(" <releases>\n")242 f.write(" <release version=\""+version+"\" timestamp=\"1408573857\"></release>\n")243 f.write(" </releases>\n")244 f.write(" <launchable type=\"desktop-id\">"+name+".desktop</launchable>\n")245 with lock:246 if name in self.descDict.keys():247 description=self.descDict[name]248 else:249 description=self._get_description(name)250 self.descDict.update({name:description})251 f.write(" <description><p>This is an AppImage bundle of app "+name+". It hasn't been tested by our developers and comes from a 3rd party dev team. Please use it carefully.</p><p>"+description+"</p></description>\n")252 f.write(" <bundle type=\"appimage\">"+app+"</bundle>\n")253 f.write(" <keywords>\n")254 f.write(" <keyword>"+name+"</keyword>\n")255 f.write(" <keyword>appimage</keyword>\n")256 f.write(" </keywords>\n")257 f.write(" <categories>\n")258 f.write(" <category>AppImage</category>\n")259 f.write(" <category>GTK</category>\n")260 f.write(" </categories>\n")261 f.write("<icon type=\"cached\">"+name+"_"+name+".png</icon>\n")262 f.write("</component>\n")263 f.write("</components>\n")264 f.close()265 semaphore.release() -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/loadStore.py
r5187 r5188 7 7 import json 8 8 import re 9 import urllib 10 import random 11 import threading 12 import time 9 13 10 14 class loadstore: … … 59 63 store=self._sanitize_store(store) 60 64 if loadBundles: 65 self._download_appImg_catalogue() 61 66 store=self.load_appImg_catalog(store) 62 67 self.store=store … … 227 232 #def _apply_blacklist 228 233 234 def _download_appImg_catalogue(self): 235 CURSOR_UP='\033[F' 236 ERASE_LINE='\033[K' 237 outfile='appimage.yml' 238 outdir="/usr/share/metainfo" 239 outdir="/tmp" 240 content='' 241 applist=[] 242 progressBar="#" 243 repolist=['https://dl.bintray.com/probono/AppImages'] 244 self.descDict={} 245 for repo in repolist: 246 self._debug(("Fetching repo %s")%(repo)) 247 print ("Download Progress: "+progressBar,end="\r") 248 progressBar=progressBar+"#" 249 applist=self._generate_applist(self._fetch_repo(repo)) 250 print ("Download Progress: "+progressBar,end="\r") 251 self._debug("Processing info...") 252 self._th_generate_xml_catalog(applist,outdir,progressBar) 253 self._debug("Fetched repo "+repo) 254 self._debug("Setting status to 0") 255 self._set_status(0) 256 return("Repo fetched") 257 258 def _fetch_repo(self,repo): 259 with urllib.request.urlopen('https://dl.bintray.com/probono/AppImages') as f: 260 content=(f.read().decode('utf-8')) 261 return(content) 262 263 def _generate_applist(self,content): 264 garbageList=[] 265 applist=[] 266 garbageList=content.split(' ') 267 for garbageLine in garbageList: 268 if garbageLine.endswith('AppImage"'): 269 app=garbageLine.replace('href=":','') 270 applist.append(app.replace('"','')) 271 return(applist) 272 273 def _get_description(self,appName): 274 desc='' 275 self._debug("Getting description from 'https://bintray.com/probono/AppImages/'"+appName) 276 try: 277 with urllib.request.urlopen('https://bintray.com/probono/AppImages/'+appName) as f: 278 content=(f.read().decode('utf-8')) 279 soup=BeautifulSoup(content,"html.parser") 280 descDiv=soup.findAll('div', attrs={ "class" : "description-text"}) 281 if len(descDiv)>0: 282 desc=descDiv[0].text 283 desc=desc.replace(':','.') 284 desc=desc.replace('&','&') 285 except: 286 pass 287 return(desc) 288 289 def _th_generate_xml_catalog(self,applist,outdir,progressBar=''): 290 CURSOR_UP='\033[F' 291 ERASE_LINE='\033[K' 292 oldName='' 293 oldDesc='' 294 maxconnections = 10 295 semaphore = threading.BoundedSemaphore(value=maxconnections) 296 randomList = list(applist) 297 random.shuffle(randomList) 298 lenAppList=len(randomList) 299 inc=25/lenAppList 300 for app in randomList: 301 th=threading.Thread(target=self._th_write_xml, args = (app,outdir,semaphore,inc)) 302 th.start() 303 # while (len(threading.enumerate())>3): 304 # self._callback() 305 time.sleep(0.5) 306 progressBar=self.progress 307 print ("Download Progress: "+str(int(progressBar))+"%",end="\r") 308 309 def _th_write_xml(self,app,outdir,semaphore,inc): 310 semaphore.acquire() 311 lock=threading.Lock() 312 self._debug("Generating "+app+" xml") 313 nameSplitted=app.split('-') 314 name=nameSplitted[0] 315 version=nameSplitted[1] 316 arch=nameSplitted[2] 317 f=open(outdir+'/'+name+"_"+version+".appdata.xml",'w') 318 f.write('<?xml version="1.0" encoding="UTF-8"?>'+"\n") 319 f.write("<components version=\"0.10\">\n") 320 f.write("<component type=\"desktop-application\">\n") 321 f.write(" <id>"+app.lower()+"</id>\n") 322 f.write(" <pkgname>"+app+"</pkgname>\n") 323 f.write(" <name>"+name+"</name>\n") 324 f.write(" <summary>"+name+" AppImage Bundle</summary>\n") 325 f.write(" <metadata_license>CC0-1.0</metadata_license>\n") 326 f.write(" <provides><binary>"+app+"</binary></provides>\n") 327 f.write(" <releases>\n") 328 f.write(" <release version=\""+version+"\" timestamp=\"1408573857\"></release>\n") 329 f.write(" </releases>\n") 330 f.write(" <launchable type=\"desktop-id\">"+name+".desktop</launchable>\n") 331 with lock: 332 if name in self.descDict.keys(): 333 description=self.descDict[name] 334 else: 335 description=self._get_description(name) 336 self.descDict.update({name:description}) 337 self.progress=self.progress+inc 338 f.write(" <description><p>This is an AppImage bundle of app "+name+". It hasn't been tested by our developers and comes from a 3rd party dev team. Please use it carefully.</p><p>"+description+"</p></description>\n") 339 f.write(" <bundle type=\"appimage\">"+app+"</bundle>\n") 340 f.write(" <keywords>\n") 341 f.write(" <keyword>"+name+"</keyword>\n") 342 f.write(" <keyword>appimage</keyword>\n") 343 f.write(" </keywords>\n") 344 f.write(" <categories>\n") 345 f.write(" <category>AppImage</category>\n") 346 f.write(" <category>GTK</category>\n") 347 f.write(" </categories>\n") 348 f.write("<icon type=\"cached\">"+name+"_"+name+".png</icon>\n") 349 f.write("</component>\n") 350 f.write("</components>\n") 351 f.close() 352 semaphore.release() -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/storeManager.py
r5187 r5188 371 371 def _load_Store(self): 372 372 action='load' 373 if self.loadBundles:374 function=self._execute_class_method('loadCatalogue','appimage')375 function.execute_action('loadCatalogue')376 373 loadFunction=self._execute_class_method(action) 374 print(self.loadBundles) 377 375 self.store=loadFunction.execute_action(action,self.store,self.loadBundles) 378 376 #def _load_Store
Note: See TracChangeset
for help on using the changeset viewer.