From: Andy D. <an...@no...> - 2012-01-10 17:37:38
|
On 9 Jan 2012, at 06:59, Jose Mari wrote: > I think that in last instance pythondialog runs a shell with dialog cmd. > > In function _call_program(self, redirect_child_stdin, cmdargs, > **kwargs) exits the exec command: > os.execve(self._dialog_prg, arglist, new_environ) > > Try to print the complete line call and test it in a bash shell. Thanks for the advice. In the documentation, I found that there was a suggested 'debugging' block of text that caused the command to be written out. import commands envvar_settings_list = [] if new_environ.has_key("DIALOGRC"): envvar_settings_list.append( "DIALOGRC='%s'" % new_environ["DIALOGRC"]) for var in _dialog_exit_status_vars.keys(): varname = "DIALOG_" + var envvar_settings_list.append( "%s=%s" % (varname, new_environ[varname])) envvar_settings = string.join(envvar_settings_list, " ") file("command.debug", "wb").write( envvar_settings + string.join(map(commands.mkarg, arglist), "")) os.execve(self._dialog_prg, arglist, new_environ) When it works ok, I get useful stuff in the output file : DIALOG_OK=0 DIALOG_HELP=5 DIALOG_EXTRA=4 DIALOG_ESC=2 DIALOG_ERROR=3 DIALOG_CANCEL=1 '/usr/bin/dialog' '--backtitle' 'Welcome to xxxxx' '--menu' 'Where would you like to go today ?' '15' '60' '7' 'AddHost' 'Add Host to System' 'AddCheck' 'Add Check to Host' 'Logout' 'Log out of Shell' But when I try to build a menu of options from the database as described in my original mail at the top of the thread, the output file is made blank. -rw-r--r-- 1 andy andy 0 Jan 10 17:31 command.debug On 9 Jan 2012, at 08:18, Peter Åstrand wrote: > Try running "strace -f" on the entire application. This is what looks to happen at the time of the crash : $ strace -f python xxshell.py 1 [...] [pid 20299] fstat(6, {st_mode=S_IFREG|0644, st_size=2477, ...}) = 0 [pid 20299] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5494054000 [pid 20299] read(6, "\321\362\r\nW\313\27Mc\0\0\0\0\0\0\0\0\3\0\0\0@\0\0\0sF\0\0\0d\0"..., 4096) = 2477 [pid 20299] fstat(6, {st_mode=S_IFREG|0644, st_size=2477, ...}) = 0 [pid 20299] read(6, "", 4096) = 0 [pid 20299] close(6) = 0 [pid 20299] munmap(0x7f5494054000, 4096) = 0 [pid 20299] close(4) = 0 [pid 20299] open("command.debug", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4 [pid 20299] fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 20299] close(4) = 0 [pid 20299] exit_group(127) = ? Process 20296 resumed Process 20299 detached <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], 0, NULL) = 20299 --- SIGCHLD (Child exited) @ 0 (0) --- write(2, "Traceback (most recent call last"..., 35Traceback (most recent call last): ) = 35 write(2, " File \"monshell.py\", line 126, "..., 44 File "monshell.py", line 126, in <module> ) = 44 open("monshell.py", O_RDONLY) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=3578, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5494054000 read(5, "import sys, os, os.path, time, s"..., 4096) = 3578 write(2, " ", 4 ) = 4 write(2, "if __name__ == \"__main__\": main("..., 34if __name__ == "__main__": main() ) = 34 close(5) = 0 Any ideas ? Andy |