39
39
40
40
41
41
def atask_default (ctx ):
42
- ctx .run ("echo Works" )
43
42
print ("Running script..." )
44
43
45
44
def atask_install_scoop (ctx ):
46
45
from invoke .watchers import Responder
46
+ breakpoint ()
47
47
ctx .run (
48
- command = ' "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned"' ,
48
+ command = "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned" ,
49
49
watchers = [
50
50
Responder (
51
51
pattern = r".*default is \"N\".*" ,
52
52
response = "A\n " ,
53
53
)
54
54
],
55
55
)
56
+ sys .exit (1 )
56
57
ctx .run ('powershell "iwr -useb https://get.scoop.sh | iex"' )
57
58
#ctx.run("""powershell "$env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User')\"""")
58
59
ctx .run ("scoop install git aria2" )
@@ -183,7 +184,7 @@ def global_defaults():
183
184
overrides = {
184
185
"tasks" : {"collection_name" : PROG_NAME },
185
186
"run" : {
186
- # "shell": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
187
+ "shell" : "C:\\ WINDOWS\\ System32\\ WindowsPowerShell\\ v1.0\\ powershell.exe" ,
187
188
"echo" : True ,
188
189
"debug" : True ,
189
190
},
@@ -194,15 +195,18 @@ def global_defaults():
194
195
name = PROG_NAME , namespace = namespace , config_class = SetupConfig , version = "0.0.1"
195
196
)
196
197
# NOTE: Debug
197
- from subprocess import Popen
198
- def Popen_print (* args , ** kwargs ):
199
- if "command" in kwargs :
200
- print (kwargs ["command" ])
201
- else :
202
- print (args [0 ])
203
- return Popen (* args , ** kwargs )
204
- with patch ("invoke.runners.Popen" , new = Popen_print ):
205
- program .run ()
198
+ # This uses the Python auditing framework in Python 3.8+
199
+ if sys .version_info >= (3 ,8 ):
200
+ print ("auditing enabled" )
201
+
202
+ def print_popen (* args , ** kwargs ) -> None :
203
+ if args [0 ] == "subprocess.Popen" :
204
+ # sys.audit("subprocess.Popen", executable, args, cwd, env)
205
+ # ("subprocess.Popen", (executable, args, cwd, env))
206
+ print (f"{ args [1 ][0 ]} -> { args [1 ][1 ]} " )
207
+
208
+ sys .addaudithook (print_popen )
209
+ program .run ()
206
210
207
211
208
212
if __name__ == "__main__" :
0 commit comments