-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hooker to execute shell cmds in python directily as builtin functions
- Loading branch information
Showing
8 changed files
with
79 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .hook import HookGlobals | ||
from . import tester | ||
|
||
class DirectScript(HookGlobals): | ||
def hook_func(func, *args, **kwargs): | ||
if globals().get(func) is not None: | ||
return globals()[func](*args, **kwargs) | ||
cmd = f"{func[1][1]} " | ||
for arg in args: | ||
cmd += f"{arg} " | ||
for key, value in kwargs.items(): | ||
cmd += f"{key}={value} " | ||
global __hook_exec__ | ||
__hook_exec__.script_run(cmd) | ||
|
||
def __init__(self, func, exec): | ||
super().__init__(func) | ||
self.set_global("__hook_func__", DirectScript.hook_func) | ||
self.set_global("__hook_exec__", exec) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters