summaryrefslogtreecommitdiffstats
path: root/usr/share/mageiawelcome/helpers.py
blob: cac5578f270328aa64b5f79503acb2f4a5199a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-


import csv
import os

def is_installed(name):
  return os.WEXITSTATUS(os.system('rpm -q --quiet ' + name))

  
def get_listapp():
  listapp = ''
  with open("apps.csv", 'rb') as f:
      mycsv = csv.reader(f,delimiter='|')
      mycsv.next()
      for r in mycsv:
	if (r[5] == 'false'):
	  start_btn = ""
	else:
	  start_btn = "<button class='cmd small pill green' data-run='"+ r[5] + "'><i class='icon-ok-sign'> </i> Launch</button>" 
	if (r[6] != ''):
	  label = "<span class='label red'>" + r[6] + "</span>"
	else:
	  label = ""  
	if ( is_installed(r[1]) != 0):# NOT INSTALLED
	  listapp += "<li class='" + r[3] +"' id='" + r[0] + "'><img class=icon src=img/" + r[0] + ".png /><div class='chkbox'><input type='checkbox' datasrc='" + r[1] +"'></div> \
<h6>" + r[2] + "</h6><p class=description>" + r[4] + "</p>" + start_btn  + label + "<button class='inst small pill' data-rpm='" + r[1] + "'><i class='icon-circle-arrow-down'> </i> Install</button></li>"
	else: # INSTALLED
	  listapp += "<li class='urpme " + r[3] +"' id='" + r[0] + "'><img class=icon src=img/" + r[0] + ".png /><div class='chkbox'></div> \
<h6>" + r[2] + "</h6><p class=description>" + r[4] + "</p>" + start_btn + label + "<button class='uninst small pill red' data-rpm='" + r[1] + "'><i class='icon-minus-sign'> </i> remove</button></li>"
  return listapp