예제 #1
0
    def test_pass_in_both_defaultname(self):
        """
        Environment variables: unset   
        Args : default names
        """

        arguments = '--user ' + arg_username + ' --password ' + arg_password
        sys.argv = []
        sys.argv.append(scriptname)
        sys.argv += arguments.split()

        Credentials = GetCredentials(user_argname='--user')
        ds_login_args = Credentials.add_login_args().parse_args()
        ds_login_args.funct_getlogon(ds_login_args)

        self.assertEqual(ds_login_args.user, arg_username)
        self.assertEqual(ds_login_args.password, arg_password)
예제 #2
0
    def test_pass_in_both_newnames(self):
        """
        Environment variables: unset   
        Args : Specify names
        """

        arguments = arg_alternative_user_name + ' ' + arg_username + ' ' + arg_alternative_password_name + ' ' + arg_password
        sys.argv = []
        sys.argv.append(scriptname)

        sys.argv += arguments.split()

        Credentials = GetCredentials(
            user_argname=arg_alternative_user_name,
            password_argname=arg_alternative_password_name)

        ds_login_args = Credentials.add_login_args().parse_args()
        ds_login_args.funct_getlogon(ds_login_args)

        self.assertEqual(ds_login_args.user, arg_username)
        self.assertEqual(ds_login_args.password, arg_password)
예제 #3
0
    def test_os_var(self):
        """ 
        Set environment variables - standard
        Do not pass in args
        """

        import os
        arguments = ''
        sys.argv = []
        sys.argv.append(scriptname)
        sys.argv += arguments.split()

        os.environ['USER'] = envvar_username
        os.environ['PASSWORD'] = envvar_password

        Credentials = GetCredentials()

        ds_login_args = Credentials.add_login_args().parse_args()
        ds_login_args.funct_getlogon(ds_login_args)

        self.assertEqual(ds_login_args.user, envvar_username)
        self.assertEqual(ds_login_args.password, envvar_password)
예제 #4
0
def HandleInputParameters():

    import os
    import argparse

    ## Variables for this script
    this_script_path=(os.path.dirname(sys.argv[0]))
    
    this_script_name=(os.path.basename(sys.argv[0]))
    # not used datadir=os.path.join(this_script_path,"data") # Ah!  you don't want the '/' in your args - makes sense!  
    logdir=os.path.join(this_script_path,"logs") # Ah!  you don't want the '/' in your args - makes sense!  
    default_logfile=os.path.join(logdir,this_script_name + '_log_file.txt')
   
        
    # Set up input options
    
    parser = argparse.ArgumentParser()
    parser.add_argument("--serviceTierHostName", type=str, dest="serviceTierHostName", help="The hostName/dns/ipaddress of the DataStage Service layer. e.g 127.0.0.1:9443 ", default='127.0.0.1', required=False) # Setting all to false here as it's making testing easier
    parser.add_argument("--isPort", type=str, dest="isPort", help="The port for accesing the serviceTier e.g 9443 ", default='9443', required=False) # Setting all to false here as it's making testing easier
    parser.add_argument("--hostName", type=str, dest="hostName", help="The hostName of the DataStage engine. e.g HN01. Often the same as the serviceTierHostName ", default='HN01', required=True) # Setting all to false here as it's making testing easier
    parser.add_argument("--projectName", type=str, dest="projectName", help="project to compile jobs in ", required=True)
    parser.add_argument("--logfile", type=str, dest="logfile", help="the logfile to be processed", default=default_logfile)
    parser.add_argument("--jobName", action='append', type=str, dest="job_list", help="jobs to compile", required=True)
    


    # Add logon credentials 
    #       get credentials, using generic code.
    from general_functions import GetCredentials
    Credentials = GetCredentials(user_argname='--ds-user', password_argname='--ds-password')
    parser = Credentials.add_login_args(parser)

    args = parser.parse_args()
    args.funct_getlogon(args)
    
   
    
    return args
예제 #5
0
    def test_arrgs_and_env_var(self):
        """ 
        Set environment variables - standard
        Pass in args
        Args should overriee env vars.
        """

        import os
        arguments = '--user ' + arg_username + ' --password ' + arg_password
        sys.argv = []
        sys.argv.append(scriptname)

        sys.argv += arguments.split()

        os.environ['USER'] = envvar_username
        os.environ['PASSWORD'] = envvar_password

        Credentials = GetCredentials()

        ds_login_args = Credentials.add_login_args().parse_args()
        ds_login_args.funct_getlogon(ds_login_args)

        self.assertEqual(ds_login_args.user, arg_username)
        self.assertEqual(ds_login_args.password, arg_password)
"""

from general_functions import GetCredentials


def main():

    print('Hello ' + args.user + '. Your password is ' + args.password + ' .')
    pass


if __name__ == '__main__':

    ## You can create the parser, using GetCredentials, or you can add to an existing parser.

    Credentials = GetCredentials(user_argname='--ds-user',
                                 password_argname='--ds-password')
    parser = Credentials.add_login_args()

    parser.add_argument(
        "--hostName",
        type=str,
        dest="hostName",
        help="The hostName of the DataStage engine. e.g HN01 ",
        default='HN01',
        required=True
    )  # Setting all to false here as it's making testing easier
    parser.add_argument("--projectName",
                        type=str,
                        dest="projectName",
                        help="project to compile jobs in ",
                        required=True)