Base dispather

def main(args=None):
    " Base dispather "
    try:
        start = datetime.now()

        LOGGER.info('MAKESITE Version %s' % version)
        LOGGER.info('Started at %s' % start.strftime("%Y-%m-%d %H:%M:%S"))
        LOGGER.info('Logfile: %s' % LOGFILE_HANDLER.stream.name)
        LOGGER.info('-' * 60)

        if args.host:
            cmd = "makesite %s %s" % (args.action, ' '.join(args.argv))
            for host in args.host:
                LOGGER.info('\nHOST: %s' % host)
                LOGGER.info('RUN: %s\n' % cmd)
                client = SSHClient(host)
                client.connect()
                client.exec_command(cmd)
                client.close()
                LOGGER.info("\nOPERATION SUCCESSFUL\n")

        else:
            func = ACTIONS.get(args.action)
            func(args.argv)
            LOGGER.info("\nOPERATION SUCCESSFUL")

    except (AssertionError, CalledProcessError, gaierror), e:
        LOGGER.error("\nOPERATION FAILED - %s" % str(e))
        LOGGER.error("See log: %s" % LOGFILE_HANDLER.stream.name)
        sys.exit(1)