Permalink
Browse files

Provide a DBus service file to auto-start the update daemon.

 - Don't start the update daemon when starting Khweeteur.
 - Add a --no-fork option to the update daemon.  If set, don't fork.
 - Install the script and the service file when building the package.
  • Loading branch information...
1 parent b0b6e27 commit 92f73180f7b80336e3762fa2de9b6a6230079f6b @nwalfield nwalfield committed Oct 8, 2011
Showing with 22 additions and 35 deletions.
  1. +3 −0 khweeteur-daemon.service
  2. +0 −15 khweeteur/__init__.py
  3. +14 −4 khweeteur/daemon.py
  4. +0 −14 khweeteur/qwidget_gui.py
  5. +3 −0 scripts/khweeteur-daemon
  6. +2 −2 setup.py
View
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=net.khertan.khweeteur.daemon
+Exec=/usr/bin/khweeteur-daemon start --no-fork
View
@@ -42,22 +42,7 @@ def takeScreenShot(app):
QPixmap.grabWidget(app.win).save(pvr, 'png') # tell it to grab only your self.centralwidget screen, which is just window screen without the menu status bar on top.
if __name__ == '__main__':
- from subprocess import Popen
- import os.path
- Popen(['/usr/bin/python',
- os.path.join(os.path.dirname(__file__),
- 'daemon.py'),
- 'start'])
install_excepthook()
app = Khweeteur()
app.exec_()
takeScreenShot(app)
- from PySide.QtCore import QSettings
- settings = QSettings("Khertan Software", "Khweeteur")
- if settings.contains('useDaemon'):
- print settings.value('useDaemon')
- if settings.value('useDaemon') != '2':
- print 'Stop daemon'
- #use system to wait the exec
- os.system('/usr/bin/python ' + \
- os.path.join(os.path.dirname(__file__), 'daemon.py') + ' stop')
View
@@ -752,20 +752,27 @@ def athread_end(self):
return self.thread_exited(self.sender())
-if __name__ == '__main__':
+def main():
install_excepthook(__version__)
def usage(exit_status=2):
- print ('usage: %s start|stop|restart|startfromprefs|debug'
+ print ('usage: %s start|stop|restart|startfromprefs|debug [--no-fork]'
% sys.argv[0])
sys.exit(2)
+ detach_process = None
+ redirect_output = True
+
+ if sys.argv[-1] == '--no-fork':
+ del sys.argv[-1]
+ detach_process = False
+
if len(sys.argv) != 2:
usage()
- detach_process = None
if sys.argv[1] == 'debug':
detach_process = False
+ redirect_output = False
sys.argv[1] = 'start'
if 'startfromprefs' == sys.argv[1]:
@@ -777,7 +784,7 @@ def usage(exit_status=2):
if sys.argv[1] in ['start', 'stop', 'restart']:
khweeteurdaemon = KhweeteurDaemon()
- if detach_process is None:
+ if redirect_output:
khweeteurdaemon.stdin_path = "/dev/null"
khweeteurdaemon.stdout_path = os.path.expanduser(
'~/.khweeteur.log.out')
@@ -799,3 +806,6 @@ def usage(exit_status=2):
logging.error('Unknown command')
print "Unknown command: '%s'" % (sys.argv[1],)
usage(2)
+
+if __name__ == '__main__':
+ main()
View
@@ -1331,19 +1331,5 @@ def geolocUpdated(self, update):
if __name__ == '__main__':
- from subprocess import Popen
- Popen(['/usr/bin/python', os.path.join(os.path.dirname(__file__),
- 'daemon.py'), 'start'])
app = Khweeteur()
app.exec_()
- settings = QSettings('Khertan Software', 'Khweeteur')
- if settings.contains('useDaemon'):
- print "useDaemon:", settings.value('useDaemon')
- if settings.value('useDaemon') != '2':
- print 'Stopping daemon'
-
- # use system to wait the exec
-
- os.system('/usr/bin/python '
- + os.path.join(os.path.dirname(__file__), 'daemon.py')
- + ' stop')
View
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+python /usr/lib/python2.5/site-packages/khweeteur/daemon.py ${1+"$@"}
View
@@ -36,14 +36,14 @@
url='http://www.khertan.net/khweeteur',
packages= ['khweeteur','khweeteur.oauth', 'khweeteur.oauth2'],
package_data = {'khweeteur': ['icons/*.png']},
- data_files=[('/usr/share/dbus-1/services', ['khweeteur.service']),
+ data_files=[('/usr/share/dbus-1/services', ['khweeteur.service', 'khweeteur-daemon.service']),
('/usr/share/applications/hildon/', ['khweeteur.desktop']),
('/usr/share/pixmaps', ['khweeteur.png','khweeteur_64.png','khweeteur_32.png']),
('/usr/share/icons/hicolor/128x128/apps', ['khweeteur.png']),
('/usr/share/icons/hicolor/64x64/apps', ['icons/hicolor/64x64/apps/khweeteur.png']),
('/usr/share/icons/hicolor/32x32/apps', ['icons/hicolor/32x32/apps/khweeteur.png']),
('/etc/event.d', ['khweeteurd']),],
- scripts=['scripts/khweeteur'],
+ scripts=['scripts/khweeteur', 'scripts/khweeteur-daemon'],
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: X11 Applications :: Qt",

0 comments on commit 92f7318

Please sign in to comment.