This is an automated email from the ASF dual-hosted git repository.
bipinprasad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/storm.git
The following commit(s) were added to refs/heads/master by this push:
new bb9979b47 [STORM-3847] Fix various problems in the python PowerShell
execution (#3403)
bb9979b47 is described below
commit bb9979b47a25a5215660c8f3df0b1a910da9d5e4
Author: Felix Engl <[email protected]>
AuthorDate: Mon Apr 4 07:52:57 2022 +0200
[STORM-3847] Fix various problems in the python PowerShell execution (#3403)
* Fix python version check in storm.ps1
(& python -V 2>&1) already returns a string. Accessing it like this (&
python -V 2>&1)[0] returns a single char. Therefore the check
"$PythonNumVersion -le 26" always fails.
* Clean Powershell-Code (no logical changes)
Fix left sided null comparison:
https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/PossibleIncorrectComparisonWithNull.md
Fix Cmdlet Alias:
https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/AvoidUsingCmdletAliases.md
* Fix call of python script
Start a new python-process in the current console window to get the stdout
and stderr
* Pipe the stout and stderr to the console
Pipe for windows the stout and stderr to the python console, to see it
directly in the Powershell-console window.
---
bin/storm.ps1 | 17 +++++++++--------
bin/storm.py | 5 +++--
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/bin/storm.ps1 b/bin/storm.ps1
index 780425179..0b1220aeb 100644
--- a/bin/storm.ps1
+++ b/bin/storm.ps1
@@ -23,12 +23,12 @@ while((Get-Item $PRG).LinkType -eq "SymbolicLink") {
}
# Check for Python version
-$PythonVersion = (& python -V 2>&1)[0].ToString().Split(" ")[1];
+$PythonVersion = (& python -V 2>&1).Split(" ")[1];
$PythonMajor = [int]$PythonVersion.Split(".")[0];
$PythonMinor = [int]$PythonVersion.Split(".")[1];
$PythonNumVersion = $PythonMajor * 10 + $PythonMinor;
if($PythonNumVersion -le 26) {
- echo "Need python version > 2.6";
+ Write-Output "Need python version > 2.6";
exit 1;
}
@@ -40,14 +40,14 @@ if($args.Length -ge 1) {
if("--config" -eq $args.get(0)) {
$ConfFile = $args.get(1);
if(-not (Test-Path $ConfFile)) {
- echo ("Error: Path {0} does not exist" -f $ConfFile);
+ Write-Output ("Error: Path {0} does not exist" -f $ConfFile);
exit 1;
}
if((Get-Item $ConfFile).PsIsContainer) {
$ConfFile=[io.path]::combine($ConfFile, "storm.yaml");
}
if(-not (Test-Path $ConfFile)) {
- echo ("Error: Path {0} does not exist" -f $ConfFile);
+ Write-Output ("Error: Path {0} does not exist" -f $ConfFile);
exit 1;
}
$STORM_CONF_FILE = $ConfFile;
@@ -55,14 +55,15 @@ if($args.Length -ge 1) {
}
}
-$env:STORM_CONF_DIR = if($STORM_CONF_DIR -ne $null) { $STORM_CONF_DIR; } else
{ [io.path]::combine($env:STORM_BASE_DIR, "conf"); }
-$env:STORM_CONF_FILE = if($STORM_CONF_FILE -ne $null) { $STORM_CONF_FILE; }
else { [io.path]::combine($env:STORM_BASE_DIR, "conf", "storm.yaml"); }
+$env:STORM_CONF_DIR = if($null -ne $STORM_CONF_DIR) { $STORM_CONF_DIR; } else
{ [io.path]::combine($env:STORM_BASE_DIR, "conf"); }
+$env:STORM_CONF_FILE = if($null -ne $STORM_CONF_FILE) { $STORM_CONF_FILE; }
else { [io.path]::combine($env:STORM_BASE_DIR, "conf", "storm.yaml"); }
$StormEnvPath = [io.path]::combine($env:STORM_CONF_DIR, "storm-env.ps1");
if(Test-Path $StormEnvPath) {
. $StormEnvPath;
}
-& ([io.path]::combine("$STORM_BIN_DIR", "storm.py")) $args;
+$ArgsForProcess = @(([io.path]::combine("$STORM_BIN_DIR", "storm.py"))) + $args
+Start-Process -FilePath python -ArgumentList $ArgsForProcess -Wait -NoNewWindow
-exit $LastExitCode
\ No newline at end of file
+exit $LastExitCode
diff --git a/bin/storm.py b/bin/storm.py
index 7651a2cb7..05dd1d280 100755
--- a/bin/storm.py
+++ b/bin/storm.py
@@ -255,8 +255,9 @@ def exec_storm_class(klass, storm_config_opts,
jvmtype="-server", jvmopts=[],
elif is_windows():
# handling whitespaces in JAVA_CMD
try:
- ret = subprocess.check_output(all_args, stderr=subprocess.STDOUT)
- print(ret)
+ process = subprocess.Popen(all_args, stderr=sys.stderr,
stdout=sys.stdout)
+ process.wait()
+ sys.exit(process.returncode)
except subprocess.CalledProcessError as e:
print(e.output)
sys.exit(e.returncode)