amirivija / porting-advisor-for-graviton

Apache License 2.0
0 stars 0 forks source link

When the pre-requisite Python 3.10 or greater isn't installed running the porting advisor fails without proper error #1

Open amirivija opened 1 year ago

amirivija commented 1 year ago

Describe the bug

When the pre-requisite Python 3.10 or greater isn't installed running the porting advisor fails with the following message.

Traceback (most recent call last): File "/Users/amirisev/Documents/code/graviton/porting-advisor-for-graviton/src/porting-advisor.py", line 23, in main() File "/Users/amirisev/Documents/code/graviton/porting-advisor-for-graviton/src/advisor/init.py", line 26, in main from .main import main as real_main File "/Users/amirisev/Documents/code/graviton/porting-advisor-for-graviton/src/advisor/main.py", line 28, in from .reports.report_factory import ReportOutputFormat, ReportFactory File "/Users/amirisev/Documents/code/graviton/porting-advisor-for-graviton/src/advisor/reports/report_factory.py", line 57 match output_format: ^ SyntaxError: invalid syntax

This is because structural pattern matching : match is available only 3.10 and above. https://docs.python.org/3/whatsnew/3.10.html#pep-634-structural-pattern-matching

Expected behavior

I'd expect the advisor to validate the python version, and error out informing the user to update the python version.

Steps to Reproduce

Steps to reproduce the behavior: With Python 3.19 python -V
Python 3.9.6

  1. Run with parameters '...' python3 src/porting-advisor.py ~/Documents/code/src/
  2. Open report...
  3. Scroll down to '...'
  4. See error

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information)

uname -a Darwin 88665a58263e.ant.amazon.com 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64

Additional context

Add any other context about the problem here.

amirivija commented 1 year ago

Potential fix is to check the Python version

def check_python_version(required_version): current_version = sys.version_info if current_version[0] == required_version[0] and current_version[1] >= required_version[1]: pass
else:
print( "[%s] - Error: Graviton Porting Advisor requires Python version to be be %d.%d or greater\n" % (sys.argv[0], required_version[0], required_version[1]) ) sys.exit(2)
return 0