[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r18033: {projects} Make logger global in gettor.py Remove some XXXs (projects/gettor)
Author: kaner
Date: 2009-01-08 20:21:27 -0500 (Thu, 08 Jan 2009)
New Revision: 18033
Modified:
projects/gettor/gettor.py
projects/gettor/gettor_requests.py
projects/gettor/gettor_responses.py
Log:
Make logger global in gettor.py
Remove some XXXs
Modified: projects/gettor/gettor.py
===================================================================
--- projects/gettor/gettor.py 2009-01-09 00:58:22 UTC (rev 18032)
+++ projects/gettor/gettor.py 2009-01-09 01:21:27 UTC (rev 18033)
@@ -67,6 +67,8 @@
import gettor_opt
import gettor_packages
+# Global logger
+log = None
# Switch language to 'newlocale'. Return default if language is not supported.
def switchLocale(newlocale, localedir):
@@ -77,37 +79,39 @@
trans.install()
def runTests():
- # XXX
+ # XXX: Implement me
return True
def installMo(poFile, targetDir):
+ global log
args = os.getcwd() + "/" + poFile + " -o " + targetDir + "/gettor.mo"
try:
ret = subprocess.call("msgfmt" + " " + args, shell=True)
if ret < 0:
- print >> sys.stdout, "Error in msgfmt execution: ", ret
+ log.error("Error in msgfmt execution: %s" % ret)
return False
except OSError, e:
- print >> sys.stdout, "Comilation failed: ", e
+ log.erro("Comilation failed: " % e)
return False
return True
def installTrans(config, localeSrcdir):
+ global log
hasDirs = None
if config is None:
log.error("Bad arg.")
return False
if not os.path.isdir(localeSrcdir):
- print >> sys.stderr, "Not a directory: ", localeSrcdir
+ log.error("Not a directory: " % localeSrcdir)
return False
localeDir = config.getLocaleDir()
if not os.path.isdir(localeDir):
- print >> sys.stderr, "Sorry, %s is not a directory." % distDir
+ log.error("Sorry, %s is not a directory." % distDir)
return False
for root, dirs, files in os.walk(localeSrcdir):
- # XXX Python lacks 'depth' featue for os.walk()
+ # Python lacks 'depth' featue for os.walk()
if root != localeSrcdir:
continue
for dir in dirs:
@@ -120,16 +124,16 @@
targetDir = localeDir + "/" + dir + "/LC_MESSAGES"
if os.path.isdir(targetDir):
if installMo(poFile, targetDir) == False:
- print >> sys.err, "Installing .mo files failed."
+ log.error("Installing .mo files failed.")
return False
else:
- print >> sys.stderr, "Not a directory: ", targetDir
+ log.error("Not a directory: " % targetDir)
return False
except Exception, e:
- print >> sys.stderr, "Error accessing translation files: ", e
+ log.error("Error accessing translation files: " % e)
return False
if hasDirs is None:
- print >> sys.stderr, "Empty locale dir: ", localeSrcdir
+ log.errpr("Empty locale dir: " % localeSrcdir)
return False
return True
@@ -155,7 +159,9 @@
savedTab += line
return savedTab
-def processMail(conf, log, logLang, packageList, blackList, whiteList):
+def processMail(conf, logLang, packageList, blackList, whiteList):
+ global log
+
if packageList is None or len(packageList) < 1:
log.error(_("Sorry, your package list is unusable."))
log.error(_("Try running with --fetch-packages --prep-packages."))
@@ -216,7 +222,9 @@
return True
def main():
+ global log
success = None
+
# Parse command line, setup config, logging and language
options, arguments = gettor_opt.parseOpts()
conf = gettor_config.gettorConf(options.configfile)
@@ -329,7 +337,7 @@
return success
# Main loop
- if not processMail(conf, log, logLang, packs.getPackageList(), blackList,
+ if not processMail(conf, logLang, packs.getPackageList(), blackList,
whiteList):
log.error(_("Processing mail failed."))
return False
Modified: projects/gettor/gettor_requests.py
===================================================================
--- projects/gettor/gettor_requests.py 2009-01-09 00:58:22 UTC (rev 18032)
+++ projects/gettor/gettor_requests.py 2009-01-09 01:21:27 UTC (rev 18033)
@@ -47,9 +47,6 @@
self.replytoAddress = self.parsedMessage["from"]
# If no package name could be recognized, use 'None'
self.returnPackage = None
- # XXX TODO:
- # Should we pick only the first line of the email body. Drop the rest?
- # It may be too unfriendly to our users
for line in email.Iterators.body_line_iterator(self.parsedMessage):
for package in packages.keys():
match = re.match(package, line)
Modified: projects/gettor/gettor_responses.py
===================================================================
--- projects/gettor/gettor_responses.py 2009-01-09 00:58:22 UTC (rev 18032)
+++ projects/gettor/gettor_responses.py 2009-01-09 01:21:27 UTC (rev 18033)
@@ -140,7 +140,6 @@
# Add a file if we have one
if fileName:
- # XXX TODO: Iterate over each file eventually
filePart = mime.nextpart()
filePart.addheader('Content-Transfer-Encoding', 'base64')
emailBody = filePart.startbody('application/zip; name=%s' % os.path.basename(fileName))