summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-12 08:49:13 +0900
committerkali <kali@leap.se>2012-09-12 08:49:13 +0900
commitddd11604a5ae376ba27f70c9eb9a6971e749b1f9 (patch)
treec6c043af23c6dfbebfb0bb8437a68fd1e25305c5
parent18109193b239be6e7ecc4c2d07c9c999e33081f8 (diff)
pep8
-rw-r--r--src/leap/baseapp/dialogs.py1
-rw-r--r--src/leap/baseapp/unitychecks.py45
2 files changed, 32 insertions, 14 deletions
diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py
index af531154..3cb539cf 100644
--- a/src/leap/baseapp/dialogs.py
+++ b/src/leap/baseapp/dialogs.py
@@ -32,7 +32,6 @@ class ErrorDialog(QDialog):
# closing the dialog. we can pass that
# in the constructor
-
def criticalMessage(self, msg, label):
msgBox = QMessageBox(QMessageBox.Critical,
"QMessageBox.critical()", msg,
diff --git a/src/leap/baseapp/unitychecks.py b/src/leap/baseapp/unitychecks.py
index aa644c5f..72c9ee6f 100644
--- a/src/leap/baseapp/unitychecks.py
+++ b/src/leap/baseapp/unitychecks.py
@@ -17,9 +17,14 @@ logger.setLevel('DEBUG')
from leap.base.constants import APP_NAME
from leap.baseapp.dialogs import ErrorDialog
-get_whitelist = lambda: eval(Popen(['gsettings', 'get', 'com.canonical.Unity.Panel', 'systray-whitelist'], stdout=PIPE).communicate()[0])
+get_whitelist = lambda: eval(
+ Popen(['gsettings', 'get', 'com.canonical.Unity.Panel',
+ 'systray-whitelist'], stdout=PIPE).communicate()[0])
+
+set_whitelist = lambda ls: Popen(
+ ['gsettings', 'set',
+ 'com.canonical.Unity.Panel', 'systray-whitelist', repr(ls)])
-set_whitelist = lambda ls: Popen(['gsettings', 'set', 'com.canonical.Unity.Panel', 'systray-whitelist', repr(ls)])
def add_to_whitelist():
ls = get_whitelist()
@@ -27,21 +32,29 @@ def add_to_whitelist():
ls.append(APP_NAME)
set_whitelist(ls)
+
def remove_from_whitelist():
ls = get_whitelist()
if APP_NAME in ls:
ls.remove(APP_NAME)
set_whitelist(ls)
+
def is_unity_running():
- (output, error) = Popen('ps aux | grep [u]nity-panel-service', stdout=PIPE, shell=True).communicate()
+ #XXX use psutil instead
+ (output, error) = Popen(
+ 'ps aux | grep [u]nity-panel-service',
+ stdout=PIPE, shell=True).communicate()
output = bool(str(output))
if not output:
- (output, error) = Popen('ps aux | grep [u]nity-2d-panel', stdout=PIPE, shell=True).communicate()
+ (output, error) = Popen(
+ 'ps aux | grep [u]nity-2d-panel',
+ stdout=PIPE, shell=True).communicate()
output = bool(str(output))
return output
-def need_to_add():
+
+def need_to_add():
if is_unity_running():
wlist = get_whitelist()
if not (APP_NAME in wlist or 'all' in wlist):
@@ -49,11 +62,17 @@ def need_to_add():
return True
return False
+
def add_and_restart():
add_to_whitelist()
Popen('LANG=en_US.UTF-8 unity', shell=True)
-MSG = "Seems that you are using a Unity desktop and Leap is not allowed to use Tray icon. Press OK to add Leap to Unity's white list and then restart Unity"
+
+MSG = ("Seems that you are using a Unity desktop "
+ "and %s is not allowed to use Tray icon. "
+ "Press OK to add %s to Unity's white list "
+ "and then restart Unity" % (APP_NAME, APP_NAME))
+
def do_check():
if platform.system() == "Linux" and need_to_add():
@@ -63,17 +82,17 @@ def do_check():
"add to systray?",
add_and_restart)
-if __name__=='__main__':
- if len(sys.argv)>1:
+
+if __name__ == '__main__':
+ if len(sys.argv) > 1:
cmd = sys.argv[1]
- if cmd=='add':
+ if cmd == 'add':
add_to_whitelist()
- elif cmd=='rm':
+ elif cmd == 'rm':
remove_from_whitelist()
- elif cmd=='print':
+ elif cmd == 'print':
print get_whitelist()
- elif cmd=="check":
+ elif cmd == "check":
from PyQt4.QtGui import QApplication
app = QApplication(sys.argv)
do_check()
-