From d60dfdf71c8a16b509b581b09f4fdd65f9badfab Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 30 May 2001 15:54:41 +0000 Subject: [PATCH] Removed some more code that is also in ROX-Lib. git-svn-id: https://rox.svn.sourceforge.net/svnroot/rox/trunk/Archive@685 66de3db3-b00d-0410-b41b-f4738ad19bea --- AppRun | 2 +- Archive.py | 41 +++++++++++++++++++++++++++++------------ Help/Changes | 4 ++++ support.py | 47 ----------------------------------------------- 4 files changed, 34 insertions(+), 60 deletions(-) delete mode 100644 support.py diff --git a/AppRun b/AppRun index 8722d25..2bb1636 100755 --- a/AppRun +++ b/AppRun @@ -8,7 +8,7 @@ from gtk import * from GDK import * from Archive import * -from support import * +from rox.support import * if len(argv) != 2: report_error("Drag a file or directory onto Archive to " diff --git a/Archive.py b/Archive.py index 2a18c8a..67dee28 100644 --- a/Archive.py +++ b/Archive.py @@ -9,7 +9,7 @@ from gtk import * from GDK import * from rox.SaveBox import SaveBox -from support import * +from rox import support from rox import choices import string @@ -69,7 +69,7 @@ def bg_system(command, out = None): os.close(w) if out != None: os.close(out) - report_error("fork() failed!") + support.report_error("fork() failed!") return 127 if child_pid == 0: # Child @@ -111,15 +111,15 @@ def bg_system(command, out = None): input_remove(tag) os.close(r) - (pid, status) = waitpid(child_pid, 0) + (pid, status) = os.waitpid(child_pid, 0) child_pid = None str = string.strip(done[0]) if status or str: if str: - report_error("Error: " + str) + support.report_error("Error: " + str) else: - report_error("Operation failed") + support.report_error("Operation failed") return status @@ -140,8 +140,8 @@ def make_archiver(path): else: window = ArchiveFile(path) - window.connect('destroy', lambda w: rox_toplevel_unref()) - rox_toplevel_ref() + window.connect('destroy', lambda w: support.rox_toplevel_unref()) + support.rox_toplevel_ref() window.show() def pull_up(dir): @@ -171,7 +171,24 @@ def report_known(formats): for f in formats: if f[2]: txt = txt + f[0] + '\n' - report_error(txt) + support.report_error(txt) + +from os import _exit, fork, execvp, dup2 + +def child(*argv): + """Spawn a new process. Connect stderr to stdout.""" + child = fork() + if child == 0: + # We are the child + try: + dup2(1, 2) + execvp(argv[0], argv) + except: + pass + print "Warning: exec('%s') failed!" % argv[0] + _exit(1) + elif child == -1: + print "Error: fork() failed!" class Archive(SaveBox): def __init__(self, win, type): @@ -191,12 +208,12 @@ class Archive(SaveBox): success = self.do_save(path) except: success = FALSE - report_exception() + support.report_exception() self.set_sensitive(TRUE); return success def set_uri(self, uri): - path = get_local_path(uri) + path = support.get_local_path(uri) if path: child('rox', '-x', path) pass @@ -237,7 +254,7 @@ class ExtractFile(Archive): def do_save(self, path): if os.path.exists(path): - report_error("File `%s' already exists!" % path) + support.report_error("File `%s' already exists!" % path) return FALSE stats = os.stat(self.path) mode = stat.S_IMODE(stats[stat.ST_MODE]) & 0x1ff; @@ -276,7 +293,7 @@ class ArchiveFile(Archive): return FALSE if os.path.exists(path): - report_error("File `%s' already exists!" % path) + support.report_error("File `%s' already exists!" % path) return FALSE stats = os.stat(self.path) mode = stat.S_IMODE(stats[stat.ST_MODE]) & 0x1ff; diff --git a/Help/Changes b/Help/Changes index a443fbd..a59255c 100644 --- a/Help/Changes +++ b/Help/Changes @@ -2,6 +2,10 @@ A simple archiver by Thomas Leonard +30-May-2001 +~~~~~~~~~~~ +Removed some more code that is also in ROX-Lib. + 23-May-2001 ~~~~~~~~~~~ When extracting an archive in the form 'name-version.ext', the suggested diff --git a/support.py b/support.py deleted file mode 100644 index d0b24ae..0000000 --- a/support.py +++ /dev/null @@ -1,47 +0,0 @@ -from os import _exit, fork, execvp, waitpid, dup2 - -from rox.MultipleChoice import MultipleChoice -from rox.support import * - -from gtk import * - -# Open a modal dialog box showing a message. -# The user can choose from a selection of buttons at the bottom. -# Returns -1 if the window is destroyed, or the number of the button -# if one is clicked (starting from zero). -# -# If a dialog is already open, returns -1 without waiting AND -# brings the current dialog to the front. -current_dialog = None -def get_choice(message, title, buttons): - global current_dialog - - if current_dialog: - current_dialog.hide() - current_dialog.show() - return -1 - - current_dialog = MultipleChoice(message, buttons) - current_dialog.set_title(title) - choice_return = current_dialog.wait() - - print "Return", choice_return - - current_dialog = None - - return choice_return - -def child(*argv): - """Spawn a new process. Connect stderr to stdout.""" - child = fork() - if child == 0: - # We are the child - try: - dup2(1, 2) - execvp(argv[0], argv) - except: - pass - print "Warning: exec('%s') failed!" % argv[0] - _exit(1) - elif child == -1: - print "Error: fork() failed!" -- 2.11.4.GIT