Python kivy 模块,utils() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用kivy.utils()

项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def loadAESCb(self, path, filename):
        if not filename or len(filename) < 1:
            return

        key = None
        try:
            full = os.path.join(path, filename[0])
            with open(full) as f:
                if full.endswith(".json"):
                    jsonAES = utils.readJsonStream(f)
                    key = jsonAES["base64AESKey"]
                else:
                    key = f.read()

            App.get_running_app().curSearchPath = path
        except (IOError, UnicodeDecodeError, ValueError) as e:
            displayError(e)
        except KeyError:
            displayError(_("Malformed crypto container"))

        self.dismissPopup()
        self.setKey(key)
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def setKey(self, key):
        self._key = None
        try:
            if key is not None:
                self.aes_input.text = key
                k = utils.loadB64Key(key.encode('utf-8'))
                if self._algorithmPrefix not in algorithms.ALGORITHMS:
                    raise receipt.UnknownAlgorithmException(
                            self._receipt.receiptId)
                algorithm = algorithms.ALGORITHMS[self._algorithmPrefix]
                utils.raiseForKey(k, algorithm)
                self._key = k
        except Exception as e:
            self.aes_input.text = ''
            displayError(e)

        if self._key:
            self.decrypt_button.disabled = True
            self.updateView()
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def verify(self):
        if self._verifying:
            self.verifyAbort()
            return

        key = None
        try:
            k = self.aesInput.text
            if k and k != '':
                key = utils.loadB64Key(k.encode('utf-8'))
        except Exception as e:
            self.aesInput.text = ''
            displayError(e)
            return

        self._verifying = True
        self.verify_button.text = _('Verifying...')

        App.get_running_app().pool.apply_async(verifyDEP_prepare_Task,
                (self.dep, App.get_running_app().keyStore, key,
                    App.get_running_app().nprocs),
                callback = self.verifyDEP_prepare_Cb)
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def loadAESCb(self, path, filename):
        if not filename or len(filename) < 1:
            return

        try:
            full = os.path.join(path, filename[0])
            with open(full) as f:
                if full.endswith(".json"):
                    jsonAES = utils.readJsonStream(f)
                    self.aesInput.text = jsonAES["base64AESKey"]
                else:
                    self.aesInput.text = f.read()

            App.get_running_app().curSearchPath = path
        except (IOError, UnicodeDecodeError, ValueError) as e:
            displayError(e)
        except KeyError:
            displayError(_("Malformed crypto container"))

        self.dismissPopup()
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def setKey(self, key):
        self._key = None
        try:
            if key is not None:
                self.aes_input.text = key
                k = utils.loadB64Key(key.encode('utf-8'))
                if self._algorithmPrefix not in algorithms.ALGORITHMS:
                    raise receipt.UnknownAlgorithmException(
                            self._receipt.receiptId)
                algorithm = algorithms.ALGORITHMS[self._algorithmPrefix]
                utils.raiseForKey(k, algorithm)
                self._key = k
        except Exception as e:
            self.aes_input.text = ''
            displayError(e)

        if self._key:
            self.decrypt_button.disabled = True
            self.updateView()
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def verify(self):
        if self._verifying:
            self.verifyAbort()
            return

        key = None
        try:
            k = self.aesInput.text
            if k and k != '':
                key = utils.loadB64Key(k.encode('utf-8'))
        except Exception as e:
            self.aesInput.text = ''
            displayError(e)
            return

        self._verifying = True
        self.verify_button.text = _('Verifying...')

        App.get_running_app().pool.apply_async(verifyDEP_prepare_Task,
                (self.dep, App.get_running_app().keyStore, key,
                    App.get_running_app().nprocs),
                callback = self.verifyDEP_prepare_Cb)
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def loadAESCb(self, path, filename):
        if not filename or len(filename) < 1:
            return

        try:
            full = os.path.join(path, filename[0])
            with open(full) as f:
                if full.endswith(".json"):
                    jsonAES = utils.readJsonStream(f)
                    self.aesInput.text = jsonAES["base64AESKey"]
                else:
                    self.aesInput.text = f.read()

            App.get_running_app().curSearchPath = path
        except (IOError, UnicodeDecodeError, ValueError) as e:
            displayError(e)
        except KeyError:
            displayError(_("Malformed crypto container"))

        self.dismissPopup()
项目:displayminion    作者:cedarsuite    | 项目源码 | 文件源码
def build(self):
        self.title = 'Cedar Display Client'

        if self.config.get('window', 'fullscreen') == 'yes':
            Window.fullscreen = 'auto'

        if kivy.utils.platform is 'windows':
            self.icon = 'logo/logo-128x128.png'
        else:
            self.icon = 'logo/logo-1024x1024.png'

        self.source = DisplaySource(self, pos_hint = {'x': 1, 'y': 1}, size_hint = [None, None])
        self.source.bind(on_touch_down = self.toggle_fullscreen)

        self.layout = FloatLayout()
        self.layout.add_widget(self.source)

        self.ui = UserInterface(self)

        return self.layout
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def importKeyStoreCb(self, path, filename):
        if not filename or len(filename) < 1:
            return

        try:
            full = os.path.join(path, filename[0])
            if full.endswith(".json"):
                with open(full) as f:
                    jsonKS = utils.readJsonStream(f)
                    App.get_running_app().keyStore = \
                            key_store.KeyStore.readStoreFromJson(jsonKS)
            else:
                config = configparser.RawConfigParser()
                config.optionxform = str
                with open(full) as f:
                    config.readfp(f)
                App.get_running_app().keyStore = \
                        key_store.KeyStore.readStore(config)

            App.get_running_app().curSearchPath = path
        except (IOError, UnicodeDecodeError, ValueError,
                configparser.Error) as e:
            displayError(e)
        except KeyError:
            displayError(_("Malformed crypto container"))

        self.dismissPopup()
        self.buildKSTree()
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
def importKeyStoreCb(self, path, filename):
        if not filename or len(filename) < 1:
            return

        try:
            full = os.path.join(path, filename[0])
            if full.endswith(".json"):
                with open(full) as f:
                    jsonKS = utils.readJsonStream(f)
                    App.get_running_app().keyStore = \
                            key_store.KeyStore.readStoreFromJson(jsonKS)
            else:
                config = configparser.RawConfigParser()
                config.optionxform = str
                with open(full) as f:
                    config.readfp(f)
                App.get_running_app().keyStore = \
                        key_store.KeyStore.readStore(config)

            App.get_running_app().curSearchPath = path
        except (IOError, UnicodeDecodeError, ValueError,
                configparser.Error) as e:
            displayError(e)
        except KeyError:
            displayError(_("Malformed crypto container"))

        self.dismissPopup()
        self.buildKSTree()