Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODP-1073: Changed print statements to work in Python2 and Python3 #1

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading