Ejemplo n.º 1
0
def main(*margs, **kwargs):
    oldargs = None
    if margs or kwargs:
        # Backing up current arguments
        oldargs = sys.argv
        sys.argv = sys.argv[:1]

    args = parse_arguments(*margs, **kwargs)

    if margs or kwargs:
        # Restoring current arguments
        sys.argv = oldargs

    init(args.verbosity)
    pelican = get_instance(args)

    try:
        if args.autoreload:
            files_found_error = True
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if files_changed(pelican.path, pelican.markup) or \
                            files_changed(pelican.theme, ['']):
                        if not files_found_error:
                            files_found_error = True
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    logger.warning("Keyboard interrupt, quitting.")
                    break
                except NoFilesError:
                    if files_found_error:
                        logger.warning("No valid files found in content. "
                                       "Nothing to generate.")
                        files_found_error = False
                    time.sleep(1)  # sleep to avoid cpu load
                except Exception, e:
                    logger.warning(
                        "Caught exception \"{}\". Reloading.".format(e)
                    )

                    traceback.print_exc()

                    continue
        else:
Ejemplo n.º 2
0
def main():
    args = parse_arguments()
    init(args.verbosity)
    pelican = get_instance(args)

    try:
        if args.autoreload:
            files_found_error = True
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if (files_changed(
                            pelican.path,
                            pelican.markup,
                            pelican.ignore_files)
                        or files_changed(
                            pelican.theme,
                            [''],
                            pelican.ignore_files
                    )):
                        if not files_found_error:
                            files_found_error = True
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    logger.warning("Keyboard interrupt, quitting.")
                    break
                except NoFilesError:
                    if files_found_error:
                        logger.warning("No valid files found in content. "
                                       "Nothing to generate.")
                        files_found_error = False
                    time.sleep(1)  # sleep to avoid cpu load
                except Exception as e:
                    logger.warning(
                            'Caught exception "{0}". Reloading.'.format(e))
                    continue
        else:
            pelican.run()
    except Exception as e:
        logger.critical(e)

        if (args.verbosity == logging.DEBUG):
            raise
        else:
            sys.exit(getattr(e, 'exitcode', 1))
Ejemplo n.º 3
0
def main():
    args = parse_arguments()
    init(args.verbosity)
    pelican = get_instance(args)

    try:
        if args.autoreload:
            files_found_error = True
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if (files_changed(pelican.path, pelican.markup,
                                      pelican.ignore_files)
                            or files_changed(pelican.theme, [''],
                                             pelican.ignore_files)):
                        if not files_found_error:
                            files_found_error = True
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    logger.warning("Keyboard interrupt, quitting.")
                    break
                except NoFilesError:
                    if files_found_error:
                        logger.warning("No valid files found in content. "
                                       "Nothing to generate.")
                        files_found_error = False
                    time.sleep(1)  # sleep to avoid cpu load
                except Exception as e:
                    if (args.verbosity == logging.DEBUG):
                        logger.critical(e.args)
                        raise
                    logger.warning(
                        'Caught exception "{0}". Reloading.'.format(e))
                    continue
        else:
            pelican.run()
    except Exception as e:
        logger.critical(e)

        if (args.verbosity == logging.DEBUG):
            raise
        else:
            sys.exit(getattr(e, 'exitcode', 1))
Ejemplo n.º 4
0
def main():
    args = parse_arguments()
    init(args.verbosity)
    # Split the markup languages only if some have been given. Otherwise,
    # populate the variable with None.
    pelican = get_instance(args)

    try:
        if args.autoreload:
            files_found_error = True
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if files_changed(pelican.path, pelican.markup) or \
                            files_changed(pelican.theme, ['']):
                        if files_found_error == False:
                            files_found_error = True
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    logger.warning("Keyboard interrupt, quitting.")
                    break
                except NoFilesError:
                    if files_found_error == True:
                        logger.warning(
                            "No valid files found in content. Nothing to generate."
                        )
                        files_found_error = False
                    time.sleep(1)  # sleep to avoid cpu load
                except Exception, e:
                    logger.warning(
                        "Caught exception \"{}\". Reloading.".format(e))
                    continue
        else:
Ejemplo n.º 5
0
def main():
    args = parse_arguments()
    init(args.verbosity)
    # Split the markup languages only if some have been given. Otherwise,
    # populate the variable with None.
    pelican = get_instance(args)

    try:
        if args.autoreload:
            files_found_error = True
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if files_changed(pelican.path, pelican.markup) or \
                            files_changed(pelican.theme, ['']):
                        if files_found_error == False:
                            files_found_error = True
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    logger.warning("Keyboard interrupt, quitting.")
                    break
                except NoFilesError:
                    if files_found_error == True:
                        logger.warning("No valid files found in content. Nothing to generate.")
                        files_found_error = False
                    time.sleep(1)  # sleep to avoid cpu load
                except Exception, e:
                    logger.warning(
                        "Caught exception \"{}\". Reloading.".format(e)
                    )
                    continue
        else:
Ejemplo n.º 6
0
def main():
    args = parse_arguments()
    init(args.verbosity)
    # Split the markup languages only if some have been given. Otherwise,
    # populate the variable with None.
    pelican = get_instance(args)

    try:
        if args.autoreload:
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if files_changed(pelican.path, pelican.markup) or \
                            files_changed(pelican.theme, ['']):
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    break
        else:
            pelican.run()
    except Exception, e:
        logger.critical(unicode(e))

        if (args.verbosity == logging.DEBUG):
            raise
        else:
            sys.exit(getattr(e, 'exitcode', 1))
Ejemplo n.º 7
0
def main():
    args = parse_arguments()
    init(args.verbosity)
    # Split the markup languages only if some have been given. Otherwise,
    # populate the variable with None.
    pelican = get_instance(args)

    try:
        if args.autoreload:
            while True:
                try:
                    # Check source dir for changed files ending with the given
                    # extension in the settings. In the theme dir is no such
                    # restriction; all files are recursively checked if they
                    # have changed, no matter what extension the filenames
                    # have.
                    if files_changed(pelican.path, pelican.markup) or \
                            files_changed(pelican.theme, ['']):
                        pelican.run()

                    # reload also if settings.py changed
                    if file_changed(args.settings):
                        logger.info('%s changed, re-generating' %
                                    args.settings)
                        pelican = get_instance(args)
                        pelican.run()

                    time.sleep(.5)  # sleep to avoid cpu load
                except KeyboardInterrupt:
                    break
        else:
            pelican.run()
    except Exception, e:
        logger.critical(unicode(e))

        if (args.verbosity == logging.DEBUG):
            raise
        else:
            sys.exit(getattr(e, 'exitcode', 1))