reindex is added alongside vaccum + firefox-trunk (Nightly) support added

This commit is contained in:
Francois B 2017-10-23 22:35:54 +02:00
parent c1f0bad041
commit 1a6d2030ac
5 changed files with 627 additions and 560 deletions

View file

@ -15,7 +15,17 @@ __libVer__ = "0.1"
def mozDefragFirefox(): # Firefox defrag
cmd2exec = "for f in ~/.mozilla/firefox/*/*.sqlite;"
cmd2exec += "do sqlite3 $f 'VACUUM;';"
cmd2exec += "do sqlite3 $f 'VACUUM; REINDEX;';"
cmd2exec += "done"
cmdOutput = str(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
return cmdOutput
def mozDefragFirefoxTrunk(): # Firefox trunk defrag
cmd2exec = "for f in ~/.mozilla/firefox-trunk/*/*.sqlite;"
cmd2exec += "do sqlite3 $f 'VACUUM; REINDEX;';"
cmd2exec += "done"
cmdOutput = str(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
@ -25,7 +35,7 @@ def mozDefragFirefox(): # Firefox defrag
def mozDefragThunderbird(): # Thunderbird defrag
cmd2exec = "for f in ~/.thunderbird/*/*.sqlite;"
cmd2exec += "do sqlite3 $f 'VACUUM;';"
cmd2exec += "do sqlite3 $f 'VACUUM; REINDEX;';"
cmd2exec += "done"
cmdOutput = str(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
@ -43,6 +53,17 @@ def mozFirefoxIsInstalled(): # check if Firefox is installed
return 1 if (cmdOutput > 0) else 0
def mozFirefoxTrunkIsInstalled(): # check if Firefox trunk is installed
cmd2exec = "if which firefox-trunk >/dev/null;"
cmd2exec += "then echo 1;"
cmd2exec += "else echo 0;"
cmd2exec += "fi"
cmdOutput = int(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
return 1 if (cmdOutput > 0) else 0
def mozThunderbirdIsInstalled(): # check if Thunderbird is installed
cmd2exec = "if which thunderbird >/dev/null;"
@ -62,6 +83,14 @@ def mozFirefoxIsRunning(): # check if Firefox is running
return 1 if (cmdOutput > 0) else 0
def mozFirefoxTrunkIsRunning(): # check if Firefox trunk is running
cmd2exec = "ps auxw | grep -i firefox-trunk | grep -v grep | wc -l"
cmdOutput = int(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
return 1 if (cmdOutput > 0) else 0
def mozThunderbirdIsRunning(): # check if Thunderbird is running
cmd2exec = "ps auxw | grep -i thunderbird | grep -v grep | wc -l"

View file

@ -58,6 +58,12 @@ class Ui_mozDefragMainWindow(QtWidgets.QMainWindow, # --- Main ---------------
self.logTextEdit.append("> Firefox defrag done")
else:
self.logTextEdit.append("> Close Firefox and try again")
if self.checkBoxFirefoxTrunk.isChecked():
if not mozFirefoxTrunkIsRunning():
mozDefragFirefoxTrunk()
self.logTextEdit.append("> Firefox Nightly defrag done")
else:
self.logTextEdit.append("> Close Firefox Nightly and try again")
if self.checkBoxThunderbird.isChecked():
if not mozThunderbirdIsRunning():
mozDefragThunderbird()
@ -78,6 +84,11 @@ class Ui_mozDefragMainWindow(QtWidgets.QMainWindow, # --- Main ---------------
self.checkBoxFirefox.setChecked(True)
else:
self.checkBoxFirefox.setDisabled(True)
if mozFirefoxTrunkIsInstalled():
self.checkBoxFirefoxTrunk.setEnabled(True)
self.checkBoxFirefoxTrunk.setChecked(True)
else:
self.checkBoxFirefoxTrunk.setDisabled(True)
if mozThunderbirdIsInstalled():
self.checkBoxThunderbird.setEnabled(True)
self.checkBoxThunderbird.setChecked(True)

View file

@ -12,7 +12,7 @@ class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(395, 376)
MainWindow.resize(395, 383)
MainWindow.setAutoFillBackground(False)
MainWindow.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.Belgium))
self.centralwidget = QtWidgets.QWidget(MainWindow)
@ -23,28 +23,38 @@ class Ui_MainWindow(object):
self.logo_header.setPixmap(QtGui.QPixmap(":/pictures/pic/logo_header.jpg"))
self.logo_header.setObjectName("logo_header")
self.aboutButton = QtWidgets.QPushButton(self.centralwidget)
self.aboutButton.setGeometry(QtCore.QRect(10, 330, 112, 31))
self.aboutButton.setGeometry(QtCore.QRect(10, 340, 112, 31))
self.aboutButton.setObjectName("aboutButton")
self.defragAllButton = QtWidgets.QPushButton(self.centralwidget)
self.defragAllButton.setGeometry(QtCore.QRect(270, 330, 112, 31))
self.defragAllButton.setGeometry(QtCore.QRect(270, 340, 112, 31))
self.defragAllButton.setDefault(False)
self.defragAllButton.setObjectName("defragAllButton")
self.logTextEdit = QtWidgets.QTextEdit(self.centralwidget)
self.logTextEdit.setGeometry(QtCore.QRect(10, 210, 371, 111))
self.logTextEdit.setReadOnly(True)
self.logTextEdit.setObjectName("logTextEdit")
self.layoutWidget = QtWidgets.QWidget(self.centralwidget)
self.layoutWidget.setGeometry(QtCore.QRect(20, 130, 141, 71))
self.layoutWidget.setGeometry(QtCore.QRect(20, 130, 141, 80))
self.layoutWidget.setObjectName("layoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
self.verticalLayout.setObjectName("verticalLayout")
self.checkBoxThunderbird = QtWidgets.QCheckBox(self.layoutWidget)
self.checkBoxThunderbird.setObjectName("checkBoxThunderbird")
self.verticalLayout.addWidget(self.checkBoxThunderbird)
self.checkBoxFirefoxTrunk = QtWidgets.QCheckBox(self.layoutWidget)
self.checkBoxFirefoxTrunk.setEnabled(True)
self.checkBoxFirefoxTrunk.setObjectName("checkBoxFirefoxTrunk")
self.verticalLayout.addWidget(self.checkBoxFirefoxTrunk)
self.checkBoxFirefox = QtWidgets.QCheckBox(self.layoutWidget)
self.checkBoxFirefox.setEnabled(True)
self.checkBoxFirefox.setObjectName("checkBoxFirefox")
self.verticalLayout.addWidget(self.checkBoxFirefox)
self.logTextEdit = QtWidgets.QTextEdit(self.centralwidget)
self.logTextEdit.setGeometry(QtCore.QRect(10, 220, 371, 111))
self.logTextEdit.setReadOnly(True)
self.logTextEdit.setObjectName("logTextEdit")
self.logo_header.raise_()
self.aboutButton.raise_()
self.defragAllButton.raise_()
self.logTextEdit.raise_()
self.layoutWidget.raise_()
self.logTextEdit.raise_()
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
@ -56,6 +66,7 @@ class Ui_MainWindow(object):
self.aboutButton.setText(_translate("MainWindow", "About"))
self.defragAllButton.setText(_translate("MainWindow", "Defrag"))
self.checkBoxThunderbird.setText(_translate("MainWindow", "Thunderbird"))
self.checkBoxFirefoxTrunk.setText(_translate("MainWindow", "Firefox Nightly"))
self.checkBoxFirefox.setText(_translate("MainWindow", "Firefox"))
import res_pics_rc

View file

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>395</width>
<height>376</height>
<height>383</height>
</rect>
</property>
<property name="windowTitle">
@ -43,7 +43,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>330</y>
<y>340</y>
<width>112</width>
<height>31</height>
</rect>
@ -56,7 +56,7 @@
<property name="geometry">
<rect>
<x>270</x>
<y>330</y>
<y>340</y>
<width>112</width>
<height>31</height>
</rect>
@ -68,26 +68,13 @@
<bool>false</bool>
</property>
</widget>
<widget class="QTextEdit" name="logTextEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>371</width>
<height>111</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>141</width>
<height>71</height>
<height>80</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -98,6 +85,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFirefoxTrunk">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Firefox Nightly</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFirefox">
<property name="enabled">
@ -110,6 +107,25 @@
</item>
</layout>
</widget>
<widget class="QTextEdit" name="logTextEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>371</width>
<height>111</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<zorder>logo_header</zorder>
<zorder>aboutButton</zorder>
<zorder>defragAllButton</zorder>
<zorder>logTextEdit</zorder>
<zorder>layoutWidget</zorder>
<zorder>logTextEdit</zorder>
</widget>
</widget>
<resources>

File diff suppressed because it is too large Load diff