os.system Rückgabewert Problem
Verfasst: Sonntag 25. Mai 2008, 12:30
Da der Standard GNOME Run Dialog keine Variablen akzeptiert habe ich mich entschlossen einfach selber einen in PyGTK zu schreiben, bis auf den Rückgabewert von os.system klappt das ja auch wunderbar.
Den Wert hole ich mir wie folgt:
self.execute = os.system("was weiss ich")
self.signal = self.execute & 0xFF
self.exitcode = (self.signal >> 8 ) & 0xFF
Direkt im Python Interpreter _kein_ Problem, aber im Script funktioniert das nicht...
Hier noch die ganze Funktion zur Programmausführung ...
Ich hoffe jemand hat ne Antwort parat.
Den Wert hole ich mir wie folgt:
self.execute = os.system("was weiss ich")
self.signal = self.execute & 0xFF
self.exitcode = (self.signal >> 8 ) & 0xFF
Direkt im Python Interpreter _kein_ Problem, aber im Script funktioniert das nicht...
Hier noch die ganze Funktion zur Programmausführung ...
Code: Alles auswählen
def run(self, command):
self.infolabel.set_text("")
if self.terminal_checkbox.get_active() and self.root_checkbox.get_active():
self.command = "gksu -u root \"%s -e `bash -c \'%s\'`\"" % (self.terminal, self.entry_command.get_text())
self.execute = os.system("%s &" % self.command)
elif self.terminal_checkbox.get_active() and self.root_checkbox.get_active() != True:
self.command = "%s -e \"bash -c \'%s\'\"" % (self.terminal, self.entry_command.get_text())
self.execute = os.system("%s &" % self.command)
elif self.terminal_checkbox.get_active() != True and self.root_checkbox.get_active():
self.command = "gksu -u root %s" % self.entry_command.get_text()
self.execute = os.system('%s &' % self.command)
else:
self.command = "%s" % (self.entry_command.get_text())
self.execute = os.system("%s &" % self.command)
self.signal = self.execute & 0xFF
self.exitcode = (self.signal >> 8) & 0xFF
print "%s" % self.exitcode
if self.exitcode == 127:
self.infolabel.set_text(_("Command not found"))
elif self.exitcode != 0:
print "Something went wrong"
self.infolabel.set_text(_("Something went wrong"))
else:
if self.command not in self.history:
self.history.append(self.command)
self.history_list.append_text(self.command)
gconf_database.set_list("/apps/gnome-settings/gnome-panel/history-gnome-run", "string", self.history)
gtk.main_quit()