Beispiel #1
0
 def request(self):
     ''' Return a local proxy to the current :class:`werkzeug.Request`
         instance.'''
     return werkzeug.LocalProxy(lambda: bottle.local.werkzueg_request)
Beispiel #2
0
        from craftr import defaults
        result = {}
        for key, value in vars(defaults).items():
            if not key.startswith('_'):
                result[key] = value
        result.update({
            'options': self.options,
            'project_dir': self.project_dir
        })
        return result

    @property
    def current_line(self):
        """
    This property is only accessible when the module is currently begin
    executed, and only from within the same thread. Returns the line at
    which the module is currently being executed.
    """

        frame = sys._getframe()
        while frame and frame.f_globals is not vars(self.namespace):
            frame = frame.f_back
        if not frame:
            raise RuntimeError('module frame not found')
        return frame.f_lineno


#: Proxy object that points to the current :class:`Session` object.
session = werkzeug.LocalProxy(lambda: Session.current)
Beispiel #3
0
 def response(self):
     ''' Return a local proxy to the current :class:`werkzeug.Response`
         instance.'''
     return werkzeug.LocalProxy(lambda: bottle.local.werkzeug_response)
Beispiel #4
0
            bar = ''.join(itertools.islice(itertools.cycle(sign), width))
        else:
            intprogress = int(min([1.0, max([0.0, float(progress)])]) * width)
            bar = '#' * intprogress + ' ' * (width - intprogress)
        indent = self._indent_seq * self._indent
        print('{}|{}| {}'.format(indent, bar, info_text),
              end='',
              file=self._stream)
        self._progress['index'] += 1
        self._progress['last'] = ctime
        self._stream.flush()

    def progress_end(self):
        tty.clear_line()
        self._progress = None

    def set_level(self, level):
        self._level = level

    def flush(self):
        self._stream.flush()


_logger = DefaultLogger()
logger = werkzeug.LocalProxy(lambda: _logger)


def set_logger(logger):
    global _logger
    _logger = logger