1
2
3
4
5
6
7
8
9
10
11
12
|
# encoding: utf-8
# api: streamtuner2
# title: win32/subprocess
# description: Utilizes subprocess spawning or win32 API instead of os.system
# version: 0.3
# depends: streamtuner2 > 2.2.0, python >= 2.7
# priority: optional
# config:
# { name: cmd_spawn, type: select, select: "popen|shell|call|execv|spawnv|pywin32|win32api|system", value: popen, description: Spawn method }
# { name: cmd_flags, type: select, select: "none|nowait|detached|nowaito|all|sw_hide||sw_minimize|sw_show", value: nowait, description: Process creation flags (win32) }
# type: handler
# category: io
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
|
# encoding: utf-8
# api: streamtuner2
# title: win32/subprocess
# description: Utilizes subprocess spawning or win32 API instead of os.system
# version: 0.3.1
# depends: streamtuner2 > 2.2.0, python >= 2.7
# priority: optional
# config:
# { name: cmd_spawn, type: select, select: "popen|shell|call|execv|spawnv|pywin32|win32api|system", value: popen, description: Spawn method }
# { name: cmd_flags, type: select, select: "none|nowait|detached|nowaito|all|sw_hide||sw_minimize|sw_show", value: nowait, description: Process creation flags (win32) }
# type: handler
# category: io
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# flags
flags = self.flagmap[conf.cmd_flags] if conf.windows and conf.cmd_flags in self.flagmap else 0
# debug
log.EXEC("st2subprocess:", args, "creationflags=%s"%flags)
#-- Popen → https://docs.python.org/2/library/subprocess.html#popen-constructor
v = conf.cmd_spawn
if v in ("popen"):
log.POPEN(
subprocess.Popen(args, shell=(v=="shell"), creationflags=flags).__dict__
)
#-- Popen w/ shell=True and string cmd
v = conf.cmd_spawn
if v in ("popen", "shell"):
log.POPEN_SHELL(
subprocess.Popen(cmd, shell=(v=="shell"), creationflags=flags).__dict__
)
#-- call → https://docs.python.org/2/library/subprocess.html#replacing-os-system
elif v == "call":
log.CALL(
subprocess.call(args, creationflags=flags).__dict__
)
#-- execv → https://docs.python.org/2/library/os.html#os.execv
elif v == "execv":
|
|
>
>
>
<
<
<
<
<
<
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# flags
flags = self.flagmap[conf.cmd_flags] if conf.windows and conf.cmd_flags in self.flagmap else 0
# debug
log.EXEC("st2subprocess:", args, "creationflags=%s"%flags)
#-- Popen → https://docs.python.org/2/library/subprocess.html#popen-constructor
v = conf.cmd_spawn
if v in ("popen", "shell"):
#-- Popen w/ shell=True and string cmd
if (v=="shell"):
args = [cmd]
log.POPEN(
subprocess.Popen(args, shell=(v=="shell"), creationflags=flags).__dict__
)
#-- call → https://docs.python.org/2/library/subprocess.html#replacing-os-system
elif v == "call":
log.CALL(
subprocess.call(args, creationflags=flags).__dict__
)
#-- execv → https://docs.python.org/2/library/os.html#os.execv
elif v == "execv":
|