Rev 193: Extracted writing of a script to a queuedir (pqm.write_script). in http://bzr.daniel-watkins.co.uk/pqm/xmlrpc
Daniel Watkins
daniel at daniel-watkins.co.uk
Thu Jul 31 07:35:45 BST 2008
At http://bzr.daniel-watkins.co.uk/pqm/xmlrpc
------------------------------------------------------------
revno: 193
revision-id: daniel at daniel-watkins.co.uk-20080731063410-1f4x2eszoir5bjx2
parent: daniel at daniel-watkins.co.uk-20080731061828-gi3up81kv3on0nwu
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: xmlrpc
timestamp: Thu 2008-07-31 07:34:10 +0100
message:
Extracted writing of a script to a queuedir (pqm.write_script).
-------------- next part --------------
=== modified file 'bin/pqm'
--- a/bin/pqm 2008-07-31 06:17:16 +0000
+++ b/bin/pqm 2008-07-31 06:34:10 +0000
@@ -206,12 +206,8 @@
try:
email = read_email_from_file(logger, sys.stdin)
email_string = get_email_string(logger, options, email)
- fname = 'patch.%d' % (time.time())
- logger.info('new patch ' + fname)
- f = open('tmp.' + fname, 'w')
- f.write(email_string)
- f.close()
- os.rename('tmp.' + fname, fname)
+ queuedir = os.path.abspath('.')
+ pqm.write_script(queuedir, email_string)
except:
if sender and mail_reply:
server = smtplib.SMTP(mail_server)
=== modified file 'pqm/__init__.py'
--- a/pqm/__init__.py 2008-07-17 10:09:34 +0000
+++ b/pqm/__init__.py 2008-07-31 06:34:10 +0000
@@ -26,6 +26,7 @@
import stat
import string
import sys
+import time
from pqm.errors import PQMException, PQMTlaFailure
from pqm.script import Script
@@ -54,6 +55,16 @@
sys.exit(1)
+def write_script(queuedir, text):
+ fname = 'patch.%d' % (time.time(),)
+ tmp_name = os.path.join(queuedir, 'tmp.%s' % (fname,))
+ logger.info('new patch ' + fname)
+ f = open(tmp_name, 'w')
+ f.write(text)
+ f.close()
+ os.rename(tmp_name, os.path.join(queuedir, fname))
+
+
def find_patches(queuedir, logger, branch_spec_handler, configp, options):
patches=[]
patches_re=re.compile('^patch\.\d+$')
=== modified file 'pqm/ui/xmlrpc.py'
--- a/pqm/ui/xmlrpc.py 2008-07-31 06:10:07 +0000
+++ b/pqm/ui/xmlrpc.py 2008-07-31 06:34:10 +0000
@@ -40,13 +40,7 @@
email = read_email_from_string(self.logger, text)
email_string = get_email_string(self.logger, options, email)
# Write patch
- fname = 'patch.%d' % (time.time(),)
- self.logger.info('new patch ' + fname)
- f = open(os.path.join(queuedir, 'tmp.%s' % (fname,)), 'w')
- f.write(email_string)
- f.close()
- os.rename(os.path.join(queuedir, 'tmp.%s' % (fname,)),
- os.path.join(queuedir, fname))
+ pqm.write_script(queuedir, email_string)
return "Success!"
except PQMException, e:
return "Error: %s" % (e,)
More information about the bazaar-commits
mailing list