Python3 conversion
[python-seth.git] / doc / examples / daemon-example.py
index 47dff70..bb1855b 100755 (executable)
@@ -11,15 +11,17 @@ class MyDaemon(Daemon):
     def run(self):
         """Overrides Daemon().run() with actions you want to daemonize.
         MyDaemon.run() is then called within MyDaemon().start()"""
-        print "Starting Deamon!"
+        print('Starting Deamon!')  # message issued on self.stdout
         while True:
             time.sleep(1)
+            sys.stderr.write('œ unicode write test to stderr\n')
+            sys.stdout.write('write test to stdout\n')
 
     def shutdown(self):
         """Overrides Daemon().shutdown() with some clean up"""
-        print "Stopping Daemon!"
+        print("Stopping Daemon!")  # message issued on self.stdout
 
-if __name__ == "__main__":
+if __name__ == '__main__':
     daemon = MyDaemon('/tmp/daemon-example.pid',
             '/tmp/daemon.log')
     if len(sys.argv) == 2:
@@ -30,9 +32,9 @@ if __name__ == "__main__":
         elif 'restart' == sys.argv[1]:
             daemon.restart()
         else:
-            print "Unknown command"
+            print('Unknown command')
             sys.exit(2)
         sys.exit(0)
     else:
-        print "usage: %s start|stop|restart" % sys.argv[0]
+        print("usage: {} start|stop|restart".format(sys.argv[0]))
         sys.exit(2)