How to use the duecredit.log.lgr.error function in duecredit

To help you get started, we’ve selected a few duecredit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duecredit / duecredit / duecredit / cmdline / View on Github external
parser = setup_parser()
    # parse cmd args
    args = parser.parse_args(args)

    # run the function associated with the selected command
    if args.common_debug:
        # So we could see/stop clearly at the point of failure
        # Otherwise - guard and only log the summary. Postmortem is not
        # as convenient if being caught in this ultimate except
        except Exception as exc:
            lgr.error('%s (%s)' % (str(exc), exc.__class__.__name__))
github duecredit / duecredit / duecredit / View on Github external
        with open(progname) as fp:
            code = compile(, progname, 'exec')
        # try to emulate __main__ namespace as much as possible
        globs = {
            '__file__': progname,
            '__name__': '__main__',
            '__package__': None,
            '__cached__': None,
        # Since used explicitly -- activate the beast
        runctx(code, globs, globs)
        # TODO: see if we could hide our presence from the final tracebacks if execution fails
    except IOError as err:
        lgr.error("Cannot run file %r because: %s" % (sys.argv[0], err))
    except SystemExit:
github duecredit / duecredit / duecredit / View on Github external
# Clean up current bindings first
            for k in filter(is_public_or_special, dir(self)):
                delattr(self, k)

            new_due = self.__collectors[activate]
            for k in filter(is_public_or_special, dir(new_due)):
                setattr(self, k, getattr(new_due, k))

            self.__active = activate

        # 2nd -- if activating, we might still need to have activations done
        if activate and not self.__activations_done:
            except Exception as e:
                lgr.error("Failed to prepare injections etc: %s" % str(e))
                self.__activations_done = True
github duecredit / duecredit / duecredit / injections / View on Github external
def deactivate(self):
        if not self._orig_import:
            lgr.warning("_orig_import is not yet known, so we haven't decorated default importer yet."
                        " Nothing TODO")
        if not self._active:  # pragma: no cover
            lgr.error("Must have not happened, but we will survive!")
        lgr.debug("Assigning original importer")
        __builtin__.__import__ = self._orig_import
        self._orig_import = None
        self._active = False
github duecredit / duecredit / duecredit / View on Github external
bib_source = cpBibTeX(fname)
            except decode_exceptions as e:
                # So .bib must be having UTF-8 characters.  With
                # a recent (not yet released past v0.3.0-68-g9800dad
                # we should be able to provide encoding argument
                bib_source = cpBibTeX(fname, encoding='utf-8')
        except Exception as e:
            msg = "Failed to process BibTeX file %s: %s." % (fname, e)
            citeproc_version = external_versions['citeproc']
            if 'unexpected keyword argument' in str(e) and \
                    citeproc_version and citeproc_version < '0.4':
                err = "need a newer citeproc-py >= 0.4.0"
                msg += " You might just " + err
                err = str(e)
            return "ERRORED: %s" % err
            # return warnings back
            warnings.filters = old_filters
        bib_style = cp.CitationStylesStyle(style, validate=False)
        # TODO: specify which tags of formatter we want
        bibliography = cp.CitationStylesBibliography(bib_style, bib_source,
        citation = cp.Citation([cp.CitationItem(key)])
        if not os.environ.get("DUECREDIT_KEEPTEMP"):
            exceptions = (OSError, WindowsError) if on_windows else OSError
            for i in range(50):
github duecredit / duecredit / duecredit / injections / View on Github external
def _mitigate_None_orig_import(self, name, *args, **kwargs):
        lgr.error("For some reason self._orig_import is None"
                  ". Importing using stock importer to mitigate and adjusting _orig_import")
        self._orig_import = _very_orig_import
        return _very_orig_import(name, *args, **kwargs)