ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zsom...@apache.org
Subject ranger git commit: RANGER-1951: fix the script, so it works even outside a git repository
Date Fri, 27 Jul 2018 12:00:43 GMT
Repository: ranger
Updated Branches:
  refs/heads/master c219420e7 -> 4308c8aec


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


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

Branch: refs/heads/master
Commit: 4308c8aecbd7c537469475e6f456c0ab043ea931
Parents: c219420
Author: Zsombor Gegesy <zsombor@apache.org>
Authored: Thu Jul 5 23:07:57 2018 +0200
Committer: Zsombor Gegesy <zsombor@apache.org>
Committed: Fri Jul 27 13:58:39 2018 +0200

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


http://git-wip-us.apache.org/repos/asf/ranger/blob/4308c8ae/ranger-util/src/scripts/saveVersion.py
----------------------------------------------------------------------
diff --git a/ranger-util/src/scripts/saveVersion.py b/ranger-util/src/scripts/saveVersion.py
index acf82bf..0ad39ac 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,8 +37,12 @@ def isWindowsSystem():
 	return 'Windows' in platform.system()
 
 def check_output(query):
-	output = subprocess.check_output(query)
-	return output.decode("UTF-8")
+	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)
@@ -98,10 +102,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).encode('UTF-8')).hexdigest()
 	print('hash of the ' + str(len(sortedList)) + '\n\t file from: ' + parent_dir + '\n\t is
' + srcChecksum)


Mime
View raw message