Fix exceptions raise after quitting history view.
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
2009-12-21 Fatih Aşıcı <fatih@pardus.org.tr>
|
||||||
|
* pisi/cli/history.py: Fix exceptions raise after quitting history view.
|
||||||
|
|
||||||
2009-12-16 Serdar Dalgıç <serdar@pardus.org.tr>
|
2009-12-16 Serdar Dalgıç <serdar@pardus.org.tr>
|
||||||
* pisi/cli/blame.py: Several enhancements in blame:
|
* pisi/cli/blame.py: Several enhancements in blame:
|
||||||
- pisi bl works for LC_ALL=C
|
- pisi bl works for LC_ALL=C
|
||||||
|
|||||||
+35
-5
@@ -78,10 +78,41 @@ Lists previous operations.""")
|
|||||||
print " *", pkg
|
print " *", pkg
|
||||||
print
|
print
|
||||||
|
|
||||||
def redirect_output(self):
|
def redirect_output(self, func):
|
||||||
if os.isatty(sys.stdout.fileno()):
|
if os.isatty(sys.stdout.fileno()):
|
||||||
output = os.popen("less","w")
|
class LessException(Exception):
|
||||||
sys.stdout = sys.stderr = output
|
pass
|
||||||
|
|
||||||
|
class LessPipe():
|
||||||
|
def __init__(self):
|
||||||
|
import subprocess
|
||||||
|
self.less = subprocess.Popen(["less", "-"],
|
||||||
|
stdin=subprocess.PIPE)
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.less.stdin.close()
|
||||||
|
self.less.wait()
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
self.less.stdin.flush()
|
||||||
|
|
||||||
|
def write(self, s):
|
||||||
|
try:
|
||||||
|
self.less.stdin.write(s)
|
||||||
|
except IOError:
|
||||||
|
raise LessException
|
||||||
|
|
||||||
|
stdout, stderr = sys.stdout, sys.stderr
|
||||||
|
sys.stdout = sys.stderr = LessPipe()
|
||||||
|
try:
|
||||||
|
func()
|
||||||
|
except LessException:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
sys.stdout, sys.stderr = stdout, stderr
|
||||||
|
|
||||||
|
else:
|
||||||
|
func()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.init(database = False, write = False)
|
self.init(database = False, write = False)
|
||||||
@@ -95,5 +126,4 @@ Lists previous operations.""")
|
|||||||
self.takeback(opno)
|
self.takeback(opno)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.redirect_output()
|
self.redirect_output(self.print_history)
|
||||||
self.print_history()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user