Skip to content

Commit

Permalink
Add a meaningful failure message when the CLI executable is not found. (
Browse files Browse the repository at this point in the history
#212)

* check cli

* add clicheck

* update for win

* windows

* move command

* update

* restore

---------

Co-authored-by: cloud-user <[email protected]>
  • Loading branch information
gerrynelson63 and cloud-user authored Feb 15, 2024
1 parent 351c292 commit 6bba811
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 196 deletions.
Empty file modified application.properties
100644 → 100755
Empty file.
14 changes: 4 additions & 10 deletions applyfolderauthorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@
import json
import subprocess
import sys
from sharedfunctions import callrestapi, getfolderid, file_accessible, printresult,getapplicationproperties

# get cli location from properties
propertylist=getapplicationproperties()

clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]

clicommand=os.path.join(clidir,cliexe)

from sharedfunctions import callrestapi, getfolderid, file_accessible, printresult,getapplicationproperties, getclicommand

# setup command-line arguements
parser = argparse.ArgumentParser(description="Apply bulk auths from a CSV file to folders and contents")
parser.add_argument("-f","--file", help="Full path to CSV file. Format of csv: 'folderpath,principaltype,principalid,grant_or_prohibit,perms_on_folder,perms_on_contents",required='True')
args = parser.parse_args()
file=args.file

# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

reqtype="post"

check=file_accessible(file,'r')
Expand Down
12 changes: 4 additions & 8 deletions applyviyarules.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,19 @@
import re
import pandas as pd
from datetime import datetime
from sharedfunctions import callrestapi, getfolderid, file_accessible, printresult, getapplicationproperties
from sharedfunctions import callrestapi, getfolderid, file_accessible, printresult, getapplicationproperties, getclicommand


## 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
parser = argparse.ArgumentParser(description="Apply bulk auths from a CSV file to folders and contents")
parser.add_argument("-f","--file", help="Full path to CSV file. Format of csv: 'objecturi,principaltype,principalid,grant_or_prohibit,perms,enabled,condition",required='True')
args = parser.parse_args()
file=args.file

# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

reqtype="post"

check=file_accessible(file,'r')
Expand Down
10 changes: 2 additions & 8 deletions createbinarybackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@
# 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 cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

debug=False
defaultBackupScheduleName="DEFAULT_BACKUP_SCHEDULE"
Expand Down
8 changes: 0 additions & 8 deletions createcaslibjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@
import sys
from sharedfunctions import callrestapi, getfolderid, file_accessible, printresult, getapplicationproperties

# 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
parser = argparse.ArgumentParser(description="Create basic CASLIBs from a CSV file")
parser.add_argument("-f","--file", help="Full path to CSV file. Format of csv: 'name,path,casserver,type,subdirs",required='True')
Expand Down
13 changes: 5 additions & 8 deletions explainaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,11 @@
import json
import sys
import os
from sharedfunctions import getfolderid,callrestapi,getapplicationproperties
from sharedfunctions import getfolderid,callrestapi,getapplicationproperties, getclicommand

# 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
direct_only=False
Expand Down Expand Up @@ -114,6 +107,10 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
conveyparam=args.convey
debug=args.debug


# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

if path_to_folder and objecturi:
raise Exception('You must specify either -f and a Viya folder path, or -u and an object URI, but not both.')
if path_to_folder is None and objecturi is None:
Expand Down
13 changes: 3 additions & 10 deletions exportcustomgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,11 @@
# Import Python modules
import argparse, sys, subprocess, uuid, time, os, glob, json, tempfile

from sharedfunctions import getfolderid, callrestapi, getapplicationproperties, printresult
from sharedfunctions import getfolderid, callrestapi, getapplicationproperties, printresult, getclicommand

# 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)

tempdir=tempfile.gettempdir()

# get input parameters
Expand All @@ -49,9 +41,10 @@
parser.add_argument("-f","--filename", help="Full path to file. (No extension)",default="/tmp/customgroups")
parser.add_argument("--id", help="Subset based on group id containing a string",default=None )
parser.add_argument("--name", help="Subset based on name containing a string",default=None )

parser.add_argument("-d","--debug", action='store_true', help="Debug")

# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

args= parser.parse_args()

Expand Down
12 changes: 3 additions & 9 deletions exportfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@
# Import Python modules
import argparse, sys, subprocess, uuid, time, os, glob

from sharedfunctions import getfolderid, callrestapi, getapplicationproperties, printresult
from sharedfunctions import getfolderid, callrestapi, getapplicationproperties, printresult, getclicommand

# 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 cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

# get input parameters
parser = argparse.ArgumentParser(description="Export a Viya Folder and its sub-folders")
Expand All @@ -50,7 +45,6 @@
parser.add_argument("-t","--tranferremove", help="Remove transfer package from SAS Viya after download to JSON file", action='store_true')



parser.add_argument("-q","--quiet", help="Suppress the are you sure prompt.", action='store_true')
args= parser.parse_args()

Expand Down
12 changes: 3 additions & 9 deletions exportfoldertree.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,11 @@
# Import Python modules
import argparse, sys, subprocess, uuid, time, os, glob, json

from sharedfunctions import getfolderid, callrestapi,getapplicationproperties
from sharedfunctions import getfolderid, callrestapi,getapplicationproperties,getclicommand

# 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 the complete Viya folder tree or the members of a folder to a set of Viya Packages.")
parser.add_argument("-d","--directory", help="Directory to store Export Packages",required='True')
Expand All @@ -61,6 +53,8 @@
autotranferremove=args.tranferremove
nonincrament=args.nonincrament

# get cli location from properties, check that cli is available if not ERROR and stop processing
clicommand=getclicommand()

# prompt if directory exists because existing json files are deleted
if os.path.exists(basedir):
Expand Down
13 changes: 4 additions & 9 deletions exportgeoproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,12 @@
# Import Python modules
import re
import argparse, sys, subprocess, os, glob
from sharedfunctions import callrestapi, getapplicationproperties
from sharedfunctions import callrestapi, getapplicationproperties,getclicommand


# 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 each geo providers to it's own unique transfer package")
Expand All @@ -62,6 +54,9 @@
basedir=args.directory
quietmode=args.quiet

# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

# prompt if directory exists because existing json files are deleted
if os.path.exists(basedir):

Expand Down
9 changes: 0 additions & 9 deletions getpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@

# 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

# Define exception handler so that we only output trace info from errors when in debug mode
Expand Down
8 changes: 0 additions & 8 deletions getpathsplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@
# 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

# Define exception handler so that we only output trace info from errors when in debug mode
Expand Down
13 changes: 5 additions & 8 deletions importcaslibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,8 @@
#
# Import Python modules
import argparse, sys, subprocess, os, json
from sharedfunctions import callrestapi, getapplicationproperties, file_accessible
from sharedfunctions import callrestapi, getapplicationproperties, file_accessible, getclicommand

# 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="Import JSON files that define path-based CASLIBS from directory. All json files in directory will be imported.")
Expand All @@ -55,6 +48,10 @@
quietmode=args.quiet
su=args.superuser


# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

# get python version
version=int(str(sys.version_info[0]))

Expand Down
11 changes: 3 additions & 8 deletions importconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@
#
# Import Python modules
import argparse, sys, subprocess, os, json
from sharedfunctions import callrestapi, getapplicationproperties
from sharedfunctions import callrestapi, getapplicationproperties,getclicommand

# get cli location from properties
propertylist=getapplicationproperties()

clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]

clicommand=os.path.join(clidir,cliexe)
# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

# get input parameters
parser = argparse.ArgumentParser(description="Import JSON files that update Viya configuration. All json files in directory will be imported.")
Expand Down
11 changes: 4 additions & 7 deletions importpackages.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@
#
# Import Python modules
import argparse, sys, subprocess, os, json
from sharedfunctions import callrestapi, getapplicationproperties
from sharedfunctions import callrestapi, getapplicationproperties,getclicommand

# 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="Import JSON files from directory. All json files in directory will be imported.")
Expand All @@ -51,6 +45,9 @@
version=int(str(sys.version_info[0]))


# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

# if the quiet mode flag is not passed then prompt to continue
if not quietmode:

Expand Down
11 changes: 3 additions & 8 deletions importtemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@
####################################################################

import argparse, sys, subprocess, os, json
from sharedfunctions import callrestapi, getapplicationproperties, getinputjson
from sharedfunctions import callrestapi, getapplicationproperties, getinputjson,getclicommand

# get cli location from properties
propertylist=getapplicationproperties()

clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]

clicommand=os.path.join(clidir,cliexe)
# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

parser = argparse.ArgumentParser(description="Upload templates")
parser.add_argument("-d","--directory", help="Directory that contains JSON files to import",required='True')
Expand Down
Binary file added jobmodule.pyc
Binary file not shown.
13 changes: 5 additions & 8 deletions loadcasdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,10 @@
# limitations under the License.
#
import argparse, csv, os, sys, subprocess
from sharedfunctions import callrestapi, getfolderid, file_accessible, getidsanduris, getapplicationproperties
from sharedfunctions import callrestapi, getfolderid, file_accessible, getidsanduris, getapplicationproperties,getclicommand

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)

if version==2:
from io import open
Expand All @@ -63,6 +56,10 @@
debug=args.debug
encoding=args.encoding


# get cli location from properties, check that cli is there if not ERROR and stop
clicommand=getclicommand()

reqtype="post"

check=file_accessible(file,'r')
Expand Down
Loading

0 comments on commit 6bba811

Please sign in to comment.