-
Notifications
You must be signed in to change notification settings - Fork 31
/
setup.py
executable file
·80 lines (67 loc) · 2.4 KB
/
setup.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# setup.py
# December 2020
#
# Updates the application.properties file with the location and name of the administration cli
# The default application properties stores the values for Viya 3.x
# This ensures bacward compatibility for Viya 3 users.
#
# sascli.location=/opt/sas/viya/home/bin/
# sascli.executable=sas-admin
#
# The defaults for the function are the Viya 4 values
#
# sascli.location=/opt/sas/viya/home/bin/
# sascli.executable=sas-viya
#
# As a result you only need to run setup.sh if you clone master and are using viya4
#
# .setup.py will set the default values for Viya 4
# OR
# ./setup.py --clilocation /opt/bin --cliexecutable sas-viya
#
#
# Copyright © 2018, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Import Python modules
import argparse, sys, os, inspect
from sharedfunctions import getapplicationproperties
from configobj import ConfigObj
# get python version
version=int(str(sys.version_info[0]))
# get input parameters
parser = argparse.ArgumentParser(description="Setup pyviyatools")
parser.add_argument("--clilocation", help="Enter the full path to the viya cli.",default="/opt/sas/viya/home/bin/")
parser.add_argument("--cliexecutable", help="Enter the name of the viya cli executable.", default="sas-viya")
args = parser.parse_args()
clilocation=args.clilocation
cliexecutable=args.cliexecutable
thepath=os.path.split(inspect.getsourcefile(lambda:0))
install_dir=thepath[0]
prop_file=os.path.join(install_dir, "application.properties")
print ("Note: updating "+prop_file)
dict={"sascli.location":clilocation,"sascli.executable":cliexecutable}
print("NOTE: configuration values set to ", dict )
config = ConfigObj(dict)
config.filename = prop_file
config.write()
# remove spaces
with open(prop_file, 'r+') as f:
txt = f.read().replace(' ', '')
f.seek(0)
f.write(txt)
f.truncate()