Browse Source

make cli location and command dynamic

master
Gerry Nelson 5 years ago
parent
commit
4a80096aa4
  1. 12
      applyfolderauthorization.py
  2. 15
      createbinarybackup.py
  3. 11
      explainaccess.py
  4. 12
      getpath.py
  5. 19
      snapshotreports.py
  6. 13
      testfolderaccess.py

12
applyfolderauthorization.py

@ -40,9 +40,13 @@ import json
import subprocess
from sharedfunctions import callrestapi, getfolderid, file_accessible, printresult
# 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)
# setup command-line arguements
@ -112,6 +116,6 @@ with open("bulk_rules_list.json", "w") as text_file:
text_file.write(bulk_rules_list_string+'\n')
# Execute sas-admin CLI to apply rules from JSON schema
command=clidir+'sas-admin authorization create-rules --file bulk_rules_list.json'
command=clicommand+' authorization create-rules --file bulk_rules_list.json'
print("Executing command: "+command)
subprocess.call(command, shell=True)

15
createbinarybackup.py

@ -23,8 +23,19 @@
# limitations under the License.
#
# CHANGE THIS VARIABLE IF YOUR CLI IS IN A DIFFERENT LOCATION
clidir='/opt/sas/viya/home/bin/'
# get python version
version=int(str(sys.version_info[0]))
# get cli location from properties
propertylist=getapplicationproperties()
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe)
debug=False
defaultBackupScheduleName="DEFAULT_BACKUP_SCHEDULE"
newScheduleName="BINARY_BACKUP_SCHEDULE"

11
explainaccess.py

@ -54,8 +54,17 @@
# limitations under the License.
#
# get python version
version=int(str(sys.version_info[0]))
# get cli location from properties
propertylist=getapplicationproperties()
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe)
clidir='/opt/sas/viya/home/bin/'
debug=False
direct_only=False
valid_permissions=['read','update','delete','secure','add','remove','create']

12
getpath.py

@ -31,7 +31,17 @@
#
clidir='/opt/sas/viya/home/bin/'
# get python version
version=int(str(sys.version_info[0]))
# get cli location from properties
propertylist=getapplicationproperties()
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe)
debug=False
# Import Python modules

19
snapshotreports.py

@ -45,8 +45,17 @@ from sharedfunctions import getfolderid, callrestapi, getpath
# get python version
version=int(str(sys.version_info[0]))
# CHANGE THIS VARIABLE IF YOUR CLI IS IN A DIFFERENT LOCATION
clidir='/opt/sas/viya/home/bin/'
# get python version
version=int(str(sys.version_info[0]))
# get cli location from properties
propertylist=getapplicationproperties()
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe)
# get input parameters
parser = argparse.ArgumentParser(description="Export Viya Reports each to its own unique transfer package")
@ -151,7 +160,7 @@ if areyousure.upper() =='Y':
json_name=json_name.replace(")","_")
json_name=json_name.replace(" ","-")
command=clidir+'sas-admin transfer export -u /reports/reports/'+id+' --name "'+package_name+'"'
command=clicommand+' transfer export -u /reports/reports/'+id+' --name "'+package_name+'"'
print(command)
subprocess.call(command, shell=True)
@ -161,12 +170,12 @@ if areyousure.upper() =='Y':
package_id=package_info['items'][0]['id']
completefile=os.path.join(path,json_name+'.json')
command=clidir+'sas-admin transfer download --file '+completefile+' --id '+package_id
command=clicommand+' transfer download --file '+completefile+' --id '+package_id
print(command)
subprocess.call(command, shell=True)
#time.sleep(1)
if autotranferremove:
print(clidir+'sas-admin transfer delete --id '+package_id+"\n")
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)
remTransferObjectOutput = remTransferObject.communicate(b'Y\n')
remTransferObject.wait()

13
testfolderaccess.py

@ -24,8 +24,17 @@
# limitations under the License.
#
# CHANGE THIS VARIABLE IF YOUR CLI IS IN A DIFFERENT LOCATION
clidir='/opt/sas/viya/home/bin/'
# get python version
version=int(str(sys.version_info[0]))
# get cli location from properties
propertylist=getapplicationproperties()
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe)
debug=False
# Import Python modules

Loading…
Cancel
Save