How to use the kivy.logger.Logger function in Kivy

To help you get started, we’ve selected a few Kivy 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 HeaTTheatR / KivyMD / demos / kitchen_sink / screens.py View on Github external
def load_screen(self, name_screen):
        Logger.debug(f"Kitchen Sink: Load screen {name_screen}")
        # Add button to navigation drawer
        if "icon" in self.data[name_screen]:
            self.root.ids.nav_drawer.add_widget(
                MyNavigationDrawerIconButton(
                    text=name_screen, icon=self.data[name_screen]["icon"]
                )
            )

        # Load kv string
        if "kv_string" in self.data[name_screen]:
            Builder.load_string(self.data[name_screen]["kv_string"])

        # Load screen object
        if "object" in self.data[name_screen]:
            self.data[name_screen]["object"] = eval(
                self.data[name_screen]["Factory"]
github BillBillBillBill / Tickeys-linux / tickeys / kivy / core / __init__.py View on Github external
locals=locals(),
                fromlist=[modulename], level=0)
            cls = mod.__getattribute__(classname)

            # ok !
            Logger.info('{0}: Provider: {1}{2}'.format(
                category.capitalize(), option,
                '({0} ignored)'.format(libs_ignored) if libs_ignored else ''))
            if create_instance:
                cls = cls()
            return cls

        except ImportError as e:
            errs.append((option, e, sys.exc_info()[2]))
            libs_ignored.append(modulename)
            Logger.debug('{0}: Ignored <{1}> (import error)'.format(
                category.capitalize(), option))
            Logger.trace('', exc_info=e)

        except CoreCriticalException as e:
            errs.append((option, e, sys.exc_info()[2]))
            Logger.error('{0}: Unable to use {1}'.format(
                category.capitalize(), option))
            Logger.error(
                '{0}: The module raised an important error: {1!r}'.format(
                    category.capitalize(), e.message))
            raise

        except Exception as e:
            errs.append((option, e, sys.exc_info()[2]))
            libs_ignored.append(modulename)
            Logger.trace('{0}: Unable to use {1}'.format(
github kivy / kivy / kivy / cache.py View on Github external
def remove(category, key=None):
        '''Purge the cache.

        :Parameters:
            `category`: str
                Identifier of the category.
            `key`: str (optional)
                Unique identifier of the object in the store. If this
                argument is not supplied, the entire category will be purged.
        '''
        Logger.trace("trying to remove %s from %s", key, category)
        if key is not None:
            cat = Cache._categories[category]
            Logger.trace('cat max size %s', cat['max_size'])
            if cat['max_size']:
                obj_size = cat['sizes'][key]
                Logger.trace('removing %s from %s size',
                             obj_size, category)
                cat['size'] -= obj_size
                del cat['sizes'][key]

            del Cache._objects[category][key]
            Logger.trace("removed %s:%s from cache", category, key)
        else:
            Cache._objects[category] = {}
            Logger.trace("flushed category %s from cache", category)
github pyKy / kivy-doc-ja / kivy / resources.py View on Github external
def resource_add_path(path):
    '''Add a custom path to search in.
    '''
    if path in resource_paths:
        return
    Logger.debug('Resource: add <%s> in path list' % path)
    resource_paths.append(path)
github kivy / kivy / kivy / lang / parser.py View on Github external
global_idmap[name] = value
            elif cmd[:8] == 'include ':
                ref = cmd[8:].strip()
                force_load = False

                if ref[:6] == 'force ':
                    ref = ref[6:].strip()
                    force_load = True

                # if #:include [force] "path with quotes around"
                if ref[0] == ref[-1] and ref[0] in ('"', "'"):
                    c = ref[:3].count(ref[0])
                    ref = ref[c:-c] if c != 2 else ref

                if ref[-3:] != '.kv':
                    Logger.warn('Lang: {0} does not have a valid Kivy'
                                'Language extension (.kv)'.format(ref))
                    break
                if ref in __KV_INCLUDES__:
                    if not os.path.isfile(resource_find(ref) or ref):
                        raise ParserException(self, ln,
                                              'Invalid or unknown file: {0}'
                                              .format(ref))
                    if not force_load:
                        Logger.warn('Lang: {0} has already been included!'
                                    .format(ref))
                        continue
                    else:
                        Logger.debug('Lang: Reloading {0} ' +
                                     'because include was forced.'
                                     .format(ref))
                        kivy.lang.builder.Builder.unload_file(ref)
github kivy / kivy-berkelium / berkelium / __init__.py View on Github external
from weakref import ref
from kivy.base import EventLoop
from kivy.clock import Clock
from kivy.factory import Factory
from kivy.graphics import Color, Rectangle
from kivy.logger import Logger
from kivy.uix.widget import Widget
from kivy.utils import QueryDict
from kivy.properties import StringProperty, ObjectProperty, AliasProperty, \
    BooleanProperty, OptionProperty, ListProperty, NumericProperty

try:
    import _berkelium as berkelium
except ImportError:
    Logger.critical('Unable to load berkelium extension.')
    Logger.critical('Ensure that you have the good version for your platform')
    raise

# ensure the berkelium binary will be executable
curdir = dirname(__file__)
chmod(join(curdir, 'data', 'berkelium'), 0755)

_berkelium_init = False
_berkelium_listeners = []
_berkelium_counter = 0

def _update_berkelium(*largs):
    berkelium.update()
    global _berkelium_counter, _berkelium_listeners
    _berkelium_counter += 1
    if _berkelium_counter % 30 == 0:
        _berkelium_listeners = [x for x in _berkelium_listeners if x()]
github kivy / kivy / kivy / __init__.py View on Github external
__kivy_post_configuration = []


if platform == 'macosx' and sys.maxsize < 9223372036854775807:
    r = '''Unsupported Python version detected!:
    Kivy requires a 64 bit version of Python to run on OS X. We strongly
    advise you to use the version of Python that is provided by Apple
    (don't use ports, fink or homebrew unless you know what you're
    doing).
    See http://kivy.org/docs/installation/installation-macosx.html for
    details.
    '''
    Logger.critical(r)

if sys.version_info[0] == 2:
    Logger.critical(
        'Unsupported Python version detected!: Kivy 2.0.0 and higher does not '
        'support Python 2. Please upgrade to Python 3, or downgrade Kivy to '
        '1.11.0 - the last Kivy release that still supports Python 2.')


def parse_kivy_version(version):
    """Parses the kivy version as described in :func:`require` into a 3-tuple
    of ([x, y, z], 'rc|a|b|dev|post', 'N') where N is the tag revision. The
    last two elements may be None.
    """
    m = re.match(
        '^([0-9]+)\\.([0-9]+)\\.([0-9]+?)(rc|a|b|\\.dev|\\.post)?([0-9]+)?$',
        version)
    if m is None:
        raise Exception('Revision format must be X.Y.Z[-tag]')
github BillBillBillBill / Tickeys-linux / tickeys / kivy / modules / screen.py View on Github external
def apply_device(device, scale, orientation):
    name, width, height, dpi, density = devices[device]
    if orientation == 'portrait':
        width, height = height, width
    Logger.info('Screen: Apply screen settings for {0}'.format(name))
    Logger.info('Screen: size={0}x{1} dpi={2} density={3} '
                'orientation={4}'.format(width, height, dpi, density,
                                         orientation))
    try:
        scale = float(scale)
    except:
        scale = 1
    environ['KIVY_METRICS_DENSITY'] = str(density * scale)
    environ['KIVY_DPI'] = str(dpi * scale)
    Config.set('graphics', 'width', str(int(width * scale)))
    # simulate with the android bar
    # FIXME should be configurable
    Config.set('graphics', 'height', str(int(height * scale - 25 * density)))
    Config.set('graphics', 'fullscreen', '0')
    Config.set('graphics', 'show_mousecursor', '1')