Browse Source

Changed install.py to also work with python 3.x

Helmut Pozimski 11 years ago
parent
commit
adb9b9f29a
4 changed files with 19 additions and 17 deletions
  1. 1 0
      CHANGELOG
  2. 1 1
      README
  3. 1 1
      TODO
  4. 16 15
      install.py

+ 1 - 0
CHANGELOG

@@ -2,6 +2,7 @@
 ----
 ----
 
 
 * Added title checking to filter unrelated results from subscriptions with search strings
 * Added title checking to filter unrelated results from subscriptions with search strings
+* Python 3 is now also supported
 
 
 0.3
 0.3
 ----
 ----

+ 1 - 1
README

@@ -10,7 +10,7 @@ see ./stov.py --help
 
 
 stov depends on the following software to be installed:
 stov depends on the following software to be installed:
 
 
-	* Python 2.6 or higher (it might also work with earlier versions, but hasn't been tested, python 3 is not supported yet)
+	* Python 2.6 or higher (it might also work with earlier versions, but hasn't been tested, python 3.x should work)
 	* youtube-dl (get it from http://rg3.github.com/youtube-dl/ if you don't have it yet
 	* youtube-dl (get it from http://rg3.github.com/youtube-dl/ if you don't have it yet
 
 
 === COPYING ===
 === COPYING ===

+ 1 - 1
TODO

@@ -4,4 +4,4 @@ TODOs for 0.4:
 *Make the whole help screen translateable
 *Make the whole help screen translateable
 *Don't report success on deletion if the subscription didn't exist
 *Don't report success on deletion if the subscription didn't exist
 *Correctly catch signals
 *Correctly catch signals
-*Full compability with python 3
+*Full compability with python 3 (mostly done)

+ 16 - 15
install.py

@@ -17,6 +17,7 @@
 
 
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
 
 
+from __future__ import print_function, unicode_literals
 import sys
 import sys
 import subprocess
 import subprocess
 import os
 import os
@@ -33,18 +34,18 @@ def main():
 	try:
 	try:
 		sys.argv[1]
 		sys.argv[1]
 	except IndexError:
 	except IndexError:
-		print ("No argument given, please give the path to install the program to"
+		print("No argument given, please give the path to install the program to"
 			" or --help")
 			" or --help")
 		sys.exit(2)
 		sys.exit(2)
 	if sys.argv[1] == "-h" or sys.argv[1] == "--help":
 	if sys.argv[1] == "-h" or sys.argv[1] == "--help":
-		print """Usage: ./install.py OPTION
+		print("""Usage: ./install.py OPTION
 
 
 	Valid options are:
 	Valid options are:
 -h or --help: Print this help screen
 -h or --help: Print this help screen
 $PATH: Define the Path to install to, e.g. /usr/local or /usr/share
 $PATH: Define the Path to install to, e.g. /usr/local or /usr/share
 
 
 If installation fails, please check if the given path is correct and
 If installation fails, please check if the given path is correct and
-you can write to it."""
+you can write to it.""")
 		sys.exit(0)
 		sys.exit(0)
 	else:
 	else:
 		installpath = sys.argv[1]
 		installpath = sys.argv[1]
@@ -64,7 +65,7 @@ you can write to it."""
 		print >> sys.stderr, ("Your python version is below 2.6! You might still"
 		print >> sys.stderr, ("Your python version is below 2.6! You might still"
 					"be able to run the program but use it at your own risk!")
 					"be able to run the program but use it at your own risk!")
 	else:
 	else:
-		print "Checking running python version: OK"
+		print("Checking running python version: OK")
 	try:
 	try:
 		subprocess.check_call(["youtube-dl", "-h"], stdout=subprocess.PIPE)
 		subprocess.check_call(["youtube-dl", "-h"], stdout=subprocess.PIPE)
 	except subprocess.CalledProcessError:
 	except subprocess.CalledProcessError:
@@ -75,7 +76,7 @@ you can write to it."""
 						" If youtube-dl isn't found automatically, you may also enter "
 						" If youtube-dl isn't found automatically, you may also enter "
 						"the path to it in the configuration file.")
 						"the path to it in the configuration file.")
 	else:
 	else:
-		print "Checking for youtube-dl: OK"
+		print("Checking for youtube-dl: OK")
 	"""Create the subdirectory for the installation process"""
 	"""Create the subdirectory for the installation process"""
 	programpath = os.path.join(installpath, "stov")
 	programpath = os.path.join(installpath, "stov")
 	files = ["stov.py", "subscription.py", "youtube.py", "configuration.py",
 	files = ["stov.py", "subscription.py", "youtube.py", "configuration.py",
@@ -85,13 +86,13 @@ you can write to it."""
 	"""Start the installation process by copying files into the directory"""
 	"""Start the installation process by copying files into the directory"""
 	try:
 	try:
 		if os.access(programpath, os.F_OK) is not True:
 		if os.access(programpath, os.F_OK) is not True:
-			os.mkdir(programpath, 0775)
+			os.mkdir(programpath, 0o775)
 		else:
 		else:
-			print ("Program directory already exists, existing "
+			print("Program directory already exists, existing "
 				"files will be overwritten!")
 				"files will be overwritten!")
 	except OSError:
 	except OSError:
-		print >> sys.stderr, ("Directory could not be created, "
-					"cancelling installation")
+		print("Directory could not be created, cancelling installation",
+			file=sys.stderr)
 	else:
 	else:
 		for i in files:
 		for i in files:
 			sys.stdout.write("Copying file %s into program directory: " % i)
 			sys.stdout.write("Copying file %s into program directory: " % i)
@@ -120,20 +121,20 @@ you can write to it."""
 			os.symlink(os.path.join(programpath, "stov.py"),
 			os.symlink(os.path.join(programpath, "stov.py"),
 				os.path.join(binpath, "stov"))
 				os.path.join(binpath, "stov"))
 		except OSError:
 		except OSError:
-			print "Symlink in bin-directory already exists"
-		print ("stov has been installed successfully to "
+			print("Symlink in bin-directory already exists")
+		print("stov has been installed successfully to "
 			+ programpath + " and a symlink has been "
 			+ programpath + " and a symlink has been "
 			"created in " + binpath + ", you should "
 			"created in " + binpath + ", you should "
 			"be able to run the program by typing \"stov\"")
 			"be able to run the program by typing \"stov\"")
 	elif installation_success is True:
 	elif installation_success is True:
-		print ("stov has been installed successfully to %s but the installer "
+		print("stov has been installed successfully to %s but the installer "
 		"couldn't find a suitable bin directory, you need to call stov.py"
 		"couldn't find a suitable bin directory, you need to call stov.py"
 		" with it's absolute path" % programpath)
 		" with it's absolute path" % programpath)
 	else:
 	else:
-		print ("One or more installation steps failed. Please check this manually "
+		print("One or more installation steps failed. Please check this manually "
 			"and try again")
 			"and try again")
 if __name__ == "__main__":
 if __name__ == "__main__":
 	main()
 	main()
 else:
 else:
-	print >> sys.stderr, ("This script needs to run on command line, "
-				"please do not import it")
+	print("This script needs to run on command line, please do not import it",
+		file=sys.stderr)