def main():
    """
    read command-line args, prompt for db user/pwd if needed
    for each entry in databaseFile (arg) - try to create/execute a resource
    """
    global edcSession
    edcSession = EDCSession()
    edcSession.initUrlAndSessionFromEDCSettings()
    print(edcSession.baseUrl)

    # read any command-line args
    args = readLocalArgs()
    print(f"args={args}")

    # check that both files exist (database file and resource template json file)
    if not os.path.isfile(args.resourceFile):
        print(f"resource file not found {args.resourceFile}, exiting")
        return

    # assuming all args are now read - let's do something
    for count, resourceName in enumerate(open(args.resourceFile)):
        # database name is read from file - only process if not starting with #
        if not resourceName.startswith("#") and len(resourceName.strip()) > 0:
            deleteResource(resourceName.strip(), args)
urllib3.disable_warnings()

start_time = time.time()
# initialize http header - as a dict
header = {}
auth = None

# number of objects for each page/chunk
pageSize = 500

# the csv lineage file to write to
csvFileName = "custom_attributes.csv"
# the path to write to - can be overwritten by -o cmdlink parameter
csvFilePath = "out/"

edcSession = EDCSession()
parser = argparse.ArgumentParser(parents=[edcSession.argparser])
parser.add_argument("-o", "--output", default="", help="output folder - e.g. .out")


def main():
    """
    call GET /access/2/catalog/models/attributes
     and GET /access/2/catalog/models/referenceAttributes
    the /access/2/catalog/models/attributes call returns all attributes
    (system + custom), so we filter for only the custom attrs
    these start with "com.infa.appmodels.ldm.

    output - prints the attribute name, id and some other properties to console
             + count the # of objects using the attribute
    """
예제 #3
0
def main():
    # prompt for catalog url
    print(f"edc api configuration utility:\n")
    catalog_url = input("enter catalog url - http(s):\\<server>:port : ")
    catalog_user = input("enter user id: ")
    p = getpass.getpass(prompt=f"password for user={catalog_user}: ")
    b64_auth_str = base64.b64encode(bytes(f"{catalog_user}:{p}", "utf-8"))
    auth = f'Basic {b64_auth_str.decode("utf-8")}'

    edcSession: EDCSession = EDCSession()

    edcSession.initSession(catalog_url=catalog_url,
                           catalog_auth=auth,
                           verify=None)

    print("\nvalidating that the information you entered is valid...")

    rc, rs_json = edcSession.validateConnection()
    if rc == 200:
        print(f"valid connection\n\t{rs_json}\n")
        print(
            "to make this a repeatable process - you can set the following enviroment variables, or an .env* file"
        )

        print("\nto set an env variable - linux/mac:")
        print(f'\texport INFA_EDC_URL={catalog_url}')
        print(f'\texport INFA_EDC_AUTH="Basic {b64_auth_str.decode("utf-8")}"')
        print("")
        print("for Powershell:")
        print(f'\t$env:INFA_EDC_AUTH={catalog_url}')
        print(f'\t$env:INFA_EDC_AUTH="Basic {b64_auth_str.decode("utf-8")}"')
        print("")
        print("for windows cmd:")
        print(f'\tset INFA_EDC_URL={catalog_url}')
        print(f'\tset INFA_EDC_AUTH=Basic {b64_auth_str.decode("utf-8")}')
        print("")

        print("\nor - create a .env file with those settings.")
        print(
            "\tNote:  if you create a file named '.env' - it will be automatically used by other scripts, or you can over-ride with the -v setting"
        )

        if not pathlib.Path(".env").is_file():
            yes_or_not = input(
                "\na .env file in the current folder does not exist, should i create it? (y or n)?:"
            )
            if yes_or_not.lower() == 'y':
                print('creating .env.....')
                write_env_file(".env", catalog_url, b64_auth_str)
        else:
            yes_or_not = input(
                "\na .env file already exists, would you like to overwrite it with these settings?: Y or N :"
            )
            if yes_or_not.lower() == 'y':
                print('overwriting .env.....')
                write_env_file(".env", catalog_url, b64_auth_str)
            else:
                yes_or_not = input(
                    "\na create/overwrite a different env file (suggest .env_<name>?: Y or N :"
                )
                if yes_or_not.lower() == 'y':
                    env_name = input(
                        'env file name to create: e.g. .env_test :')
                    if env_name is not None or env_name != "":
                        write_env_file(env_name, catalog_url, b64_auth_str)
                    else:
                        print("no name entered - can't create file")
    else:
        print(f"connection test failed\n{rs_json}")
예제 #4
0
class mem:
    """
    empty class for storing variables & not making them global
    """

    edcSession: EDCSession = EDCSession()