summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/pdist/rcslib.py27
-rwxr-xr-xDemo/pdist/rcvs.py18
-rwxr-xr-xDemo/pdist/rrcs.py18
-rwxr-xr-xDemo/scripts/pp.py24
4 files changed, 33 insertions, 54 deletions
diff --git a/Demo/pdist/rcslib.py b/Demo/pdist/rcslib.py
index 6d2e313..4e72766 100755
--- a/Demo/pdist/rcslib.py
+++ b/Demo/pdist/rcslib.py
@@ -143,22 +143,17 @@ class RCS:
if message and message[-1] != '\n':
message = message + '\n'
lockflag = "-u"
- textfile = None
- try:
- if new:
- textfile = tempfile.mktemp()
- f = open(textfile, 'w')
- f.write(message)
- f.close()
- cmd = 'ci %s%s -t%s %s %s' % \
- (lockflag, rev, textfile, otherflags, name)
- else:
- message = regsub.gsub('\([\\"$`]\)', '\\\\\\1', message)
- cmd = 'ci %s%s -m"%s" %s %s' % \
- (lockflag, rev, message, otherflags, name)
- return self._system(cmd)
- finally:
- if textfile: self._remove(textfile)
+ if new:
+ f = tempfile.NamedTemporaryFile()
+ f.write(message)
+ f.flush()
+ cmd = 'ci %s%s -t%s %s %s' % \
+ (lockflag, rev, f.name, otherflags, name)
+ else:
+ message = regsub.gsub('\([\\"$`]\)', '\\\\\\1', message)
+ cmd = 'ci %s%s -m"%s" %s %s' % \
+ (lockflag, rev, message, otherflags, name)
+ return self._system(cmd)
# --- Exported support methods ---
diff --git a/Demo/pdist/rcvs.py b/Demo/pdist/rcvs.py
index 9129c28..24036c7 100755
--- a/Demo/pdist/rcvs.py
+++ b/Demo/pdist/rcvs.py
@@ -172,17 +172,13 @@ class MyFile(File):
if self.lsum == sum:
return
import tempfile
- tfn = tempfile.mktemp()
- try:
- tf = open(tfn, 'w')
- tf.write(data)
- tf.close()
- print 'diff %s -r%s %s' % (flags, rev, fn)
- sts = os.system('diff %s %s %s' % (flags, tfn, fn))
- if sts:
- print '='*70
- finally:
- remove(tfn)
+ tf = tempfile.NamedTemporaryFile()
+ tf.write(data)
+ tf.flush()
+ print 'diff %s -r%s %s' % (flags, rev, fn)
+ sts = os.system('diff %s %s %s' % (flags, tf.name, fn))
+ if sts:
+ print '='*70
def commitcheck(self):
return self.action() != 'C'
diff --git a/Demo/pdist/rrcs.py b/Demo/pdist/rrcs.py
index ecb01a2..a07260c 100755
--- a/Demo/pdist/rrcs.py
+++ b/Demo/pdist/rrcs.py
@@ -102,17 +102,13 @@ def diff(x, copts, fn):
flags = flags + ' ' + o + a
flags = flags[1:]
data = x.get(fn)
- tfn = tempfile.mktemp()
- try:
- tf = open(tfn, 'w')
- tf.write(data)
- tf.close()
- print 'diff %s -r%s %s' % (flags, x.head(fn), fn)
- sts = os.system('diff %s %s %s' % (flags, tfn, fn))
- if sts:
- print '='*70
- finally:
- remove(tfn)
+ tf = tempfile.NamedTemporaryFile()
+ tf.write(data)
+ tf.flush()
+ print 'diff %s -r%s %s' % (flags, x.head(fn), fn)
+ sts = os.system('diff %s %s %s' % (flags, tf.name, fn))
+ if sts:
+ print '='*70
def same(x, copts, fn, data = None):
if data is None:
diff --git a/Demo/scripts/pp.py b/Demo/scripts/pp.py
index 2496046..64e57ee 100755
--- a/Demo/scripts/pp.py
+++ b/Demo/scripts/pp.py
@@ -120,19 +120,11 @@ for line in SCRIPT:
program = program + (string.joinfields(epilogue, '\n') + '\n')
import tempfile
-tfn = tempfile.mktemp()
-try:
- fp = open(tfn, 'w')
- fp.write(program)
- fp.close()
- if DFLAG:
- import pdb
- pdb.run('execfile(' + `tfn` + ')')
- else:
- execfile(tfn)
-finally:
- import os
- try:
- os.unlink(tfn)
- except:
- pass
+fp = tempfile.NamedTemporaryFile()
+fp.write(program)
+fp.flush()
+if DFLAG:
+ import pdb
+ pdb.run('execfile(' + `tfn` + ')')
+else:
+ execfile(tfn)