Ejemplo n.º 1
0
    def build(self):
        if os.path.isfile(SETTINGS_FILE) is False:
            Logger.exception("WeatherPi: Cannot open configuration file %s" % SETTINGS_FILE)
            exit()

        settings = configobj.ConfigObj(SETTINGS_FILE)

        if 'debug' in settings['General']:
            Logger.setLevel(kivy.logger.logging.DEBUG)

        root = BacklightScreenManager(settings)
        root.transition = kivy.uix.screenmanager.SlideTransition()

        root.add_widget(WeatherScreen(settings, name=WEATHER_SCREEN))
        root.add_widget(OptionsScreen(name=OPTIONS_SCREEN))

        self.lifx_screen = LifxScreen(settings, name=LIFX_SCREEN)
        root.add_widget(self.lifx_screen)

        Clock.schedule_interval(root.clock_callback, 1.0)
        return root
Ejemplo n.º 2
0
import logging
import traceback
from concurrent.futures import ThreadPoolExecutor, TimeoutError, as_completed
from os import environ, makedirs
from os.path import exists, join
from random import choice
from time import time

import requests
from kivy.clock import Clock
from kivy.logger import LOG_LEVELS, Logger

from kivy_garden.mapview.constants import CACHE_DIR

if "MAPVIEW_DEBUG_DOWNLOADER" in environ:
    Logger.setLevel(LOG_LEVELS['debug'])

# user agent is needed because since may 2019 OSM gives me a 429 or 403 server error
# I tried it with a simpler one (just Mozilla/5.0) this also gets rejected
USER_AGENT = 'Kivy-garden.mapview'


class Downloader:
    _instance = None
    MAX_WORKERS = 5
    CAP_TIME = 0.064  # 15 FPS

    @staticmethod
    def instance(cache_dir=None):
        if Downloader._instance is None:
            if not cache_dir:
Ejemplo n.º 3
0
 def init_logging(self):
     Logger.setLevel(LOG_LEVELS[self._config["log_level"]])
Ejemplo n.º 4
0
        if not exists(kivy_usermodules_dir):
            mkdir(kivy_usermodules_dir)
        if not exists(kivy_userexts_dir):
            mkdir(kivy_userexts_dir)
        if not exists(icon_dir):
            try:
                shutil.copytree(join(kivy_data_dir, 'logo'), icon_dir)
            except:
                Logger.exception('Error when copying logo directory')

    # configuration
    from kivy.config import Config

    # Set level of logger
    level = LOG_LEVELS.get(Config.get('kivy', 'log_level'))
    Logger.setLevel(level=level)

    # Can be overrided in command line
    if 'KIVY_UNITTEST' not in environ and 'KIVY_PACKAGING' not in environ:
        # save sys argv, otherwize, gstreamer use it and display help..
        sys_argv = sys.argv
        sys.argv = sys.argv[:1]

        try:
            opts, args = getopt(sys_argv[1:], 'hp:fkawFem:sr:dc:', [
                'help', 'fullscreen', 'windowed', 'fps', 'event',
                'module=', 'save', 'fake-fullscreen', 'auto-fullscreen',
                'display=', 'size=', 'rotate=', 'config=', 'debug',
                'dpi='])

        except GetoptError as err:
Ejemplo n.º 5
0
            wrapper = self.wrappers[widget]
        else:
            self.content.append(widget)
            wrapper = MagicScatter(manager=self, screen_name=screen_name, wrapped = widget)
            widget.size_hint = 1,1
            wrapper.add_widget(widget)
            self.wrappers[widget] = wrapper
            widget.size = wrapper.size = self.size
            #print "Addition",widget, wrapper, widget.size, wrapper.size, widget.pos, wrapper.pos
        if len(self.content) == 1:
            super(VirtualScreenManagerBase, self).add_widget(wrapper, index)
            self.current_screen = widget

if __name__ == '__main__':
    from kivy.logger import Logger
    Logger.setLevel('DEBUG')
    try:
        from kivy.factory import Factory
        vskv = """
<VirtualScreen@BoxLayout>:
    orientation: "vertical"
    Button:
        text: "Activate"
        size_hint_y: None
        height: 40
        on_press: content.activated = not content.activated
        canvas.before:
            Color:
                rgb: 0,1,0
            Rectangle:
                size: self.size
Ejemplo n.º 6
0
    def on_stop(self):

        logging.debug("saving checked directory state...")

        unchecked = []

        res = ''

        for widget in self._layout.GetWidgetById('CategoryPanel').children:
            if not widget.ids['chb'].active:
                logging.debug("found unchecked category: %s" %
                              widget.ids['chb'].name)
                unchecked.append(widget.ids['chb'].name)

        if unchecked:

            res = self._imglib._root + '*' + ','.join(unchecked)

        else:
            logging.debug("there is no unchecked boxes")

        self.config.set("ImageLib", "unchecked_categoreis", res)
        self.config.write()


if __name__ == "__main__":

    Logger.setLevel(logging.DEBUG)

    RndArtApp().run()
    from Profiler import Profiler
    ProfilerImported = True
except:
    ProfilerImported = False
    print "WARNING: Failed to import Profiler!"
    traceback.print_exc(file=sys.stdout)

#========================================================================================
# Logging
#========================================================================================

if 0:
    #Use these lines to see all the messages
    from kivy.logger import Logger
    import logging
    Logger.setLevel(logging.TRACE)

#****************************************************************************************
# Camera Analyzer
#****************************************************************************************


class AndroidOpenCV_OpticalAvoider(CustomCameraOpenCV, FloatLayout):
    def __init__(self, *args, **kwargs):

        print "Building Analyzer"

        super(AndroidOpenCV_OpticalAvoider, self).__init__(*args, **kwargs)

        #--- Optical Avoider ---
        self.OpticalAvoider = OpticalAvoider()
Ejemplo n.º 8
0
Archivo: __init__.py Proyecto: ydm/kivy
            Activate a module (use "list" to get a list of available modules).
        -r, --rotation
            Rotate the window's contents (0, 90, 180, 270).
        -s, --save
            Save current Kivy configuration.
        --size=640x480
            Size of window geometry.
        --dpi=96
            Manually overload the Window DPI (for testing only.)
    '''
    print(kivy_usage.__doc__ % (basename(sys.argv[0])))


# Start !
if 'vim' in globals():
    Logger.setLevel(level=LOG_LEVELS.get('critical'))
else:
    Logger.setLevel(level=LOG_LEVELS.get('info'))
    Logger.info('Kivy v%s' % (__version__))

#: Global settings options for kivy
kivy_options = {
    'window': ('egl_rpi', 'pygame', 'sdl', 'x11'),
    'text': ('pil', 'pygame', 'sdlttf'),
    'video': ('ffmpeg', 'gstreamer', 'pyglet', 'null'),
    'audio': ('pygame', 'gstreamer', 'sdl'),
    'image': ('tex', 'imageio', 'dds', 'gif', 'pil', 'pygame'),
    'camera': ('opencv', 'gstreamer', 'videocapture'),
    'spelling': (
        'enchant',
        'osxappkit',
Ejemplo n.º 9
0
def getLogger(debug=False, fileHandler=None):
    Logger.setLevel(logging.DEBUG)
    if fileHandler != None:
        Logger.addHandler(fileHandler)
    return Logger
Ejemplo n.º 10
0
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.graphics.texture import Texture
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.camera import Camera
from kivy.core.image import Image
from functools import partial
from kivy.logger import Logger
import logging

from classify_object import Classifier

Logger.setLevel(logging.TRACE)

trainImgPaths = "/pyimagesearch/dataset/images"
maskImgPaths = None

class TestCameraBox(BoxLayout):

    def classify(self, event):
        self.classifier.classify(None)
        print("Classify")

    def capture(self, event):
        if (self.camera.play):
            self.camera.play = False
            img = Image(self.camera.texture)
            img.save("capture.png")
            self.captureButton.text="Take another"
Ejemplo n.º 11
0
        from conf import gamepath
        "Create Game Folder"
        # ~ 1.Get Current game name
        gameId=self.selected_game
        gameName=self.ids.details.title
        # ~ 2. Create folder for current game name
        import os.path
        path=os.path.join(gamepath,gameName)
        if os.path.isdir(path):
            alert('Already Existing folder for %s in %s. Aborting'%(gameName,gamepath))
        else:
            os.mkdir(path)
            # ~ 3. create subfolders: rule, img, old , export
            os.mkdir(os.path.join(path, 'rules'))
            os.mkdir(os.path.join(path, 'img'))
            os.mkdir(os.path.join(path, 'download'))
            os.mkdir(os.path.join(path, 'export-%s'%gameName))
        output = file(os.path.join(path, 'description.txt'),'wb')
        output.write('Game Description:\n')
        output.write(self.ids.details.ids.description.text)
        output.write('\n\nMore Information:')
        output.write(self.ids.details.ids.information.text.encode('cp1252'))
        from utils import start_file
        start_file(path)

if __name__=='__main__':
    from kivy.logger import Logger
    Logger.setLevel('WARNING')
    from kivy.base import runTouchApp
    runTouchApp((BGGeekBrowser()))
Ejemplo n.º 12
0
import os

from kivy.logger import Logger

from chipper.analysis import Song
from chipper.command_line import run_analysis
Logger.setLevel(2)


def test_song_class():
    f_path = os.path.join(os.path.dirname(__file__), 'test_data', 'test.gzip')
    results = Song(f_path, 50, 40).run_analysis()
    assert len(results) == 44


def test_command_line():
    f_path = os.path.join(os.path.dirname(__file__), 'test_data')
    run_analysis(f_path, 50, 40, 'output_test')


if __name__ == '__main__':
    test_command_line()
Ejemplo n.º 13
0
        if self.do_collide_after_children:
            if not self.collide_point(x, y):
                return False

        if 'multitouch_sim' in touch.profile:
            touch.multitouch_sim = True
        # grab the touch so we get all it later move events for sure
        self._bring_to_front(touch)
        touch.grab(self)
        self._touches.append(touch)
        self._last_touch_pos[touch] = touch.pos

        return True

from kivy.factory import Factory
Factory.register('NoRatioScatter', NoRatioScatter)

if __name__ == '__main__':
    from kivy.logger import Logger
    Logger.setLevel("WARNING")
    from kivy.base import runTouchApp
    from kivy.uix.floatlayout import FloatLayout
    from kivy.uix.image import Image
    fl = FloatLayout()
    a= NoRatioScatter()
    img = Image(source='images/judge.jpg')
    fl.add_widget(a)
    a.add_widget(img)

    runTouchApp(fl)
            Logger.info(
                "Could not perform mod {} cleanup. Marking torrent as dirty.".
                format(mod.foldername))
            metadata_file.set_dirty(True)
            metadata_file.write_data()

            return False
        else:
            metadata_file.set_dirty(False)
            metadata_file.write_data()

        return True


if __name__ == '__main__':
    Logger.setLevel(level='INFO')

    class DummyMod:
        def __init__(self, torrent_url, parent_location, foldername,
                     full_name):
            self.torrent_url = torrent_url
            self.parent_location = parent_location
            self.foldername = foldername
            self.full_name = full_name

    class DummyQueue:
        def progress(self, d, frac):
            Logger.info('Progress: {}'.format(unicode(d)))

        def reject(self, d):
            Logger.error('Reject: {}'.format(unicode(d)))
Ejemplo n.º 15
0
            Activate a module (use "list" to get a list of available modules).
        -r, --rotation
            Rotate the window's contents (0, 90, 180, 270).
        -s, --save
            Save current Kivy configuration.
        --size=640x480
            Size of window geometry.
        --dpi=96
            Manually overload the Window DPI (for testing only.)
    """
    print(kivy_usage.__doc__ % (basename(sys.argv[0])))


# Start !
if "vim" in globals():
    Logger.setLevel(level=LOG_LEVELS.get("critical"))
else:
    Logger.setLevel(level=LOG_LEVELS.get("info"))
    Logger.info("Kivy v%s" % (__version__))

#: Global settings options for kivy
kivy_options = {
    "window": ("egl_rpi", "pygame", "sdl", "x11"),
    "text": ("pil", "pygame", "sdlttf"),
    "video": ("ffmpeg", "gstreamer", "pyglet", "null"),
    "audio": ("pygame", "gstreamer", "sdl"),
    "image": ("tex", "imageio", "dds", "gif", "pil", "pygame"),
    "camera": ("opencv", "gstreamer", "videocapture"),
    "spelling": ("enchant", "osxappkit"),
    "clipboard": ("pygame", "dummy"),
}
Ejemplo n.º 16
0
 def on_start(self):
     self.icon = 'icon.ico'
     Logger.setLevel(LOG_LEVELS["debug"])
     self.zip_path = None
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License for more details. You should
# have received a copy of the GNU General Public License along with
# this code. If not, see <http://www.gnu.org/licenses/>.

import unittest
from mock import patch
import mock
import socket
from autosportlabs.telemetry.telemetryconnection import TelemetryConnection, TelemetryManager
import asyncore
import json
import random
from kivy.logger import Logger
Logger.setLevel(51)  # Hide all Kivy Logger calls

@patch.object(asyncore, 'loop')
class TelemetryConnectionTest(unittest.TestCase):

    def setUp(self):
        self.host = 'foobar.baz'
        self.port = 8080
        self.device_id = 'DFDS44'

        self.meta = {}
        self.meta['foo'] = mock.Mock(units="F", sampleRate="10", min=0, max=100)
        self.meta['bar'] = mock.Mock(units="C", sampleRate="1", min=-100, max=200)
        self.meta['baz'] = mock.Mock(units="C", sampleRate="1", min=-100, max=200)

        # Mock's constructor treats 'name' in a special way, it won't return a string
Ejemplo n.º 18
0
    SurveyInstanceRepositoryInMem
from .survey.infra.tip_repository_json import TipRepositoryJson
from .survey.infra.tip_history_inmem import TipHistoryRepositoryInMem
from .survey.survey_controller import SurveyController

import config as cfg
from .actors.eca import ECA
from .actors.user import USER

logger = logging.getLogger().getChild(__package__)

if __name__ == '__main__':
    os.environ["KIVY_NO_CONSOLELOG"] = "1"
    from kivy.logger import Logger
    from kivy.config import Config
    Logger.setLevel(logging.INFO)
    Config.set('kivy', 'log_dir', 'D:\\kivy_logs\\')

    logger.info('\nagent: %s \nuser: %s', cfg.agent, cfg.user)

    eca = ECA(**cfg.agent)
    user = USER(**cfg.user)

    with ThreadPoolExecutor() as executor:
        speech_recognizer = GoogleSpeechRecognizer(
            sample_rate_hertz=DEFAULT_RATE)
        mock_speech_recognizer = MockSpeechRecognizer()

        async_speech_recognizer = AsyncSpeechRecognizer(
            executor=executor, recognizer=speech_recognizer)
Ejemplo n.º 19
0
        if not exists(kivy_home_dir):
            mkdir(kivy_home_dir)
        if not exists(kivy_usermodules_dir):
            mkdir(kivy_usermodules_dir)
        if not exists(icon_dir):
            try:
                shutil.copytree(join(kivy_data_dir, 'logo'), icon_dir)
            except:
                Logger.exception('Error when copying logo directory')

    # configuration
    from kivy.config import Config

    # Set level of logger
    level = LOG_LEVELS.get(Config.get('kivy', 'log_level'))
    Logger.setLevel(level=level)

    # Can be overrided in command line
    if ('KIVY_UNITTEST' not in environ and
            'KIVY_PACKAGING' not in environ and
            'KIVY_NO_ARGS' not in environ):
        # save sys argv, otherwise, gstreamer use it and display help..
        sys_argv = sys.argv
        sys.argv = sys.argv[:1]

        try:
            opts, args = getopt(sys_argv[1:], 'hp:fkawFem:sr:dc:', [
                'help', 'fullscreen', 'windowed', 'fps', 'event',
                'module=', 'save', 'fake-fullscreen', 'auto-fullscreen',
                'multiprocessing-fork', 'display=', 'size=', 'rotate=',
                'config=', 'debug', 'dpi='])
Ejemplo n.º 20
0
from .. import directories
import base64
import configparser
from kivy.logger import Logger
import logging

from hardline import daemonconfig
logging.Logger.manager.root = Logger




# Terrible Hacc, because otherwise we cannot iumport hardline on android.


Logger.setLevel(LOG_LEVELS["info"])



# In this mode, we are just acting as a viewer for a file
oneFileMode = False




class ServiceApp(MDApp, uihelpers.AppHelpersMixin, tools.ToolsAndSettingsMixin, servicesUI.ServicesMixin, discovery.DiscoveryMixin, tables.TablesMixin, posts.PostsMixin, streams.StreamsMixin):

    def stop_service(self, foo=None):
        if self.service:
            self.service.stop()
            self.service = None
Ejemplo n.º 21
0
def bookblock(source_dir, target_dir, source_file_format, target_file_format,
              pages, geometry, image_mode, view_mode, examples, debug):
    """Cut out pages from book scans.
    """

    # Resetting `sys.argv':
    #
    # The bookblock command line options disturb Kivy:
    # See file site-packages/kivy/__init__.py :
    #
    #     try:
    #         opts, args = getopt(sys_argv[1:], 'hp:fkawFem:sr:dc:', [
    #             'help', 'fullscreen', 'windowed', 'fps', 'event',
    #             'module=', 'save', 'fake-fullscreen', 'auto-fullscreen',
    #             'multiprocessing-fork', 'display=', 'size=', 'rotate=',
    #             'config=', 'debug', 'dpi='])
    #
    #     except GetoptError as err:
    #         Logger.error('Core: %s' % str(err))
    #         kivy_usage()
    #
    # Example: the option `--source-dir <dir>' causes the following error:
    #
    #   Core: option --source-dir not recognized
    #
    # Therefore only options relevant for Kivy should be
    # contained in sys.argv when starting to deal with Kivy code:
    sys.argv = [sys.argv[1]]

    if debug in ['trace', 'debug', 'info']:
        print("DEBUG bookblock:")
        print("")
        print("  - source_dir:         {}".format(source_dir))
        print("  - target_dir:         {}".format(target_dir))
        print("  - source_file_format: {}".format(source_file_format))
        print("  - target_file_format: {}".format(target_file_format))
        print("  - pages:              {}".format(pages))
        print("  - geometry:           {}".format(geometry))
        print("  - image_mode:         {}".format(image_mode))
        print("  - view_mode:          {}".format(view_mode))
        print("  - examples:           {}".format(examples))
        print("  - debug:              {}".format(debug))

    # Show examples?
    if examples:
        print_examples()
        exit()

    # Settings
    settings = Settings() \
        .set_debug_level(debug) \
        .set_image_mode(image_mode) \
        .set_view_mode(view_mode) \
        .set_source_dir(source_dir) \
        .set_target_dir(target_dir) \
        .set_source_file_format(source_file_format) \
        .set_target_file_format(target_file_format) \
        .set_geometry(geometry) \
        .set_pages(pages)

    # Print settings
    settings.print_settings()

    # Hack to silently import Kivy's noisy logger:
    # The logger prints all kind of messages before the log level can be set
    # and seems to ignore its config file log level settings as well
    # (Kivy's config is at ~/.kivy/config.ini)
    if not debug in ['trace', 'debug', 'info']:

        # Silence stderr
        orig_stderr = sys.stderr
        sys.stderr = open(os.devnull, "w")

        # Import Kivy's logger
        from kivy.logger import Logger, LOG_LEVELS

        # Set the log level
        Logger.setLevel(level=LOG_LEVELS.get(debug))

        # Restore stdout
        sys.stderr = orig_stderr

    # Start the GUI
    # For some reason BookBlockApp cannot be imported before
    # as it seems to interfere with click
    from newskylabs.tools.bookblock.gui.main import BookBlockApp
    app = BookBlockApp(settings)
    app.run()

    # done :)
    print("")
    print("Bye :)")
    print("")
    exit()
Ejemplo n.º 22
0
        -p, --provider id:provider[,options]
            Add an input provider (eg: ccvtable1:tuio,192.168.0.1:3333).
        -m mod, --module=mod
            Activate a module (use "list" to get a list of available modules).
        -r, --rotation
            Rotate the window's contents (0, 90, 180, 270).
        -s, --save
            Save current Kivy configuration.
        --size=640x480
            Size of window geometry.
    '''
    print kivy_usage.__doc__ % (basename(sys.argv[0]))


# Start !
Logger.setLevel(level=LOG_LEVELS.get('info'))
Logger.info('Kivy v%s' % (__version__))

#: Global settings options for kivy
kivy_options = {
    'window': ('pygame', ),
    'text': ('pil', 'cairo', 'pygame'),
    'video': ('ffmpeg', 'gstreamer', 'pyglet'),
    'audio': ('pygame', 'gstreamer', ),
    'image': ('dds', 'gif', 'pil', 'pygame'),
    'camera': ('opencv', 'gstreamer', 'videocapture'),
    'spelling': ('enchant', 'osxappkit', ),
    'clipboard': ('pygame', 'dummy'), }

# Read environment
for option in kivy_options:
Ejemplo n.º 23
0
            if k in ['mappings', 'profile', 'kv_file']:
                settings[k] = os.path.abspath(os.path.join(os.path.dirname(settings_file), os.path.expandvars(settings[k])))
                if not os.path.isfile(settings[k]) or not os.path.getsize(settings[k]) > 0:
                    Logger.error("init: File Not Found '{0}'".format(settings[k]))
                    sys.exit(1)

        # set kv_file if override exists
        k = settings.pop('kv_file', None)
        if k:
        	self.kv_file = k
        self.settings = settings

        # our init is done, call parent class init to finish
        App.__init__(self)
        return

    def build(self):
        return SwitchPanel(**self.settings)

    def on_stop(self):
        self.root.shutdown()
        return


if __name__ == '__main__':
    h = logging.handlers.RotatingFileHandler(filename=os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), 'client.log')), maxBytes=1024*1024, backupCount=9)
    h.setLevel(logging.INFO)
    Logger.addHandler(h)
    Logger.setLevel(logging.INFO)
    defaultApp().run()
Ejemplo n.º 24
0
    def init_logger(self):

        # Store log messages until logger is configured
        log_messages = []

        # Init log level from ~/.bookblock or the defaults
        config = self.config
        log_dir    = config.get('logger', 'log_dir')
        log_name   = config.get('logger', 'log_name')
        log_level  = config.get('logger', 'log_level')
        log_enable = config.getint('logger', 'log_enable')
        #| log_maxfiles = config.getint('logger', 'log_maxfiles')

        # Ensure that log directory exists
        log_dir_path = PosixPath(log_dir).expanduser()
        print("log_dir_path:", log_dir_path)
        if not Path(log_dir_path).exists():
            log_messages.append("Creating log directory: {}".format(log_dir))
            log_dir_path.mkdir(parents=True, exist_ok=True)

        # Substitute the log file name format patterns with actual values
        # %y -> year, %m -> month, %d -> day, %_ -> next log file number
        log_file = log_name.replace('%_', '@@NUMBER@@')
        log_file = strftime(log_file)
        log_file = '{}/{}'.format(str(log_dir_path), log_file)
        n = 0
        while True:
            log_file2 = log_file.replace('@@NUMBER@@', str(n))
            if not os.path.exists(log_file2):
                log_file = log_file2
                break
            n += 1
            if n > 10000:  # prevent maybe flooding ?
                raise Exception('Too many logfile, remove them')
            
        # Open log file
        # and substitue it for the kivy log file (~/kivy/logs/...
        FileHandler.filename = str(log_file)
        if FileHandler.fd is not None:
            FileHandler.fd.close()
        FileHandler.fd = open(log_file, 'w')
        log_messages.append('Logger: Record log in %s' % log_file)

        # Log level
        # Command line option --debug overwrites settings
        log_level_option = self._settings.get_debug_level()
        if log_level_option != None:
            log_level = log_level_option

        # Convert to logging debug level
        log_level_code = LOG_LEVELS.get(log_level.lower())

        # When log_level is not one of 
        # trace, debug, info, warning, error, critical, 
        # None is returned.
        if log_level_code == None:
            log_levels = ['trace', 'debug', 'info', 'warning', 'error', 'critical']
            print("ERROR Undefined log level: {}\n".format(log_level) +
                  "Defined are only the following: {}.".format(', '.join(log_levels)),
                  file=sys.stderr)
            exit(-1)

        # Set log level
        Logger.setLevel(log_level_code)

        # En- / Disable logger
        Logger.logfile_activated = bool(log_enable)

        # TODO Purge old logs
        # See site-packages/kivy/logger.py, class FileHandler, method purge_logs() 
        # for an example of how to purge old logs.

        # Log stored log messages
        for msg in log_messages:
            Logger.info(msg)
            
        # Log some general information about Python, Kivy etc.
        
        # Kivys default logging level is info
        # In order to suppress the initial INFO messages printed when kivy is loaded
        # until the log level for `bookblock' is set
        # I set the level to WARNING by in file ~/.kivy/config.ini
        # > [kivy]
        # > #log_level = info
        # > log_level = warning
        # Some of the suppressed information is printed now
        # when the bookblock log level is lower or equal to INFO

        Logger.info('Kivy: v%s' % kivy.__version__)
        Logger.info('Kivy: Installed at "{}"'.format(kivy.__file__))
        Logger.info('Python: v{}'.format(sys.version))
        Logger.info('Python: Interpreter at "{}"'.format(sys.executable))
        Logger.info('Bookblock: Installed at "{}"'.format(dirname(dirname(__file__))))
        Logger.info('Bookblock: To avoid the Kivy startup INFO messages '
                    'change the kivy log level to WARNING '
                    'in ~/.kivy/config.ini')
        Logger.info('Bookblock: To avoid further messages from Bookblock '
                    'adapt the Bookblock log level in '
                    'in ~/.bookblock')
        Logger.info('Bookblock: For more debug information '
                    'change the kivy log level in ~/.kivy/config.ini '
                    'and the Bookblock log level in ~/.bookblock/config.ini '
                    'to TRACE, DEBUG, or INFO.')
Ejemplo n.º 25
0
import random

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Ellipse, Line, Rectangle
from kivy.properties import ObjectProperty, BooleanProperty, StringProperty
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition, FallOutTransition, NoTransition
from kivy.uix.boxlayout import BoxLayout
from kivy.garden.graph import Graph, LinePlot
from kivy.clock import Clock

from kivy.logger import Logger

import logging
Logger.setLevel(logging.DEBUG)

import rospy
import rospkg
from geometry_msgs.msg import PoseStamped
from nav_msgs.msg import Path
from nao_writing_msgs.msg import MultiPaths

class PainterBox(Widget):
    btn = ObjectProperty()


    def __init__(self, **kwargs):
        super(PainterBox, self).__init__(**kwargs)
        self.color = (random.random(), 1., 1.)
        self.lines = []
Ejemplo n.º 26
0
Uses kaki module for Hot Reload (limited to some uses cases).
Before using, install kaki by `pip install kaki`

"""

import os
import platform
import sys

root_dir = os.path.split(os.path.abspath(sys.argv[0]))[0]
sys.path.insert(0, os.path.join(root_dir, "libs", "applibs"))

from kaki.app import App as HotReloaderApp  # NOQA: E402
from kivy.logger import LOG_LEVELS, Logger  # NOQA: E402

Logger.setLevel(LOG_LEVELS["debug"])

from kivy.core.window import Window  # NOQA: E402
from kivymd.app import MDApp  # NOQA: E402

from libs.uix.baseclass.root import Root  # NOQA: E402

# This is needed for supporting Windows 10 with OpenGL < v2.0
if platform.system() == "Windows":
    os.environ["KIVY_GL_BACKEND"] = "angle_sdl2"

KV_FOLDER = os.path.join(os.getcwd(), "libs", "uix", "kv")


class PROJECT_NAME(MDApp, HotReloaderApp):
    DEBUG = 1  # To enable Hot Reload
Ejemplo n.º 27
0
            Activate a module (use "list" to get a list of available modules).
        -r, --rotation
            Rotate the window's contents (0, 90, 180, 270).
        -s, --save
            Save current Kivy configuration.
        --size=640x480
            Size of window geometry.
        --dpi=96
            Manually overload the Window DPI (for testing only.)
    '''
    print(kivy_usage.__doc__ % (basename(sys.argv[0])))


# Start !
if 'vim' in globals():
    Logger.setLevel(level=LOG_LEVELS.get('critical'))
else:
    Logger.setLevel(level=LOG_LEVELS.get('info'))
    Logger.info('Kivy v%s' % (__version__))

#: Global settings options for kivy
kivy_options = {
    'window': ('egl_rpi', 'pygame', 'sdl', 'x11'),
    'text': ('pil', 'pygame', 'sdlttf'),
    'video': ('gstplayer', 'ffmpeg', 'gi', 'pygst', 'pyglet', 'null'),
    'audio': ('gstplayer', 'pygame', 'gi', 'pygst', 'sdl'),
    'image': ('tex', 'imageio', 'dds', 'gif', 'pil', 'pygame'),
    'camera': ('opencv', 'gi', 'pygst', 'videocapture', 'avfoundation'),
    'spelling': ('enchant', 'osxappkit', ),
    'clipboard': ('android', 'pygame', 'dummy'), }
Ejemplo n.º 28
0
def pytest_configure(config):
    Logger.setLevel(LOG_LEVELS["error"])