Skip to content

Commit

Permalink
ODP-1073: Changed print statements to work in Python2 and Python3 (#1)
Browse files Browse the repository at this point in the history
* ODP-1073: Changed print statements to work in Python2 and Python3
  • Loading branch information
JeffreySmith authored and manishsinghmowall committed Jun 18, 2024
1 parent 7822376 commit b4f1f97
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from optparse import OptionParser

if os.getenv('JAVA_HOME') is None:
print "[W] ---------- JAVA_HOME environment property not defined, using java in path. ----------"
print("[W] ---------- JAVA_HOME environment property not defined, using java in path. ----------")
JAVA_BIN='java'
else:
JAVA_BIN=os.path.join(os.getenv('JAVA_HOME'),'bin','java')
print "Using Java:" + str(JAVA_BIN)
print("Using Java:" + str(JAVA_BIN))

def main():

Expand Down Expand Up @@ -54,22 +54,22 @@ def call_keystore(libpath, filepath, aliasKey, aliasValue='', getorcreate='get')
output, error = p.communicate()
statuscode = p.returncode
if statuscode == 0:
print "Alias " + aliasKey + " created successfully!"
print("Alias " + aliasKey + " created successfully!")
else :
print "Error creating Alias!! Error: " + str(error)
print("Error creating Alias!! Error: " + str(error))

elif getorcreate == 'get':
commandtorun = [JAVA_BIN, '-cp', finalLibPath, 'org.apache.ranger.credentialapi.buildks' ,'get', aliasKey, '-provider',finalFilePath]
p = Popen(commandtorun,stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, error = p.communicate()
statuscode = p.returncode
if statuscode == 0:
print "Alias : " + aliasKey + " Value : " + str(output)
print("Alias : " + aliasKey + " Value : " + str(output))
else :
print "Error getting value!! Error: " + str(error)
print("Error getting value!! Error: " + str(error))

else:
print 'Invalid Arguments!!'
print('Invalid Arguments!!')

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def process(self, input, output) :
output.write(comp.compress(StringUtil.fromBytes(buf, 0, bytes_read)))
output.write(comp.flush())
except :
print "Exception in Compress:"
print '-' * 60
print("Exception in Compress:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)
raise
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def process(self, input, output) :
break
output.write(comp.decompress(StringUtil.fromBytes(buf, 0, bytes_read)))
except :
print "Exception in Decompress:"
print '-' * 60
print("Exception in Decompress:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)
raise
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def process(self, input) :
bufferedReader = BufferedReader(reader)
self.__line = bufferedReader.readLine()
except :
print "Exception in Reader:"
print '-' * 60
print("Exception in Reader:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)
raise
finally :
if bufferedReader is not None :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def onTrigger(self, context, sessionFactory) :
session.transfer(flowfile, self.__rel_success)
session.commitAsync()
except :
print sys.exc_info()[0]
print "Exception in TestReader:"
print '-' * 60
print(sys.exc_info()[0])
print("Exception in TestReader:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)

session.rollback(true)
raise

processor = CompressFlowFile()
processor = CompressFlowFile()
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def onTrigger(self, context, sessionFactory) :
session.transfer(flowfile, self.__rel_success)
session.commitAsync()
except :
print sys.exc_info()[0]
print "Exception in TestReader:"
print '-' * 60
print(sys.exc_info()[0])
print("Exception in TestReader:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)

session.rollback(True)
raise

processor = ReadModulesPathAndStoreAsAttribute()
processor = ReadModulesPathAndStoreAsAttribute()
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def onTrigger(self, context, sessionFactory) :
session.transfer(flowfile, self.__rel_success)
session.commitAsync()
except :
print sys.exc_info()[0]
print "Exception in TestReader:"
print '-' * 60
print(sys.exc_info()[0])
print("Exception in TestReader:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)

session.rollback(True)
raise

processor = ReadContentAndStoreAsAttribute()
processor = ReadContentAndStoreAsAttribute()
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def onTrigger(self, context, sessionFactory) :
session.transfer(flowfile, self.__rel_success)
session.commitAsync()
except :
print sys.exc_info()[0]
print "Exception in TestReader:"
print '-' * 60
print(sys.exc_info()[0])
print("Exception in TestReader:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print '-' * 60
print('-' * 60)

session.rollback(true)
raise

processor = UpdateAttributes()
processor = UpdateAttributes()

0 comments on commit b4f1f97

Please sign in to comment.