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

implement logger in convert_script #717

Merged
merged 6 commits into from
Nov 24, 2021
Merged

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Nov 16, 2021

Request

Implement a logger on the converter script.

Implementation

The logger is quite simple. Basic stdout output. No format. Uses the standard logging module.

The logging is made when we append the line to FileTranslator.lines through an overloaded append method in a custom List class.

Use:

If the optional keyword show_log is True in FileTranslator, the resulting converted PyMAPDL is printed to the stdout.

Example:

>>> from ansys.mapdl.core.convert import convert_apdl_block, FileTranslator
>>> apdl_ = """FINISH
... /PREP7
... """
>>>
>>>_ = convert_apdl_block(apdl_strings=apdl_, line_ending='\n', show_log=True)
Converted: '"""Script generated by ansys-mapdl-core version 0.60.dev0"""'
Converted: 'from ansys.mapdl.core import launch_mapdl'
Converted: 'mapdl = launch_mapdl(loglevel="WARNING")'
Converted: 'mapdl.finish()'
Converted: 'mapdl.prep7()'
Converted: 'mapdl.exit()'

Closes #698

@germa89 germa89 self-assigned this Nov 16, 2021
@akaszynski akaszynski changed the title Feat/convert script logger implement logger in convert_script Nov 24, 2021
tests/test_convert.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the log capture working first.

@germa89
Copy link
Collaborator Author

germa89 commented Nov 24, 2021

It should now work.

tests/test_convert.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Kaszynski <[email protected]>
@akaszynski akaszynski self-requested a review November 24, 2021 20:02
Copy link
Collaborator

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Thanks for the fixes.

@akaszynski akaszynski merged commit 9ce53dd into main Nov 24, 2021
@akaszynski akaszynski deleted the feat/convert_script-logger branch November 24, 2021 20:02
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

Successfully merging this pull request may close these issues.

Log convert_script
2 participants