23
24
def __init__(self, updateCallback):
24
25
self.updateCallback = updateCallback
32
def updateStatus(self, uri, descr, shortDescr, status):
35
def update_status_full(self, uri, descr, shortDescr, status, fileSize,
40
28
self.updateCallback(self.percent)
54
43
if self.last >= self.percent:
58
self.updateCallback(self.status, None)
60
self.updateCallback(self.status, self.percent)
46
self.updateCallback(self.status, self.percent)
61
47
self.last = self.percent
63
49
def finishUpdate(self):
64
self.updateCallback("__FINISHED__", self.percent)
50
if not self.doNotFinish:
51
self.updateCallback("__FINISHED__", self.percent)
67
54
class InstallBumblebeeThread(threading.Thread):
69
def __init__(self, downloadCb, installCb):
56
def __init__(self, downloadCb, installCb, removeFirst=False):
70
57
super(InstallBumblebeeThread, self).__init__()
58
self.removeFirst = removeFirst
71
59
self.downloadCb = downloadCb
72
60
self.installCb = installCb
61
self.softProp = SoftwareProperties()
75
64
cache = apt.Cache()
76
# self.softProp = SoftwareProperties()
77
# ppa = 'ppa:bumblebee/stable'
78
# self.softProp.add_source_from_line(ppa)
79
# self.softProp.sourceslist.save()
81
# self.aptCache.update(apt.progress.TextFetchProgress())
68
cache['bumblebee'].markDelete()
69
cache.commit(UpdateFetchProgress(self.downloadCb), TextInstallProgress(self.installCb, True))
72
ppa = 'ppa:bumblebee/stable'
73
self.softProp.remove_source(ppa)
74
self.softProp.add_source_from_line(ppa)
75
self.softProp.sourceslist.save()
77
cache.update(UpdateFetchProgress(self.downloadCb))
84
cache['bumblebee'].mark_install()
85
cache['bumblebee-nvidia'].mark_install()
86
cache['linux-headers-generic'].mark_install()
87
cache['primus'].mark_install()
88
cache.commit(UpdateFetchProgress(self.downloadCb), TextInstallProgress(self.installCb))
80
cache['bumblebee'].markInstall()
81
cache['bumblebee-nvidia'].markInstall()
82
cache['linux-headers-generic'].markInstall()
83
cache['primus'].markInstall()
84
cache.commit(UpdateFetchProgress(self.downloadCb), TextInstallProgress(self.installCb, False))
92
88
class AptHelper(object):
96
self.softProp = SoftwareProperties()
98
90
def checkBumblebeeInstalled(self):
100
92
cache = apt.Cache()
101
if platform.linux_distribution()[0].lower() == "ubuntu":
103
if cache['bumblebee'].is_installed:
95
if cache['bumblebee'].isInstalled:
113
103
downloadCb: (percent)
114
104
installCb: (msg, percent)
116
def installBumblebee(self, downloadCb, installCb):
106
def installBumblebee(self, downloadCb, installCb, removeFirst=False):
118
thread = InstallBumblebeeThread(downloadCb, installCb)
108
thread = InstallBumblebeeThread(removeFirst, downloadCb, installCb)