From 8af4942857cb8eb906056df4c4ae7ffefe9e229c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Tue, 13 Apr 2010 21:21:56 +0200 Subject: Better eix error inheritance and handling --- portato/eix/exceptions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/portato/eix/exceptions.py b/portato/eix/exceptions.py index 1ca05e1..cc4665d 100644 --- a/portato/eix/exceptions.py +++ b/portato/eix/exceptions.py @@ -23,7 +23,14 @@ class EixError (Exception): :ivar message: The error message """ + message = _("Unknown error.") + + def __init__ (self, msg = None): + Exception.__init__(self) + + if msg: + self.message = msg def __str__ (self): return self.message @@ -34,7 +41,7 @@ class EndOfFileException (EixError): """ def __init__ (self, filename): - self.message = _("End of file reached though it was not expected: '%s'") % filename + EixError.__init__(self, _("End of file reached though it was not expected: '%s'") % filename) class UnsupportedVersionError (EixError): """ @@ -42,4 +49,4 @@ class UnsupportedVersionError (EixError): """ def __init__ (self, version): - self.message = _("Version '%s' is not supported.") % version + EixError.__init__(self, _("Version '%s' is not supported.") % version) -- cgit v1.2.3 From 9c277a984863d4a5e509efb19db65c684b242ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 14 Apr 2010 03:22:55 +0200 Subject: Disable debug messages by default --- etc/portato.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/portato.cfg b/etc/portato.cfg index 10f5445..47335ea 100644 --- a/etc/portato.cfg +++ b/etc/portato.cfg @@ -24,7 +24,7 @@ system = portage ; controls debug output - boolean value -debug = True +debug = False ; the command used for syncing portage - string value synccommand = emerge --sync -- cgit v1.2.3 From efd5aa7d6e66cc1ab201d5fc5933787a7c8690b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 14 Apr 2010 04:42:56 +0200 Subject: Fixed the unicode support and stuff ... and also made eix faster :) --- portato/eix/parser.pyx | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/portato/eix/parser.pyx b/portato/eix/parser.pyx index 6363b37..4315191 100644 --- a/portato/eix/parser.pyx +++ b/portato/eix/parser.pyx @@ -33,6 +33,8 @@ cdef extern from "stdio.h": cdef extern from "Python.h": FILE* PyFile_AsFile(object) +cimport python_unicode + ctypedef unsigned char UChar ctypedef long long LLong @@ -54,7 +56,15 @@ cdef int _get_byte (FILE* file) except -1: # Base Types # -cdef LLong _number (object pfile): +cpdef LLong number (object pfile): + """ + Returns a number. + + :param file: The file to read from + :type file: file + :rtype: int + """ + cdef UChar n cdef LLong value cdef int i @@ -84,18 +94,7 @@ cdef LLong _number (object pfile): return value -def number (file): - """ - Returns a number. - - :param file: The file to read from - :type file: file - :rtype: int - """ - - return _number(file) - -def vector (file, get_type, nelems = None): +cpdef object vector (object file, object get_type, object nelems = None): """ Returns a vector of elements. @@ -118,13 +117,13 @@ def vector (file, get_type, nelems = None): cdef LLong i if nelems is None: - n = _number(file) + n = number(file) else: n = nelems return [get_type(file) for i in range(n)] -def string (file): +cpdef object string (object file, char u = 0): """ Returns a string. @@ -132,13 +131,16 @@ def string (file): :type file: file :rtype: str """ - nelems = _number(file) + cdef LLong nelems = number(file) s = file.read(nelems) if len(s) != nelems: raise EndOfFileException, file.name + if u: + return python_unicode.PyUnicode_DecodeUTF8(s, nelems, 'replace') + return s # @@ -220,8 +222,8 @@ cdef class header: :param file: The file to read from :type file: file """ - self.version = _number(file) - self.ncats = _number(file) + self.version = number(file) + self.ncats = number(file) self.overlays = vector(file, overlay) self.provide = vector(file, string) self.licenses = vector(file, string) @@ -274,12 +276,12 @@ cdef class package: cdef FILE* cfile = PyFile_AsFile(file) cdef long after_offset - self._offset = _number(file) + self._offset = number(file) after_offset = ftell(cfile) self.name = string(file) - self.description = unicode(string(file)) + self.description = string(file,1) # skip the rest, as it is currently unneeded #self.provide = vector(file, number) -- cgit v1.2.3 From 0f19f73c55ea8c8188aec7426ea94bfb7a823720 Mon Sep 17 00:00:00 2001 From: Clement Bourgeois Date: Wed, 14 Apr 2010 11:28:29 +0800 Subject: Small modifications made to the French translation (typos, grammar). --- i18n/fr.po | 138 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/i18n/fr.po b/i18n/fr.po index 8116646..ee1aef7 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: Portato\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-04-11 17:29+0200\n" -"PO-Revision-Date: 2010-04-12 23:00+0100\n" +"POT-Creation-Date: 2010-04-14 05:04+0200\n" +"PO-Revision-Date: 2010-04-14 05:22+0100\n" "Last-Translator: Clément Bourgeois \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -19,11 +19,11 @@ msgstr "Greffons" #: portato/gui/templates/PluginWindow.ui:53 msgid "_Install dependencies" -msgstr "_Installer les dépendences" +msgstr "_Installer les dépendances" #: portato/gui/templates/PluginWindow.ui:83 msgid "Needed dependencies" -msgstr "Dépendances nécéssaires" +msgstr "Dépendances nécessaires" #: portato/gui/templates/PluginWindow.ui:97 #: portato/gui/templates/PluginWindow.ui:122 @@ -33,7 +33,7 @@ msgstr "Dépendances nécéssaires" #: portato/gui/templates/MainWindow.ui:432 #: portato/gui/templates/PreferenceWindow.ui:182 msgid "label" -msgstr "etiquette" +msgstr "étiquette" #: portato/gui/templates/PluginWindow.ui:108 msgid "Author:" @@ -168,14 +168,14 @@ msgid "Queue" msgstr "File d'attente" #: portato/gui/templates/MainWindow.ui:806 -#: portato/gui/windows/main.py:1253 -#: portato/gui/windows/main.py:1255 +#: portato/gui/windows/main.py:1263 +#: portato/gui/windows/main.py:1265 msgid "Console" msgstr "Console" #: portato/gui/templates/MainWindow.ui:840 msgid "Log" -msgstr "Log" +msgstr "Journal" #: portato/gui/templates/PreferenceWindow.ui:12 msgid "Preferences" @@ -204,7 +204,7 @@ msgstr "Type de base de données utilisée" #: portato/gui/templates/PreferenceWindow.ui:192 msgid "Description" -msgstr "Déscription" +msgstr "Description" #: portato/gui/templates/PreferenceWindow.ui:208 msgid "Database Options" @@ -280,7 +280,7 @@ msgstr "Keywords Masquants" #: portato/gui/templates/PreferenceWindow.ui:607 msgid "Use Flag and Keyword Options" -msgstr "Options des flags Use et des Keywords" +msgstr "Options des Flags Use et des Keywords" #: portato/gui/templates/PreferenceWindow.ui:663 msgid "Enable systray" @@ -304,7 +304,7 @@ msgstr "Onglets Paquetages" #: portato/gui/templates/PreferenceWindow.ui:793 msgid "System Tabs" -msgstr "Onglets système" +msgstr "Onglets Système" #: portato/gui/templates/PreferenceWindow.ui:821 msgid "Tab Options" @@ -320,7 +320,7 @@ msgstr "Réduire les catégories avec le même préfixe" #: portato/gui/templates/PreferenceWindow.ui:884 msgid "Package Options" -msgstr "Options de paquetage" +msgstr "Options des Paquetages" #: portato/gui/templates/PreferenceWindow.ui:921 msgid "Console Font" @@ -365,11 +365,11 @@ msgstr "Sélectionner _Tout" #: portato/gui/templates/PkgListWindow.ui:80 msgid "_Install Selected" -msgstr "_Installer selectionnés" +msgstr "_Installer sélectionnés" #: portato/gui/templates/PkgListWindow.ui:96 msgid "_Uninstall Selected" -msgstr "_Desinstaller selectionnés" +msgstr "_Desinstaller sélectionnés" #: portato/gui/templates/MailInfoWindow.ui:6 msgid "Send Bug Mail ..." @@ -381,7 +381,7 @@ msgid "" "\n" "(all optional)" msgstr "" -"Informations additionnelles\n" +"Informations Additionnelles\n" "\n" "(toutes optionnelles)" @@ -513,7 +513,7 @@ msgstr "Impossible de démarrer etc-proposals. Vous n'êtes pas root !" #: plugins/package_details.py:73 msgid "Shows the Changelog of a package" -msgstr "Affiche le changelog du paquetage" +msgstr "Affiche le Journal des changements apportés au paquetage" #: plugins/package_details.py:75 msgid "Changelog" @@ -571,58 +571,58 @@ msgstr "Tous les suivants" msgid "Can't display dependencies: This package has an unsupported dependency string." msgstr "Impossible d'afficher les dépendances : ce paquetage comporte une chaîne de dépendance non supportée." -#: portato/plugin.py:446 -#: portato/plugin.py:449 -#: portato/plugin.py:459 +#: portato/plugin.py:444 +#: portato/plugin.py:447 +#: portato/plugin.py:457 #, python-format msgid "Loading plugin '%(plugin)s' failed: %(error)s" msgstr "Enregistrement du greffon '%(plugin)s' échoué : %(error)s" -#: portato/plugin.py:462 +#: portato/plugin.py:460 #, python-format msgid "Loading widgets of plugin '%(plugin)s' failed: %(error)s" msgstr "Chargement des widgets du greffon '%(plugin)s' impossible : %(error)s" -#: portato/plugin.py:466 +#: portato/plugin.py:464 #, python-format msgid "Widgets of plugin '%s' loaded." msgstr "Widgets du greffon '%s' chargés." -#: portato/plugin.py:497 +#: portato/plugin.py:495 msgid "Plugin is disabled!" msgstr "Le greffon est désactivé !" -#: portato/plugin.py:499 +#: portato/plugin.py:497 msgid "Plugin has unresolved dependencies - disabled!" msgstr "Le greffon a des dépendances non résolues - désactivé !" -#: portato/plugin.py:503 +#: portato/plugin.py:501 #, python-format msgid "Plugin '%s' loaded." msgstr "Greffon '%s' chargé." -#: portato/plugin.py:543 +#: portato/plugin.py:541 #, python-format msgid "Overriding hook '%(hook)s' with plugin '%(plugin)s'." msgstr "Surcharge du hook '%(hook)s' avec le greffon '%(plugin)s'." -#: portato/plugin.py:601 +#: portato/plugin.py:599 #, python-format msgid "For hook '%(hook)s' an override is already defined by plugin '%(plugin)s'!" msgstr "Une surcharge est déjà définie pour le hook '%(hook)s' par le greffon '%(plugin)s'!" -#: portato/plugin.py:602 +#: portato/plugin.py:600 #, python-format msgid "It is now replaced by the one from plugin '%s'!" msgstr "Il est maintenant remplacé par celui du greffon '%s' !" -#: portato/plugin.py:635 +#: portato/plugin.py:633 #, python-format msgid "Dependant '%(dep)s' for '%(hook)s' in plugin '%(plugin)s' not found! Adding nevertheless." msgstr "Le dépendant '%(dep)s' pour le hook '%(hook)s' du greffon '%(plugin)s' trouvé ! Ajouté quand même." -#: portato/plugin.py:704 -#: portato/plugin.py:707 +#: portato/plugin.py:702 +#: portato/plugin.py:705 #, python-format msgid "Registrating plugin '%(plugin)s' failed: %(error)s" msgstr "Enregistrement du greffon '%(plugin)s' échoué : %(error)s" @@ -641,7 +641,7 @@ msgstr "Fin de fichier atteinte de façon inattendue : '%s'" msgid "Version '%s' is not supported." msgstr "La version '%s' n'est pas supportée." -#: portato/config_parser.py:266 +#: portato/config_parser.py:268 #, python-format msgid "Unrecognized line in configuration: %s" msgstr "Ligne non reconnue dans la configuration : %s" @@ -685,7 +685,7 @@ msgstr "Bogue détecté" #: portato/gui/exception_handling.py:32 msgid "It probably isn't fatal, but should be reported to the developers nonetheless." -msgstr "Cette erreur n'est probablement pas fatale, mais devrait être reportée au développeurs quand même." +msgstr "Cette erreur n'est probablement pas fatale, mais devrait être reportée aux développeurs quand même." #: portato/gui/exception_handling.py:34 msgid "Show Details" @@ -699,45 +699,45 @@ msgstr "Envoyer..." msgid "Save traceback..." msgstr "Sauvegarder la trace..." -#: portato/gui/utils.py:189 +#: portato/gui/utils.py:187 msgid "oneshot" msgstr "oneshot" -#: portato/gui/utils.py:194 +#: portato/gui/utils.py:192 #, python-format msgid "updating from version %s" msgstr "mise-à-jour depuis la version %s." -#: portato/gui/utils.py:196 +#: portato/gui/utils.py:194 msgid "updating" msgstr "mise à jour" -#: portato/gui/utils.py:201 +#: portato/gui/utils.py:199 #, python-format msgid "downgrading from version %s" msgstr "rétrogradation depuis la version %s" -#: portato/gui/utils.py:203 +#: portato/gui/utils.py:201 msgid "downgrading" msgstr "rétrogradation" -#: portato/gui/utils.py:207 +#: portato/gui/utils.py:205 msgid "IUSE changes:" msgstr "Changements IUSE :" -#: portato/gui/utils.py:225 +#: portato/gui/utils.py:223 msgid "(In Progress)" msgstr "(En cours)" -#: portato/gui/utils.py:250 +#: portato/gui/utils.py:248 msgid "Install" msgstr "Installer" -#: portato/gui/utils.py:261 +#: portato/gui/utils.py:259 msgid "Uninstall" msgstr "Désinstaller" -#: portato/gui/utils.py:273 +#: portato/gui/utils.py:271 msgid "Update" msgstr "Mettre à jour" @@ -767,7 +767,7 @@ msgstr "Aucun ancien fichier de langage %(old)s installé. Desactivation de la c #: portato/gui/session.py:21 msgid "Version mismatch." -msgstr "Version en discordance" +msgstr "Version en discordance." #: portato/gui/session.py:27 #, python-format @@ -807,7 +807,7 @@ msgstr "" #: portato/gui/dialogs.py:31 msgid "Do you really want to quit?" -msgstr "Êtes vous sur(e) de vouloir quitter ?" +msgstr "Êtes vous sûr(e) de vouloir quitter ?" #: portato/gui/dialogs.py:32 msgid "There are some packages in the emerge queue and/or an emerge process is running." @@ -898,7 +898,7 @@ msgstr "" "Veuillez exécuter emerge --sync && layman -S." #: portato/gui/dialogs.py:141 -#: portato/gui/windows/main.py:1302 +#: portato/gui/windows/main.py:1312 #, python-format msgid "No versions of package '%s' found!" msgstr "Aucune version du paquetage '%s' trouvée !" @@ -975,7 +975,7 @@ msgstr "La première partie de la page d'accueil ne commence ni par 'http' ou 'f #: portato/gui/windows/main.py:172 msgid "Blank inside homepage." -msgstr "Aucune page précisée." +msgstr "Aucun site-web précisé." #: portato/gui/windows/main.py:211 #, python-format @@ -993,7 +993,7 @@ msgstr "Chargement de la configuration" #: portato/gui/windows/main.py:476 msgid "Creating Database" -msgstr "Création de la base de donnée" +msgstr "Création de la base de données" #: portato/gui/windows/main.py:480 msgid "Loading Plugins" @@ -1058,19 +1058,19 @@ msgstr "Traduction de la session de la version %d vers %d." msgid "Cannot translate session from version %d to %d." msgstr "Impossible de traduire la session de la version %d vers %d." -#: portato/gui/windows/main.py:1438 +#: portato/gui/windows/main.py:1448 msgid "use flags" msgstr "flags use" -#: portato/gui/windows/main.py:1450 +#: portato/gui/windows/main.py:1460 msgid "masking keywords" msgstr "keywords masquants" -#: portato/gui/windows/main.py:1858 +#: portato/gui/windows/main.py:1869 msgid "The portage tree is not existing." msgstr "L'arbre portage n'existe pas." -#: portato/gui/windows/main.py:1862 +#: portato/gui/windows/main.py:1873 msgid "The portage tree seems to be empty." msgstr "L'arbre portage semble être vide." @@ -1092,24 +1092,24 @@ msgstr "KeyError détectée => %s ne semble pas être une catégorie disponible. msgid "Error while compiling search expression: '%s'." msgstr "Erreur pendant la compilation de l'expression de recherche : '%s'." -#: portato/db/sql.py:82 +#: portato/db/sql.py:80 msgid "Cleaning database..." msgstr "Nettoyage de la base de données..." -#: portato/db/sql.py:84 +#: portato/db/sql.py:82 msgid "Populating database..." msgstr "Remplissage de la base de données..." #: portato/db/eix_sql.py:35 #, python-format msgid "Cache file '%s' does not exist. Using default instead." -msgstr "Le fichier de cache '%s' n'existe pas. Utilisation du fichier par défaut." +msgstr "Le fichier de cache '%s' n'existe pas. Utilisation du cache par défaut." -#: portato/db/__init__.py:21 +#: portato/db/__init__.py:19 msgid "SQLite" msgstr "SQLite" -#: portato/db/__init__.py:21 +#: portato/db/__init__.py:19 msgid "" "Uses an SQLite-database to store package information.\n" "May take longer to generate at the first time, but has advantages if portato is re-started with an unchanged portage tree. Additionally it allows to use fast SQL expressions for fetching the data." @@ -1117,11 +1117,11 @@ msgstr "" "Utilise une base de données SQLite pour enregistrer les informations sur les paquetages.\n" "Ce système peut prendre plus de temps pour la première utilisation mais dispose d'avantages si portato est redémarré sans changements apportés à l'arbre portage. De plus, il permet l'utilisation d'expression SQL rapides pour récupérer les données." -#: portato/db/__init__.py:22 +#: portato/db/__init__.py:20 msgid "Hashmap" msgstr "Hashmap" -#: portato/db/__init__.py:22 +#: portato/db/__init__.py:20 msgid "" "Uses an in-memory hashmap to store package information.\n" "Has been used since at least version 0.3.3, but all information has to be regenerated on each startup." @@ -1129,11 +1129,11 @@ msgstr "" "Utilise une table de hashage gardée en mémoire pour stocker les informations des paquetages.\n" "Ce procédé existe depuis la version 0.3.3, mais la table doit être régénérée à chaque démarrage." -#: portato/db/__init__.py:23 +#: portato/db/__init__.py:21 msgid "eix + SQLite" msgstr "eix + SQLite" -#: portato/db/__init__.py:23 +#: portato/db/__init__.py:21 msgid "" "Similar to SQLite, but now uses the eix database to get the package information.\n" "This should be much faster on startup, but requires that your eix database is always up-to-date.\n" @@ -1143,13 +1143,13 @@ msgstr "" "Ce mode est normalement plus rapide au démarrage, mais nécessite que votre base de données eix soit toujours à jour.\n" "De plus, ce système est le seul à permettre de faire des recherches dans les descriptions des paquets." -#: portato/db/__init__.py:51 -#: portato/db/__init__.py:66 +#: portato/db/__init__.py:49 +#: portato/db/__init__.py:64 #, python-format msgid "Cannot load %s." msgstr "Impossible de charger %s." -#: portato/db/__init__.py:72 +#: portato/db/__init__.py:70 #, python-format msgid "Unknown database type: %s" msgstr "Type de base de données inconnue : %s" @@ -1176,32 +1176,32 @@ msgstr "Démarrage de Portato" msgid "No valid su command detected. Aborting." msgstr "Aucune commande su valide détectée. Annulation." -#: portato/backend/flags.py:527 +#: portato/backend/flags.py:525 #, python-format msgid "Conflicting values for masking status: %s" msgstr "Valeurs entrant en conflit pour le statuts de masquage : %s" -#: portato/backend/flags.py:690 +#: portato/backend/flags.py:686 #, python-format msgid "Line %(line)s in file %(file)s misses a keyword (e.g. '~x86')." msgstr "La ligne %(line)s dans le fichier %(file)s n'a pas de keyword (par exemple '~x86')." -#: portato/backend/portage/system.py:280 +#: portato/backend/portage/system.py:270 #, python-format msgid "No best match for %s. It seems not to be in the tree anymore." msgstr "Pas de meilleure correspondance pour %s trouvée. Il semble qu'elle n'existe plus dans l'arbre à présent." -#: portato/backend/portage/system.py:338 +#: portato/backend/portage/system.py:328 #, python-format msgid "Found a not installed dependency: %s." msgstr "Dépendance non installée trouvée : %s." -#: portato/backend/portage/system.py:380 +#: portato/backend/portage/system.py:370 #, python-format msgid "Bug? No best match could be found for '%(package)s'. Needed by: '%(cpv)s'." msgstr "Bogue ? Aucune meilleure solution trouvée pour '%(package)s', qui est nécessaire à : '%(cpv)s'." -#: portato/backend/portage/package.py:129 +#: portato/backend/portage/package.py:127 #, python-format msgid "BUG in flags.new_masking_status. It returns '%s'" msgstr "Bogue dans flags.new_masking_status. Renvoie '%s'" -- cgit v1.2.3 From 208c4adfbdf7b82cc40da873ed185f3e29880cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 14 Apr 2010 22:17:53 +0200 Subject: Improve the C modules --- portato/eix/parser.pyx | 50 +++++++++++++++++++++++++++++++++----------------- portato/ipc.pxd | 3 ++- portato/ipc.pyx | 36 +++++++++++++++++------------------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/portato/eix/parser.pyx b/portato/eix/parser.pyx index 4315191..a6bcc96 100644 --- a/portato/eix/parser.pyx +++ b/portato/eix/parser.pyx @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# File: portato/eix/_parser.pyx +# File: portato/eix/parser.pyx # This file is part of the Portato-Project, a graphical portage-frontend. # # Copyright (C) 2006-2010 René 'Necoro' Neumann @@ -20,12 +20,12 @@ For the exact way all the functions work, have a look at the eix format descript __docformat__ = "restructuredtext" cdef extern from "stdio.h": - ctypedef struct FILE: - pass + ctypedef struct FILE int fgetc(FILE* stream) long ftell(FILE* stream) int fseek(FILE* stream, long offset, int whence) + int fread(void* ptr, int size, int n, FILE* stream) int EOF int SEEK_CUR @@ -33,11 +33,14 @@ cdef extern from "stdio.h": cdef extern from "Python.h": FILE* PyFile_AsFile(object) -cimport python_unicode - ctypedef unsigned char UChar ctypedef long long LLong +from python_unicode cimport PyUnicode_DecodeUTF8 +from python_mem cimport PyMem_Malloc, PyMem_Free +from python_exc cimport PyErr_NoMemory +from python_string cimport PyString_FromStringAndSize + from portato.eix.exceptions import EndOfFileException # @@ -123,25 +126,38 @@ cpdef object vector (object file, object get_type, object nelems = None): return [get_type(file) for i in range(n)] -cpdef object string (object file, char u = 0): +cpdef object string (object pfile, bint unicode = False): """ Returns a string. - :param file: The file to read from - :type file: file - :rtype: str + :param pfile: The file to read from + :type pfile: file + :param unicode: Return unicode + :type unicode: bool + :rtype: str or unicode """ - cdef LLong nelems = number(file) + cdef LLong nelems = number(pfile) + cdef FILE* file = PyFile_AsFile(pfile) + cdef char* s + + s = PyMem_Malloc((nelems + 1) * sizeof(char)) + + if s is NULL: + PyErr_NoMemory() - s = file.read(nelems) + try: + if fread(s, sizeof(char), nelems, file) < nelems: + raise EndOfFileException, pfile.name - if len(s) != nelems: - raise EndOfFileException, file.name + s[nelems] = '\0' - if u: - return python_unicode.PyUnicode_DecodeUTF8(s, nelems, 'replace') + if unicode: + return PyUnicode_DecodeUTF8(s, nelems, 'replace') + else: # simple string, implicitly copied + return PyString_FromStringAndSize(s, nelems) - return s + finally: + PyMem_Free(s) # # Complex Types @@ -281,7 +297,7 @@ cdef class package: after_offset = ftell(cfile) self.name = string(file) - self.description = string(file,1) + self.description = string(file, True) # skip the rest, as it is currently unneeded #self.provide = vector(file, number) diff --git a/portato/ipc.pxd b/portato/ipc.pxd index 38e6d30..5bcddd1 100644 --- a/portato/ipc.pxd +++ b/portato/ipc.pxd @@ -11,7 +11,8 @@ # Written by René 'Necoro' Neumann from python_string cimport * -from python_mem cimport * +from python_mem cimport PyMem_Malloc, PyMem_Free +from python_exc cimport PyErr_NoMemory cdef extern from "errno.h": int errno diff --git a/portato/ipc.pyx b/portato/ipc.pyx index abb26fe..7dcf949 100644 --- a/portato/ipc.pyx +++ b/portato/ipc.pyx @@ -70,7 +70,7 @@ cdef class MessageQueue (object): elif errno == ENOENT: raise MessageQueueError("Queue does not exist and 'create' is not set.") elif errno == ENOMEM or errno == ENOSPC: - raise MemoryError("Insufficient ressources.") + PyErr_NoMemory() else: raise OSError(errno, strerror(errno)) @@ -111,7 +111,7 @@ cdef class MessageQueue (object): msg = PyMem_Malloc(sizeof(msg_data) + size) if msg is NULL: - raise MemoryError("Out of memory") + PyErr_NoMemory() memcpy(msg.mtext, message, size) msg.mtype = type @@ -119,18 +119,17 @@ cdef class MessageQueue (object): with nogil: ret = msgsnd(self.msgid, msg, size, 0) - try: - if ret == -1: - if errno == EIDRM or errno == EINVAL: - raise MessageQueueRemovedError("Queue was removed.") - elif errno == EINTR: - raise MessageQueueError("Signaled while waiting.") - elif errno == EACCES: - raise MessageQueueError("Permission denied.") - else: - raise OSError(errno, strerror(errno)) - finally: - PyMem_Free(msg) + PyMem_Free(msg) + + if ret == -1: + if errno == EIDRM or errno == EINVAL: + raise MessageQueueRemovedError("Queue was removed.") + elif errno == EINTR: + raise MessageQueueError("Signaled while waiting.") + elif errno == EACCES: + raise MessageQueueError("Permission denied.") + else: + raise OSError(errno, strerror(errno)) def receive (self): """ @@ -145,7 +144,7 @@ cdef class MessageQueue (object): msg = PyMem_Malloc(sizeof(msg_data) + MAX_MESSAGE_SIZE) if msg is NULL: - raise MemoryError("Out of memory") + PyErr_NoMemory() msg.mtype = 0 @@ -162,12 +161,11 @@ cdef class MessageQueue (object): raise MessageQueueError("Permission denied.") else: raise OSError(errno, strerror(errno)) - - retTuple = (PyString_FromStringAndSize(msg.mtext, ret), msg.mtype) + else: + return (PyString_FromStringAndSize(msg.mtext, ret), msg.mtype) + finally: PyMem_Free(msg) - return retTuple - cdef inline key_t random_key (self): return (rand() / (RAND_MAX + 1) * INT_MAX) -- cgit v1.2.3 From e5b5b6793999a5094832b1819cc6b5e5e5f0ca39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 14 Apr 2010 22:22:47 +0200 Subject: Make some useless info messages being debug statements --- i18n/messages.pot | 45 ++++++++++++++------------------------------- portato/plugin.py | 6 +++--- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/i18n/messages.pot b/i18n/messages.pot index 3181d12..62e9bef 100644 --- a/i18n/messages.pot +++ b/i18n/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-04-11 15:59+0200\n" +"POT-Creation-Date: 2010-04-14 22:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -382,8 +382,8 @@ msgstr "" msgid "Queue" msgstr "" -#: portato/gui/templates/MainWindow.ui:806 portato/gui/windows/main.py:1253 -#: portato/gui/windows/main.py:1255 +#: portato/gui/templates/MainWindow.ui:806 portato/gui/windows/main.py:1262 +#: portato/gui/windows/main.py:1264 msgid "Console" msgstr "" @@ -573,7 +573,7 @@ msgid "" "Please run emerge --sync && layman -S." msgstr "" -#: portato/gui/dialogs.py:141 portato/gui/windows/main.py:1302 +#: portato/gui/dialogs.py:141 portato/gui/windows/main.py:1311 #, python-format msgid "No versions of package '%s' found!" msgstr "" @@ -794,19 +794,19 @@ msgstr "" msgid "Cannot translate session from version %d to %d." msgstr "" -#: portato/gui/windows/main.py:1438 +#: portato/gui/windows/main.py:1447 msgid "use flags" msgstr "" -#: portato/gui/windows/main.py:1450 +#: portato/gui/windows/main.py:1459 msgid "masking keywords" msgstr "" -#: portato/gui/windows/main.py:1858 +#: portato/gui/windows/main.py:1868 msgid "The portage tree is not existing." msgstr "" -#: portato/gui/windows/main.py:1862 +#: portato/gui/windows/main.py:1872 msgid "The portage tree seems to be empty." msgstr "" @@ -869,16 +869,16 @@ msgstr "" msgid "Update" msgstr "" -#: portato/eix/exceptions.py:26 +#: portato/eix/exceptions.py:27 msgid "Unknown error." msgstr "" -#: portato/eix/exceptions.py:37 +#: portato/eix/exceptions.py:44 #, python-format msgid "End of file reached though it was not expected: '%s'" msgstr "" -#: portato/eix/exceptions.py:45 +#: portato/eix/exceptions.py:52 #, python-format msgid "Version '%s' is not supported." msgstr "" @@ -893,17 +893,17 @@ msgstr "" msgid "Line %(line)s in file %(file)s misses a keyword (e.g. '~x86')." msgstr "" -#: portato/backend/portage/system.py:280 +#: portato/backend/portage/system.py:281 #, python-format msgid "No best match for %s. It seems not to be in the tree anymore." msgstr "" -#: portato/backend/portage/system.py:338 +#: portato/backend/portage/system.py:339 #, python-format msgid "Found a not installed dependency: %s." msgstr "" -#: portato/backend/portage/system.py:380 +#: portato/backend/portage/system.py:381 #, python-format msgid "" "Bug? No best match could be found for '%(package)s'. Needed by: '%(cpv)s'." @@ -1053,11 +1053,6 @@ msgstr "" msgid "Loading widgets of plugin '%(plugin)s' failed: %(error)s" msgstr "" -#: portato/plugin.py:466 -#, python-format -msgid "Widgets of plugin '%s' loaded." -msgstr "" - #: portato/plugin.py:497 msgid "Plugin is disabled!" msgstr "" @@ -1071,11 +1066,6 @@ msgstr "" msgid "Plugin '%s' loaded." msgstr "" -#: portato/plugin.py:543 -#, python-format -msgid "Overriding hook '%(hook)s' with plugin '%(plugin)s'." -msgstr "" - #: portato/plugin.py:601 #, python-format msgid "" @@ -1087,13 +1077,6 @@ msgstr "" msgid "It is now replaced by the one from plugin '%s'!" msgstr "" -#: portato/plugin.py:635 -#, python-format -msgid "" -"Dependant '%(dep)s' for '%(hook)s' in plugin '%(plugin)s' not found! Adding " -"nevertheless." -msgstr "" - #: portato/plugin.py:704 portato/plugin.py:707 #, python-format msgid "Registrating plugin '%(plugin)s' failed: %(error)s" diff --git a/portato/plugin.py b/portato/plugin.py index 9d86414..11a40c8 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -463,7 +463,7 @@ class PluginQueue (object): else: for w in p.widgets: WidgetSlot.slots[w.slot].add_widget(w) - info(_("Widgets of plugin '%s' loaded."), p.name) + debug("Widgets of plugin '%s' loaded.", p.name) def add (self, plugin, disable = False): """ @@ -540,7 +540,7 @@ class PluginQueue (object): call.call(*hargs, **hkwargs) if active.override: # override - info(_("Overriding hook '%(hook)s' with plugin '%(plugin)s'."), {"hook": hook, "plugin": active.override.plugin.name}) + debug("Overriding hook '%(hook)s' with plugin '%(plugin)s'.", {"hook": hook, "plugin": active.override.plugin.name}) ret = active.override.call(*hargs, **hkwargs) else: # normal ret = func(*args, **kwargs) @@ -632,7 +632,7 @@ class PluginQueue (object): for l in list: callList.append(l) - info(_("Dependant '%(dep)s' for '%(hook)s' in plugin '%(plugin)s' not found! Adding nevertheless."), {"hook": hook, "plugin": l.plugin.name, "dep": l.dep}) + debug("Dependant '%(dep)s' for '%(hook)s' in plugin '%(plugin)s' not found! Adding nevertheless.", {"hook": hook, "plugin": l.plugin.name, "dep": l.dep}) for hook in before: resolve(hook, before[hook], "before", 0) -- cgit v1.2.3