Fix uninstall|install

Co-authored-by: Alexander Trofimov <Alexander.Trofimov@onlyoffice.com>
This commit is contained in:
Nikita Khromov
2020-10-09 10:44:33 +03:00
committed by GitHub
parent 4cbaf10fcd
commit 4e806d658d
3 changed files with 47 additions and 47 deletions

View File

@ -54,7 +54,7 @@ def check_mysqlServer(serversBitness, serversVersions, serversPaths, dataPaths):
break
if (i == len(serversBitness) - 1):
print('MySQL Server not found')
dependence.progsToInstall.add('MySQLServer')
dependence.install.append('MySQLServer')
return dependence
for i in range(len(serversBitness)):
@ -63,7 +63,7 @@ def check_mysqlServer(serversBitness, serversVersions, serversPaths, dataPaths):
continue
elif (result == 'x32'):
print('MySQL Server ' + serversVersions[i][0:3] + ' bitness is x32, is not valid')
dependence.progsToUninstall.add('MySQL Server ' + serversVersions[i][0:3])
dependence.uninstall.append('MySQL Server ' + serversVersions[i][0:3])
continue
elif (result == 'x64'):
print('MySQL Server bitness is valid')
@ -71,17 +71,17 @@ def check_mysqlServer(serversBitness, serversVersions, serversPaths, dataPaths):
if (connectionResult.find('port') != -1 and connectionResult.find('3306') != -1):
if (base.run_command('"' + serversPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SHOW DATABASES;"')['stdout'].find('onlyoffice') == -1):
print('Database onlyoffice not found')
dependence.progsToInstall.add('MySQLDatabase')
dependence.install.append('MySQLDatabase')
if (base.run_command('"' + serversPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SELECT plugin from mysql.user where User=' + "'root';")['stdout'].find('mysql_native_password') == -1):
print('Password encryption is not valid')
dependence.progsToInstall.add('MySQLEncrypt')
dependence.install.append('MySQLEncrypt')
dependence.pathToValidMySQLServer = serversPaths[i]
return dependence
else:
print('MySQL Server configuration is not valid')
dependence.progsToUninstall.add('MySQL Server ' + serversVersions[i][0:3])
dependence.pathsToRemove.add(serversPaths[i])
dependence.progsToInstall.add('MySQLServer')
dependence.uninstall.append('MySQL Server ' + serversVersions[i][0:3])
dependence.removePath.append(serversPaths[i])
dependence.install.append('MySQLServer')
continue
return dependence

View File

@ -4,19 +4,10 @@ import os
import base
import dependence
import subprocess
import ctypes
import checks_develop as check
import shutil
if (sys.version_info[0] >= 3):
unicode = str
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
import optparse
def installingProgram(sProgram, sParam = ''):
if (sProgram == 'Node.js'):
print("Installing Node.js...")
@ -132,30 +123,25 @@ def installMySQLServer():
return True
return False
try:
base.configure_common_apps()
checkResults = check.check_dependencies()
if (len(checkResults.progsToInstall) > 0):
if is_admin():
for program in checkResults.progsToUninstall:
dependence.uninstallProgram(program)
for path in checkResults.pathsToRemove:
shutil.rmtree(path)
for program in checkResults.progsToInstall:
if (program == 'MySQLDatabase' or program == 'MySQLEncrypt'):
installingProgram(program, checkResults.pathToValidMySQLServer)
elif (program == 'MySQLServer'):
installMySQLServer()
else:
installingProgram(program)
print('All installations completed!')
else:
ctypes.windll.shell32.ShellExecuteW(None, unicode("runas"), unicode(sys.executable), unicode(''.join(sys.argv)), None, 1)
sys.exit(0)
else:
base.print_info('All checks complite')
except SystemExit:
input("Ignoring SystemExit. Press Enter to continue...")
arguments = sys.argv[1:]
parser = optparse.OptionParser()
parser.add_option("--install", action="append", type="string", dest="install", default=[], help="provides install dependencies")
parser.add_option("--uninstall", action="append", type="string", dest="uninstall", default=[], help="provides uninstall dependencies")
parser.add_option("--remove-path", action="append", type="string", dest="remove-path", default=[], help="provides path dependencies to remove")
parser.add_option("--mysql-path", action="store", type="string", dest="mysql-path", default="", help="provides path to mysql")
(options, args) = parser.parse_args(arguments)
configOptions = vars(options)
for item in configOptions["uninstall"]:
dependence.uninstallProgram(item)
for item in configOptions["remove-path"]:
shutil.rmtree(item)
for item in configOptions["install"]:
if (item == 'MySQLDatabase' or item == 'MySQLEncrypt'):
installingProgram(item, configOptions["mysql-path"])
elif (item == 'MySQLServer'):
installMySQLServer()
else:
installingProgram(item)

View File

@ -1,12 +1,17 @@
import sys
sys.path.append('../build_tools/scripts')
sys.path.append('../build_tools/scripts/vendor')
import os
import base
import ctypes
import libwindows
import dependence
import checks_develop as checks
import checks_develop as check
import subprocess
import json
if (sys.version_info[0] >= 3):
unicode = str
def install_module(path):
base.print_info('Install: ' + path)
base.cmd_in_dir(path, 'npm', ['install'])
@ -40,8 +45,17 @@ def run_integration_example():
try:
base.configure_common_apps()
dependence.check_pythonPath()
base.cmd_in_dir('./', 'python', ['install_develop.py'])
checksResult = check.check_dependencies()
if (len(checksResult.install) > 0):
install_args = ['install_develop.py']
install_args += checksResult.get_uninstall()
install_args += checksResult.get_removepath()
install_args += checksResult.get_install()
install_args += ['--mysql-path', unicode(checksResult.mysqlPath)]
code = libwindows.sudo(unicode(sys.executable), install_args)
platform = base.host_platform()
if ("windows" == platform):
restart_win_rabbit()