Revert "[RANGER-1951] Add whitespaces for be python3 compatible, fix the byte encoding issues, and that the hash is generated from all the source files"
This reverts commit b2295a5e2e8b4848c60e6ed9929147748f5d44cb.
diff --git a/ranger-util/pom.xml b/ranger-util/pom.xml
index 7220c3d..c84ca34 100644
--- a/ranger-util/pom.xml
+++ b/ranger-util/pom.xml
@@ -50,7 +50,7 @@
<arg value="${project.basedir}/src/scripts/saveVersion.py"/>
<arg value="${project.version}"/>
<arg value="${ranger.version.shortname}"/>
- <arg value="${project.basedir}"/>
+ <arg value="${project.basedir}/target"/>
</exec>
</target>
</configuration>
diff --git a/ranger-util/src/scripts/saveVersion.py b/ranger-util/src/scripts/saveVersion.py
index acf82bf..40c0267 100644
--- a/ranger-util/src/scripts/saveVersion.py
+++ b/ranger-util/src/scripts/saveVersion.py
@@ -34,11 +34,12 @@
import platform
def isWindowsSystem():
- return 'Windows' in platform.system()
+ return 'Windows' in platform.system()
def check_output(query):
- output = subprocess.check_output(query)
- return output.decode("UTF-8")
+ p = subprocess.Popen(query, stdout=subprocess.PIPE)
+ output = p.communicate ()[0]
+ return output
def hashfile(afile, hasher, blocksize=65536):
buf = afile.read(blocksize)
@@ -60,8 +61,8 @@
dir = os.getcwd()
cwd = dir.strip('scripts')
cwd = os.path.join(cwd, "src")
- if isWindowsSystem():
- cwd = cwd.replace("\\", "/")
+ if isWindowsSystem():
+ cwd = cwd.replace("\\", "/")
if revision == "" :
query = (["git","rev-parse","HEAD"])
@@ -86,9 +87,7 @@
c = []
fileList = []
sortedList = []
- parent_dir = os.path.join(src_dir, os.pardir)
-
- for (dir, _, files) in os.walk(parent_dir):
+ for (dir, _, files) in os.walk(src_dir):
for f in files:
path = os.path.join(dir, f)
if path.endswith(".java"):
@@ -103,10 +102,9 @@
f = m +" "+ val + "\n"
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)
+ srcChecksum = hashlib.md5(''.join(c)).hexdigest()
- dir = os.path.join(src_dir,"target","gen","org","apache","ranger","common")
+ dir = os.path.join(src_dir,"gen","org","apache","ranger","common")
if not os.path.exists(dir):
os.makedirs(dir)
@@ -143,7 +141,7 @@
content = content.format(VERSION=version,SHORTVERSION=shortversion,USER=user,DATE=date,URL=url,REV=revision,BRANCH=branch,SRCCHECKSUM=srcChecksum)
des = os.path.join(dir, "package-info.java")
- f = open(des , 'w')
+ f = open(des , 'wb')
f.write(content)
f.close()