FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Server Development

 
 
LinkBack Thread Tools
 
Old 10-28-2009, 02:23 AM
David Cantrell
 
Default Create execWithCallback() function in iutil.

Create an execWithCallback() function that takes in a callback function
and some data that is always passed to the callback function. Change
execWithPulseProgress() to use execWithCallback(). The idea behind
execWithCallback() is to allow flexibility to creating non-pulse
progress bars or other UI indicators.
---
iutil.py | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/iutil.py b/iutil.py
index 7ee1bf7..0b15bd8 100644
--- a/iutil.py
+++ b/iutil.py
@@ -242,8 +242,9 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'):
closefds()
return rc

-def execWithPulseProgress(command, argv, stdin = None, stdout = None,
- stderr = None, progress = None, root = '/'):
+def execWithCallback(command, argv, stdin = None, stdout = None,
+ stderr = None, callback = None, callback_data = None,
+ root = '/'):
def chroot():
os.chroot(root)

@@ -311,7 +312,8 @@ def execWithPulseProgress(command, argv, stdin = None, stdout = None,

os.write(stdout, s)
runningLog.write(s)
- if progress: progress.pulse()
+ if callback:
+ callback(s, callback_data=callback_data)

# break out early if the sub-process changes status.
# no need to flush the stream if the process has exited
@@ -342,6 +344,16 @@ def execWithPulseProgress(command, argv, stdin = None, stdout = None,

return 1

+def _pulseProgressCallback(data, callback_data=None):
+ if callback_data:
+ callback_data.pulse()
+
+def execWithPulseProgress(command, argv, stdin = None, stdout = None,
+ stderr = None, progress = None, root = '/'):
+ execWithCallback(command, argv, stdin=stdin, stdout=stdout,
+ stderr=stderr, callback=_pulseProgressCallback,
+ callback_data=progress, root=root)
+
## Run a shell.
def execConsole():
try:
--
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 05:50 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org