Browse Source

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

Helmut Pozimski 11 năm trước cách đây
mục cha
commit
adb9b9f29a
4 tập tin đã thay đổi với 19 bổ sung17 xóa
  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
+* Python 3 is now also supported
 
 0.3
 ----

+ 1 - 1
README

@@ -10,7 +10,7 @@ see ./stov.py --help
 
 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
 
 === COPYING ===

+ 1 - 1
TODO

@@ -4,4 +4,4 @@ TODOs for 0.4:
 *Make the whole help screen translateable
 *Don't report success on deletion if the subscription didn't exist
 *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 -*-
 
+from __future__ import print_function, unicode_literals
 import sys
 import subprocess
 import os
@@ -33,18 +34,18 @@ def main():
 	try:
 		sys.argv[1]
 	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")
 		sys.exit(2)
 	if sys.argv[1] == "-h" or sys.argv[1] == "--help":
-		print """Usage: ./install.py OPTION
+		print("""Usage: ./install.py OPTION
 
 	Valid options are:
 -h or --help: Print this help screen
 $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
-you can write to it."""
+you can write to it.""")
 		sys.exit(0)
 	else:
 		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"
 					"be able to run the program but use it at your own risk!")
 	else:
-		print "Checking running python version: OK"
+		print("Checking running python version: OK")
 	try:
 		subprocess.check_call(["youtube-dl", "-h"], stdout=subprocess.PIPE)
 	except subprocess.CalledProcessError:
@@ -75,7 +76,7 @@ you can write to it."""
 						" If youtube-dl isn't found automatically, you may also enter "
 						"the path to it in the configuration file.")
 	else:
-		print "Checking for youtube-dl: OK"
+		print("Checking for youtube-dl: OK")
 	"""Create the subdirectory for the installation process"""
 	programpath = os.path.join(installpath, "stov")
 	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"""
 	try:
 		if os.access(programpath, os.F_OK) is not True:
-			os.mkdir(programpath, 0775)
+			os.mkdir(programpath, 0o775)
 		else:
-			print ("Program directory already exists, existing "
+			print("Program directory already exists, existing "
 				"files will be overwritten!")
 	except OSError:
-		print >> sys.stderr, ("Directory could not be created, "
-					"cancelling installation")
+		print("Directory could not be created, cancelling installation",
+			file=sys.stderr)
 	else:
 		for i in files:
 			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.path.join(binpath, "stov"))
 		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 "
 			"created in " + binpath + ", you should "
 			"be able to run the program by typing \"stov\"")
 	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"
 		" with it's absolute path" % programpath)
 	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")
 if __name__ == "__main__":
 	main()
 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)