-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-mob-tools.py
60 lines (53 loc) · 1.78 KB
/
install-mob-tools.py
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
"""
This script does the second part of a two-part install.
It is meant to run in an environment that does not have lxml.
The first part of the two-part installation
uses export-mob-project.py and is run in a dependency-rich environment.
"""
import shutil
import glob
import os
import argparse
import subprocess
import mobenv
def lines_to_env_dict(raw_lines):
d = {}
for line in raw_lines:
line = line.strip()
if not line:
continue
if line.startswith('#'):
continue
row = line.split()
if row:
k, v = row
d[k] = v
return d
def install_xml_files(stage, env_info):
xmls = glob.glob(os.path.join(stage, 'xml-files', '*.xml'))
xml_dir = env_info.get_xml_dir()
for xml_src in xmls:
xml_dst = os.path.join(xml_dir, os.path.basename(xml_src))
shutil.copy(xml_src, xml_dst)
def install_python_subtree(stage, env_info):
ztools_dir = os.path.dirname(env_info.auto_path)
shutil.copytree(os.path.join(stage, 'python-files'), ztools_dir)
def main(args):
stage = os.path.dirname(__file__)
with open(os.path.join(stage, 'install-mob-tools.conf')) as fin:
env_dict = lines_to_env_dict(fin)
env_info = mobenv.create_environment_info(
env_dict['auto_path'],
env_dict['python_path'],
env_dict['mob_core'],
env_dict['mob_version'])
install_xml_files(stage, env_info)
install_python_subtree(stage, env_info)
if args.deploy:
cmd = env_info.get_deploy_command()
subprocess.call(cmd)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--deploy', action='store_true',
help='deploy the xml files via mobdeploy')
main(parser.parse_args())