Commits

Josh VanderLinden  committed d837928

Handling errors with the dbus stuff

  • Participants
  • Parent commits 498891e

Comments (0)

Files changed (2)

 # Maintainer: Josh VanderLinden <arch@cloudlery.com>
 pkgname=zedify
 pkgver=20130513
-pkgrel=4
+pkgrel=5
 pkgdesc="Deliver message notifications to remote machines"
 arch=('any')
 url="http://bitbucket.org/codekoala/zedify"
 license=('MIT')
-depends=('python' 'python-pyzmq' 'libnotify')
+depends=('python' 'python-pyzmq' 'libnotify' 'python-sh')
 optdepends=(
   'weechat: fabulous IRC client'
   'dunst: lightweight notifications'

File zedify/config.py

     config[section] = DotDict(_c.items(section))
 
 
+try:
 # get information about dbus for the notifications
-dbus_pid = int(sh.pgrep('dbus-daemon .* --nofork',
-                        u=os.getlogin(),
-                        f=True,
-                        a=True).split()[0])
-env = open('/proc/{}/environ'.format(dbus_pid)).read().split('\0')
-dbus_env = dict(l.split('=', 1) for l in env
-                if l.startswith('DBUS'))
-os.environ.update(dbus_env)
+    dbus_pid = int(sh.pgrep('dbus-daemon .* --nofork',
+                            u=os.getlogin(),
+                            f=True,
+                            a=True).split()[0])
+except:
+    # probably not running X for notifications
+    pass
+else:
+    env = open('/proc/{}/environ'.format(dbus_pid)).read().split('\0')
+    dbus_env = dict(l.split('=', 1) for l in env
+                    if l.startswith('DBUS'))
+    os.environ.update(dbus_env)