<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def validate_args(args):
    '''
    Apply custom validation and actions based on parsed arguments.

    Parameters
    ----------
    args : argparse.Namespace
        Result from ``parse_args`` method of ``argparse.ArgumentParser``
        instance.

    Returns
    -------
    argparse.Namespace
        Reference to input ``args``, which have been validated/updated.
    '''
    logging.basicConfig(level=getattr(logging, args.log_level.upper()))

    if getattr(args, 'command', None) == 'install':
        if args.requirements_file and not args.requirements_file.isfile():
            print >> sys.stderr, ('Requirements file not available: {}'
                                    .format(args.requirements_file))
            raise SystemExit(-1)
        elif not args.plugin and not args.requirements_file:
            print >> sys.stderr, ('Requirements file or at least one plugin '
                                  'must be specified.')
            raise SystemExit(-2)
    if hasattr(args, 'server_url'):
        logger.debug('Using MicroDrop index server: "%s"', args.server_url)
        args.server_url = SERVER_URL_TEMPLATE % args.server_url
    if all([args.plugins_directory is None,
            args.config_file is None]):
        args.plugins_directory = get_plugins_directory()
    elif args.plugins_directory is None:
        args.config_file = args.config_file.realpath()
        args.plugins_directory = get_plugins_directory(config_path=
                                                       args.config_file)
    else:
        args.plugins_directory = args.plugins_directory.realpath()
    return args