コード例 #1
0
# setup command-line arguements
parser = argparse.ArgumentParser(
    description="Create folders that are read from a csv file")
parser.add_argument(
    "-f",
    "--file",
    help=
    "Full path to csv file containing folders, format of csv: 'folderpath,description ",
    required='True')
args = parser.parse_args()
file = args.file

reqtype = "post"

check = file_accessible(file, 'r')

# file can be read
if check:

    with open(file, 'rt') as f:

        filecontents = csv.reader(f)
        for row in filecontents:

            #print(row)
            newfolder = row[0]
            description = row[1]

            if newfolder[0] != '/': newfolder = "/" + newfolder
コード例 #2
0
                    "--file",
                    help="Enter the path to the authinfo file.",
                    default='.authinfo')
args = parser.parse_args()
authfile = args.file

# Read from the authinfo file in your home directory
fname = os.path.join(os.path.expanduser('~'), authfile)

# get current profile from ENV variable or if not set use default
myprofile = os.environ.get("SAS_CLI_PROFILE", "Default")
print("Logging in with profile: ", myprofile)

# get hostname from profile
endpointfile = os.path.join(os.path.expanduser('~'), '.sas', 'config.json')
access_file = file_accessible(endpointfile, 'r')
badprofile = 0

#profile does not exist
if access_file == False:
    badprofile = 1
    host = 'default'

#profile is empty file
if os.stat(endpointfile).st_size == 0:
    badprofile = 1
    host = 'default'

# get json from profile

if not badprofile:
コード例 #3
0
                    caslibname = data['name']
                    casserver = data['server']

                    command = clicommand + '  cas caslibs create path --source-file ' + fullfile
                    print(
                        "NOTE: Viya Caslib import attempted from json file " +
                        filename + " in  directory " + basedir)
                    print(command)
                    subprocess.call(command, shell=True)
                    tryimport = tryimport + 1

                    # apply the authorization if authorization file exists
                    authfile = os.path.join(
                        basedir, caslibname + '_authorization_.json')
                    access_file = file_accessible(authfile, 'r')

                    if access_file == True:
                        command = clicommand + '  cas caslibs replace-controls --server ' + casserver + ' --name ' + caslibname + ' --force --source-file ' + authfile
                        print(
                            "NOTE: Viya Caslib authorization import attempted from json file "
                            + filename + " in  directory " + basedir)
                        print(command)
                        subprocess.call(command, shell=True)

        if not tryimport: print("NOTE: no caslib files available for import.")

    else: print("ERROR: Directory does not exist.")
else:
    print("NOTE: Operation cancelled.")