examples: python: print into stderr
authorPetr Vorel <petr.vorel@gmail.com>
Tue, 10 Mar 2015 05:18:10 +0000 (06:18 +0100)
committerThomas Haller <thaller@redhat.com>
Tue, 10 Mar 2015 11:17:59 +0000 (12:17 +0100)
https://mail.gnome.org/archives/networkmanager-list/2015-March/msg00024.html

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
examples/python/dbus/vpn.py
examples/python/gi/add_connection.py
examples/python/gi/deactivate-all.py
examples/python/gi/firewall-zone.py
examples/python/gi/update-ip4-method.py

index 8713f19..d60e470 100755 (executable)
@@ -106,7 +106,7 @@ def activate_connection(connection_path, device_path):
         sys.exit(0)
 
     def error_handler(*args):
-        print "Error activating device: %s" % args
+        sys.stderr.write("Error activating device: %s\n" % args)
         sys.exit(1)
 
     bus = dbus.SystemBus()
index bb1163d..6665099 100755 (executable)
@@ -69,7 +69,7 @@ def added_cb(client, result, data):
         client.add_connection_finish(result)
         print("The connection profile has been succesfully added to NetworkManager.")
     except Exception, e:
-        print("Error: %s" % e)
+        sys.stderr.write("Error: %s\n" % e)
     main_loop.quit()
 
 if __name__ == "__main__":
index 68f1d2d..571f3fe 100755 (executable)
@@ -77,5 +77,5 @@ if __name__ == "__main__":
                 client.deactivate_connection(ac, None)
                 sys.stdout.write("\033[32m  -> succeeded\033[0m\n")
             except Exception, e:
-               sys.stdout.write("\033[31m  -> failed\033[0m (%s)\n" % e.message)
+               sys.stderr.write("\033[31m  -> failed\033[0m (%s)\n" % e.message)
 
index ed9e591..10add3e 100755 (executable)
@@ -75,5 +75,5 @@ if __name__ == "__main__":
                 print("'%s' zone set to '%s'") % (c.get_id(), new_zone)
             break
     if not found:
-        print ("Error: connection '%s' not found.") % (con_name)
+        sys.stderr.write("Error: connection '%s' not found.\n") % (con_name)
         main_loop.quit()
index 983578c..2aa4af3 100755 (executable)
@@ -80,6 +80,6 @@ if __name__ == "__main__":
             c.commit_changes(True, None)
             print("The connection profile has been updated.")
         except Exception, e:
-            print("Error: %s" % e)
+            sys.stderr.write("Error: %s\n" % e)
         break