-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun-develop.py
More file actions
131 lines (107 loc) · 4.53 KB
/
run-develop.py
File metadata and controls
131 lines (107 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import sys
sys.path.append('../build_tools/scripts')
import os
import base
import subprocess
import ctypes
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
def deleteNodejs():
if is_admin():
print("\nDeleting Node.js...")
code = subprocess.call('wmic product where name="Node.js" call uninstall', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
if code == 0:
print("\nDelete success!")
else:
print("\nError!")
else:
ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(''.join(sys.argv)), None, 1)
sys.exit()
def installNodejs():
base.download("https://nodejs.org/dist/latest-v10.x/node-v10.22.0-x86.msi", "C:/Python_downloads" + "/nodejs.msi")
if is_admin():
print("\nUnstalling Node.js...")
code = subprocess.call('cd C:\Python_downloads\ && msiexec.exe /i nodejs.msi /qn', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
if code == 0:
print("\nInstall success!")
else:
print("\nError!")
else:
ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(''.join(sys.argv)), None, 1)
sys.exit()
def check_nodejs_version():
get_version_command = 'node -v'
popen = subprocess.Popen(get_version_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
retvalue = ''
try:
stdout, stderr = popen.communicate()
popen.wait()
nodejs_version = stdout.strip().decode("utf-8")
finally:
popen.stdout.close()
popen.stderr.close()
if nodejs_version == retvalue:
installNodejs()
return True
print('Installed Node.js version: ' + nodejs_version)
nodejs_min_version = 8
nodejs_max_version = 10
nodejs_cur_version = int(nodejs_version.split('.')[0][1:])
if (nodejs_min_version > nodejs_cur_version or nodejs_cur_version > nodejs_max_version):
print('\nNode.js version must be 8.x to 10.x')
deleteNodejs()
installNodejs()
return True
return True
def install_module(path):
base.print_info('Install: ' + path)
base.cmd_in_dir(path, 'npm', ['install'])
def run_module(directory, args=[]):
base.run_nodejs_in_dir(directory, args)
def find_rabbitmqctl(base_path):
return base.find_file(os.path.join(base_path, 'RabbitMQ Server'), 'rabbitmqctl.bat')
def restart_win_rabbit():
base.print_info('restart RabbitMQ node to prevent "Erl.exe high CPU usage every Monday morning on Windows" https://groups.google.com/forum/#!topic/rabbitmq-users/myl74gsYyYg')
rabbitmqctl = find_rabbitmqctl(os.environ['PROGRAMW6432']) or find_rabbitmqctl(os.environ['ProgramFiles(x86)'])
if rabbitmqctl is not None:
base.cmd_in_dir(base.get_script_dir(rabbitmqctl), 'rabbitmqctl.bat', ['stop_app'])
base.cmd_in_dir(base.get_script_dir(rabbitmqctl), 'rabbitmqctl.bat', ['start_app'])
else:
base.print_info('Missing rabbitmqctl.bat')
def start_mac_services():
base.print_info('Restart MySQL Server')
base.run_process(['mysql.server', 'restart'])
base.print_info('Start RabbitMQ Server')
base.run_process(['rabbitmq-server'])
base.print_info('Start Redis')
base.run_process(['redis-server'])
def run_integration_example():
base.cmd_in_dir('../document-server-integration/web/documentserver-example/nodejs', 'python', ['run-develop.py'])
base.print_info('check Node.js version')
if (True != check_nodejs_version()):
exit(0)
platform = base.host_platform()
if ("windows" == platform):
restart_win_rabbit()
elif ("mac" == platform):
start_mac_services()
base.print_info('Build modules')
base.cmd_in_dir('../build_tools', 'python', ['configure.py', '--branch', 'develop', '--module', 'develop', '--update', '1', '--update-light', '1', '--clean', '0', '--sdkjs-addon', 'comparison', '--sdkjs-addon', 'content-controls', '--sdkjs-addon', 'pivot-tables'])
base.cmd_in_dir('../build_tools', 'python', ['make.py'])
run_integration_example()
base.create_dir('App_Data')
base.create_dir('SpellChecker/dictionaries')
base.copy_dir_content('../dictionaries', 'SpellChecker/dictionaries', '', '.git')
install_module('DocService')
install_module('Common')
install_module('FileConverter')
install_module('SpellChecker')
base.set_env('NODE_ENV', 'development-' + platform)
base.set_env('NODE_CONFIG_DIR', '../../Common/config')
run_module('DocService/sources', ['server.js'])
run_module('DocService/sources', ['gc.js'])
run_module('FileConverter/sources', ['convertermaster.js'])
run_module('SpellChecker/sources', ['server.js'])