You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by me...@apache.org on 2018/09/04 12:58:14 UTC

[04/28] ranger git commit: RANGER-1951: fix the script, so it works even outside a git repository

RANGER-1951: fix the script, so it works even outside a git repository

Conflicts:
	ranger-util/src/scripts/saveVersion.py


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/d3c10fc7
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/d3c10fc7
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/d3c10fc7

Branch: refs/heads/ranger-1.1
Commit: d3c10fc7c8fcd8a8e10355f82bf6522da7975fdd
Parents: bfc1f19
Author: Zsombor Gegesy <zs...@apache.org>
Authored: Thu Jul 5 23:07:57 2018 +0200
Committer: Mehul Parikh <me...@apache.org>
Committed: Tue Sep 4 11:22:25 2018 +0530

----------------------------------------------------------------------
 ranger-util/src/scripts/saveVersion.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/d3c10fc7/ranger-util/src/scripts/saveVersion.py
----------------------------------------------------------------------
diff --git a/ranger-util/src/scripts/saveVersion.py b/ranger-util/src/scripts/saveVersion.py
index 40c0267..cceea41 100644
--- a/ranger-util/src/scripts/saveVersion.py
+++ b/ranger-util/src/scripts/saveVersion.py
@@ -29,7 +29,7 @@ import datetime
 import getpass
 import socket
 import subprocess
-from subprocess import Popen,PIPE
+from subprocess import Popen,PIPE,CalledProcessError
 from time import gmtime, strftime
 import platform
 
@@ -37,9 +37,12 @@ def isWindowsSystem():
     return 'Windows' in platform.system()
 
 def check_output(query):
-	p = subprocess.Popen(query, stdout=subprocess.PIPE)
-	output = p.communicate ()[0]
-	return output
+	try:
+		output = subprocess.check_output(query)
+		return output.decode("UTF-8")
+	except CalledProcessError:
+		# Not a git repository, or no git is installed
+		return ''
 
 def hashfile(afile, hasher, blocksize=65536):
 	buf = afile.read(blocksize)
@@ -97,10 +100,10 @@ def main():
 				pass
 
 	sortedList = sorted(fileList, key = lambda x: x[:-4])
-	for i, val in enumerate(sortedList):
+	for _, val in enumerate(sortedList):
 		m = hashfile(open(val,'rb'), hashlib.md5())
 		f = m +"  "+ val + "\n"
-		c.append(f);
+		c.append(f)
 
 	srcChecksum = hashlib.md5(''.join(c)).hexdigest()