Skip to content

Commit

Permalink
PullRequest: 171 [CP] PullRequest: 126 support python3 for upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
frf12 authored and ob-robot committed May 27, 2024
1 parent 9f1d006 commit 804b318
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion agent/executor/ob/upgrade_exec_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (t *ExecScriptTask) Execute() (err error) {
return err
}
t.ExecuteLogf("execute script '%s' %s", t.scriptFile, t.zone)
str := fmt.Sprintf("cd %s; python2 %s -h%s -P%d -uroot", t.rpmDir, t.scriptPath, t.localAgent.Ip, meta.MYSQL_PORT)
str := fmt.Sprintf("cd %s; python %s -h%s -P%d -uroot", t.rpmDir, t.scriptPath, t.localAgent.Ip, meta.MYSQL_PORT)
if meta.GetOceanbasePwd() != "" {
pwd := strings.ReplaceAll(meta.GetOceanbasePwd(), "'", "'\"'\"'")
str = fmt.Sprintf("%s -p'%s'", str, pwd)
Expand Down
16 changes: 7 additions & 9 deletions agent/executor/ob/upragde_env_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,22 @@ func (t *CheckEnvTask) Execute() (err error) {
}

func (t *CheckEnvTask) checkEnv() (err error) {
t.ExecuteLog("Checking if python2 is installed.")
cmd := exec.Command("python2", "-c", "import sys; print(sys.version_info.major)")
t.ExecuteLog("Checking if python is installed.")
cmd := exec.Command("python", "-c", "import sys; print(sys.version_info.major)")

var out bytes.Buffer
cmd.Stdout = &out
if err = cmd.Run(); err != nil {
return errors.Wrap(err, "Please check if python2 is installed.")
return errors.Wrap(err, "Please check if python is installed.")
}
output := strings.TrimSpace(out.String())
t.ExecuteLogf("Python major version %s", output)
if output != "2" {
return errors.New("python2 is not installed.")
}

for _, module := range modules {
t.ExecuteLogf("Checking if python2 module '%s' is installed.", module)
cmd = exec.Command("python2", "-c", "import "+module)
t.ExecuteLogf("Checking if python module '%s' is installed.", module)
cmd = exec.Command("python", "-c", "import "+module)
if err = cmd.Run(); err != nil {
return errors.Wrap(err, fmt.Sprintf("Please check if python2 module '%s' is installed.", module))
return errors.Wrap(err, fmt.Sprintf("Please check if python module '%s' is installed.", module))
}
}
return nil
Expand Down
6 changes: 4 additions & 2 deletions rpm/obshell.spec
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ if [ -n "$OBSHELL_RELEASE" ]; then
RELEASE=$OBSHELL_RELEASE
fi

flag="-e VERSION=$VERSION -e RELEASE=$RELEASE -e DIST=%{?dist}"
OBSHELL_VERSION=${OBSHELL_VERSION:-$VERSION}
OBSHELL_RELEASE=${OBSHELL_RELEASE:-$RELEASE}
flag="-e VERSION=$OBSHELL_VERSION -e RELEASE=$OBSHELL_RELEASE -e DIST=%{?dist}"
if [ "$PROXY" ]; then
flag="$flag -e PROXY=$PROXY"
fi

make pre-build build-release $flag
mkdir -p $RPM_BUILD_ROOT/%{_prefix}/oceanbase/bin
cp bin/obshell $RPM_BUILD_ROOT/%{_prefix}/oceanbase/bin
cp -f bin/obshell $RPM_BUILD_ROOT/%{_prefix}/oceanbase/bin

%files
%defattr(755,admin,admin)
Expand Down

0 comments on commit 804b318

Please sign in to comment.