mozDefrag/libMozDefrag.py

71 lines
2.1 KiB
Python
Raw Normal View History

2017-09-28 23:41:34 +00:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
2017-10-04 19:42:08 +00:00
libMozDefrag
2017-09-28 23:41:34 +00:00
Author : Francois B (Makoto)
Licence : GPL3
"""
import subprocess
2017-10-04 19:42:08 +00:00
__libVer__ = "0.1"
2017-09-28 23:41:34 +00:00
def mozDefragFirefox(): # Firefox defrag
cmd2exec = "for f in ~/.mozilla/firefox/*/*.sqlite;"
cmd2exec += "do sqlite3 $f 'VACUUM;';"
cmd2exec += "done"
2017-10-01 01:01:57 +00:00
cmdOutput = str(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
2017-09-28 23:41:34 +00:00
return cmdOutput
def mozDefragThunderbird(): # Thunderbird defrag
cmd2exec = "for f in ~/.thunderbird/*/*.sqlite;"
cmd2exec += "do sqlite3 $f 'VACUUM;';"
cmd2exec += "done"
cmdOutput = str(subprocess.check_output(cmd2exec,
2017-09-29 16:32:34 +00:00
shell=True).decode("utf-8"))
2017-09-28 23:41:34 +00:00
return cmdOutput
def mozFirefoxIsInstalled(): # check if Firefox is installed
cmd2exec = "if which firefox >/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;"
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 mozFirefoxIsRunning(): # check if Firefox is running
cmd2exec = "ps auxw | grep -i firefox | 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"
cmdOutput = int(subprocess.check_output(cmd2exec,
shell=True).decode("utf-8"))
return 1 if (cmdOutput > 0) else 0