]> code.delx.au - bg-scripts/blobdiff - wallchanger.py
Converted to Python3
[bg-scripts] / wallchanger.py
index 8bfb69bd7b1a64949b11c59cb5bf26e46ff66869..30f1400087288ee2e888f6fed9a16ca7cd6084bd 100755 (executable)
@@ -1,11 +1,11 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 
 # Copyright 2008 Greg Darke <greg@tsukasa.net.au>
 # Copyright 2008 James Bunton <jamesbunton@fastmail.fm>
 # Licensed for distribution under the GPL version 2, check COPYING for details
 # This is a cross platform/cross window manager way to change your wallpaper
 
-import commands, sys, os, os.path, time
+import subprocess, sys, os, os.path, time
 import logging
 try:
     import PIL, PIL.Image
@@ -24,7 +24,7 @@ def set_image(filename):
             logging.warning("Failed to set background: wallchanger.set_image(%s), changer=%s", filename, changer)
 
 def check_cmd(cmd):
-    return commands.getstatusoutput(cmd)[0] == 0
+    return subprocess.getstatusoutput(cmd)[0] == 0
 
 def init(*args, **kwargs):
     """Desktop Changer factory"""
@@ -204,7 +204,7 @@ class OSXChanger(BaseChanger):
                 return False
         cmd = """osascript -e 'tell application "finder" to set desktop picture to posix file "%s"'""" % filename
         logging.debug(cmd)
-        return not commands.getstatusoutput(cmd)[0]
+        return not subprocess.getstatusoutput(cmd)[0]
 
 class WIN32Changer(BaseChanger):
     name = "Windows"
@@ -284,7 +284,7 @@ if __name__ == "__main__":
     try:
         filename = sys.argv[1]
     except:
-        print >>sys.stderr, "Usage: %s filename" % sys.argv[0]
+        print("Usage: %s filename" % sys.argv[0], file=sys.stderr)
         sys.exit(1)
 
     main(filename)