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

AttributeError: 'int' object has no attribute 'isdigit' #241

Open
PlanetB-rgb opened this issue Mar 5, 2024 · 1 comment
Open

AttributeError: 'int' object has no attribute 'isdigit' #241

PlanetB-rgb opened this issue Mar 5, 2024 · 1 comment

Comments

@PlanetB-rgb
Copy link

PlanetB-rgb commented Mar 5, 2024

Describe the bug
User receives AttributeError: 'int' object has no attribute 'isdigit' when manually entering array_sizes for parameters.

To Reproduce
Steps to reproduce the behavior:

  1. undef OS_MAX_PATH_LEN
  2. Edit CHeaderParser-hdr-paths.txt and remove # on fm_msgdefs.h and fm_msg.h
  3. Run python3 CHeaderParser.py
  4. Enter the file name to save, I chose fm_app_cmd_file
  5. Type yes
  6. Pick a command with parameters which contains usage of OS_MAX_PATH_LEN e.g. I am choosing FM_DECOMPRESS
  7. Choose the appropriate struct e.g. 10
  8. Choose the line containing OS_MAX_PATH_LEN e.g. 2
  9. Enter any value for OS_MAX_PATH_LEN
  10. See error below

Expected behavior

Traceback (most recent call last):
  File "CHeaderParser.py", line 451, in <module>
    while not array_size.isdigit() or int(
AttributeError: 'int' object has no attribute 'isdigit'

Code snips
https://github.com/nasa/cFS-GroundSystem/blob/main/Subsystems/cmdGui/CHeaderParser.py#L450-L467

                        while not array_size.isdigit() or int(
                                array_size) not in range(129):
                            # User input is not an integer
                            if not array_size.isdigit():
                                print("Could not translate",
                                      array_name_size[1])
                            else:
                                print(
                                    "Array size out of bounds. It must be between 0 and 128."
                                )
                            try:
                                # Try to translate user input to an integer
                                array_size = int(
                                    input(
                                        (f"Please enter the defined value for "
                                         f"{array_name_size[1]} (0 - 128): ")))
                            except ValueError:
                                pass  # Ignore non-integer and try again

System observed on:

  • Hardware: VirtualBox
  • OS: Ubuntu 20.04
  • Versions [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps]

Fix

I believe the fix to be to remove int on the input function on line 462 : https://github.com/nasa/cFS-GroundSystem/blob/main/Subsystems/cmdGui/CHeaderParser.py#L462 like so:

                        while not array_size.isdigit() or int(
                                array_size) not in range(129):
                            # User input is not an integer
                            if not array_size.isdigit():
                                print("Could not translate",
                                      array_name_size[1])
                            else:
                                print(
                                    "Array size out of bounds. It must be between 0 and 128."
                                )
                            try:
                                # Try to translate user input to an integer
                                array_size =  input(
                                        (f"Please enter the defined value for "
                                         f"{array_name_size[1]} (0 - 128): "))
                            except ValueError:
                                pass  # Ignore non-integer and try again

Additional context

If you want to maintain the array_size as type int you can set the array_size to int array_size = int(array_size) after that while block above.

Reporter Info
Charles Taylor ER6
Johnson Space Center
I am on Teams

@PlanetB-rgb
Copy link
Author

I tested this on my end with FM commands and an unset OS_MAX_PATH_LEN
main...PlanetB-rgb:cFS-GroundSystem:fix-241-attribute-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant