From c7633ecc8b3df6ec86dc2561f6a7afa52e71981f Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Mon, 28 Feb 2011 19:30:17 +0100 Subject: [PATCH] Bugfixes. --- bin/backup.py | 7 +++---- gen/plone25/descriptors.py | 6 +++++- gen/plone3/__init__.py | 0 gen/plone3/installer.py | 10 ---------- shared/utils.py | 15 ++++++++++++++- 5 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 gen/plone3/__init__.py delete mode 100644 gen/plone3/installer.py diff --git a/bin/backup.py b/bin/backup.py index 3a03bfe..00bf4e4 100644 --- a/bin/backup.py +++ b/bin/backup.py @@ -157,8 +157,7 @@ class ZodbBackuper: remove the temp files that could not be removed by Zope.''' w = self.log w('Removing temp files in "%s"...' % self.tempFolder) - pdfCount = 0 - docCount = 0 + pdfCount = docCount = rtfCount = odtCount = 0 for fileName in os.listdir(self.tempFolder): ext = os.path.splitext(fileName)[1] if ext in self.toRemoveExts: @@ -169,8 +168,8 @@ class ZodbBackuper: os.remove(fullFileName) except OSError, oe: w('Could not remove "%s" (%s).' % (fullFileName, str(oe))) - w('%d PDF document(s) removed.' % pdfCount) - w('%d Word document(s) removed.' % docCount) + w('%d .pdf, %d .doc, %d .rtf and %d .odt file(s) removed.' % \ + (pdfCount, docCount, rtfCount, odtCount)) def run(self): w = self.log diff --git a/gen/plone25/descriptors.py b/gen/plone25/descriptors.py index 38780f5..cbfbed2 100644 --- a/gen/plone25/descriptors.py +++ b/gen/plone25/descriptors.py @@ -579,7 +579,11 @@ class TranslationClassDescriptor(ClassDescriptor): width = 0 height = 0 for fileName, poFile in i18nFiles.iteritems(): - if not fileName.startswith('%s-' % appName): continue + if not fileName.startswith('%s-' % appName) or \ + not i18nFiles[fileName].messagesDict.has_key(messageId): + # In this case this is not one of our Appy-managed translation + # files. + continue msgContent = i18nFiles[fileName].messagesDict[messageId].msg # Compute width width = max(width, len(msgContent)) diff --git a/gen/plone3/__init__.py b/gen/plone3/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/gen/plone3/installer.py b/gen/plone3/installer.py deleted file mode 100644 index e511706..0000000 --- a/gen/plone3/installer.py +++ /dev/null @@ -1,10 +0,0 @@ -'''This package contains stuff used at run-time for installing a generated - Plone product.''' - -# ------------------------------------------------------------------------------ -from appy.gen.plone25.installer import PloneInstaller as Plone25Installer - -class PloneInstaller(Plone25Installer): - '''This Plone installer runs every time the generated Plone product is - installed or uninstalled (in the Plone configuration panel).''' -# ------------------------------------------------------------------------------ diff --git a/shared/utils.py b/shared/utils.py index be1167f..088f561 100644 --- a/shared/utils.py +++ b/shared/utils.py @@ -17,7 +17,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA. # ------------------------------------------------------------------------------ -import os, os.path, re, sys, traceback, unicodedata, shutil +import os, os.path, re, time, sys, traceback, unicodedata, shutil # ------------------------------------------------------------------------------ class FolderDeleter: @@ -141,6 +141,19 @@ def getOsTempFolder(): raise "Sorry, I can't find a temp folder on your machine." return res +def getTempFileName(prefix='', extension=''): + '''Returns the absolute path to a unique file name in the OS temp folder. + The caller will then be able to create a file with this name. + + A p_prefix to this file can be provided. If an p_extension is provided, + it will be appended to the name. Both dotted and not dotted versions + of p_extension are allowed (ie, ".pdf" or "pdf").''' + res = '%s/%s_%f' % (getOsTempFolder(), prefix, time.time()) + if extension: + if extension.startswith('.'): res += extension + else: res += '.' + extension + return res + # ------------------------------------------------------------------------------ def executeCommand(cmd): '''Executes command p_cmd and returns the content of its stderr.'''