From 39f61dd13a806408765765f499312d94e05f4c7b Mon Sep 17 00:00:00 2001 From: Gerry Nelson Date: Tue, 24 Nov 2020 19:30:57 -0500 Subject: [PATCH] a few more sas-viya changes --- loginviauthinfo.py | 27 ++++++++++++++++----------- snapshotreports.py | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/loginviauthinfo.py b/loginviauthinfo.py index 916c17f..05c6858 100755 --- a/loginviauthinfo.py +++ b/loginviauthinfo.py @@ -57,14 +57,19 @@ except ImportError: from urlparse import urlparse -# CHANGE THIS VARIABLE IF YOUR CLI IS IN A DIFFERENT LOCATION -clidir='/opt/sas/viya/home/bin/' -#clidir='c:\\admincli\\' +# get cli location from properties +propertylist=getapplicationproperties() + +clidir=propertylist["sascli.location"] +cliexe=propertylist["sascli.executable"] + +clicommand=os.path.join(clidir,cliexe) + debug=0 profileexists=0 -# get input parameters +# get input parameters parser = argparse.ArgumentParser(description="Authinfo File") parser.add_argument("-f","--file", help="Enter the path to the authinfo file.",default='.authinfo') args = parser.parse_args() @@ -84,12 +89,12 @@ badprofile=0 #profile does not exist if access_file==False: - badprofile=1 + badprofile=1 host='default' #profile is empty file -if os.stat(endpointfile).st_size==0: +if os.stat(endpointfile).st_size==0: badprofile=1 host='default' @@ -124,11 +129,11 @@ if profileexists: print('user: '+username) print('profile: '+myprofile) print('host: '+host) - + #quote the password string for posix systems - if (os.name =='posix'): command=clidir+"sas-admin --profile "+myprofile+ " auth login -u "+username+ " -p '"+password+"'" - else: command=clidir+'sas-admin --profile '+myprofile+ ' auth login -u '+username+ ' -p '+password + if (os.name =='posix'): command=clicommand+" --profile "+myprofile+ " auth login -u "+username+ " -p '"+password+"'" + else: command=clicommand+' --profile '+myprofile+ ' auth login -u '+username+ ' -p '+password subprocess.call(command, shell=True) - + else: - print('ERROR: '+fname+' does not exist') + print('ERROR: '+fname+' does not exist') diff --git a/snapshotreports.py b/snapshotreports.py index 8a10fcf..b9ccece 100755 --- a/snapshotreports.py +++ b/snapshotreports.py @@ -173,7 +173,7 @@ if areyousure.upper() =='Y': #time.sleep(1) if autotranferremove: print(clicommand+' transfer delete --id '+package_id+"\n") - remTransferObject = subprocess.Popen(clidir+'sas-admin transfer delete --id '+package_id, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) + remTransferObject = subprocess.Popen(clicommand+' transfer delete --id '+package_id, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) remTransferObjectOutput = remTransferObject.communicate(b'Y\n') remTransferObject.wait()