# Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License.
# 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
# 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
# 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.
# OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
#
#
# change log
# change log
# renamed to importpackages.py to be more descriptive of actual usage
# renamed to importpackages.py to be more descriptive of actual usage
#
#
# Import Python modules
# Import Python modules
importargparse,sys,subprocess,os,json
importargparse,sys,subprocess,os,json
fromsharedfunctionsimportcallrestapi
fromsharedfunctionsimportcallrestapi
# CHANGE THIS VARIABLE IF YOUR CLI IS IN A DIFFERENT LOCATION
# get cli location from properties
clidir='/opt/sas/viya/home/bin/'
propertylist=getapplicationproperties()
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe)
# get input parameters
# get input parameters
parser=argparse.ArgumentParser(description="Import JSON files from directory. All json files in directory will be imported.")
parser=argparse.ArgumentParser(description="Import JSON files from directory. All json files in directory will be imported.")
@ -36,7 +41,7 @@ args= parser.parse_args()
basedir=args.directory
basedir=args.directory
quietmode=args.quiet
quietmode=args.quiet
# get python version
# get python version
version=int(str(sys.version_info[0]))
version=int(str(sys.version_info[0]))
@ -46,7 +51,7 @@ if not quietmode:
ifversion>2:
ifversion>2:
areyousure=input("WARNING: If content from the packages already exists in folders it will be replaced. Continue? (Y)")
areyousure=input("WARNING: If content from the packages already exists in folders it will be replaced. Continue? (Y)")
else:
else:
areyousure=raw_input("WARNING:If content from the packages already exists in folders it will be replaced. Continue? (Y)")
areyousure=raw_input("WARNING:If content from the packages already exists in folders it will be replaced. Continue? (Y)")