-
Notifications
You must be signed in to change notification settings - Fork 18
Feature: User Macros #147
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
base: main
Are you sure you want to change the base?
Feature: User Macros #147
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution! This looks really good! I still wanted to think about some things. In the meantime, I have some comments for you to consider.
92b7ec8 to
e9775fe
Compare
tnz/zti.py
Outdated
| # function | ||
| setattr(Zti, f"do_{macro_name}", | ||
| types.MethodType( | ||
| getattr(macro_module, f"do_{macro_name}"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have noticed that many of the do_<command> methods call self.__bg_wait_end(). That is because a background thread runs while the user is at the prompt and that call shuts down that background thread so that the session(s) can be used in a thread-safe manner. That is something that is definitely needed here. Without it. both the thread running the do_<command> method and the background thread could be using tnz methods that are not thread-safe. I suggest you define a method that wraps the macro method in order to accomplish this. See do_plugin() as an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing to model after do_plugin() ...
with ati.ati.new_program(share_sessions=True):
plugin(arg, **kwargs)That helps ensure that the ati environment provided to the plugin is clean and that any variables set by the plugin do not leak into the current environment. Unless your use case requires non-shared/global ati variables as input to or output from the macro, I suggest being consistent with do_plugin().
73b6992 to
f5c42ca
Compare
2fb401f to
bcde0d4
Compare
|
My mistake, running into issue rebasing on the latest changes. All should be ready for review now. |
2ae4bda to
05377d4
Compare
Signed-off-by: John Craig <[email protected]>
05377d4 to
8ab4e78
Compare
Signed-off-by: John Craig <[email protected]>
f10bac6 to
bb31a5b
Compare
tnz/zti.py
Outdated
| if not macro_file.endswith(".py"): | ||
| continue | ||
|
|
||
| if len(macro_file.split('.')) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest the use of pathlib for inspecting the filename and it's parts - this does not look right
examples/macros/logon.py
Outdated
| @@ -0,0 +1,30 @@ | |||
| from tnz.ati import ati | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it would actually be better to do from tnz import ati. that way the sample uses the current global ati object - which is what zti works with. when from tnz.ati import ati is used, the code here is bound the the global ati object at the time of import - there are situations in which that object can change.
Implement User Defined Macros as per #125