[Pythondialog-users] Crash!
dialog.PythonDialogErrorBeforeExecInChildProcess - Please
help to debug.
From: Andy D. <an...@no...> - 2012-01-04 15:04:26
|
Dear pythondialog-users. Thanks for this software, but please could I request some technical support with regards to an issue I am struggling to debug. I am trying to produce a dialog.menu and populate the menu with items as discovered in a database. I see in demo.py that d.menu takes a list of tuples for menu option choices, so this is the data type I am building. This is the code I am using : def add_check(d, userid, cursor): cursor.execute ("SELECT id, hostname FROM host WHERE user_id=%s", userid) hostchoices = list(cursor.fetchall()) # print hostchoices; while 1: (code, tag) = d.menu( "Pick a host to manage?", width=60, choices=hostchoices ) if handle_exit_code(d, code): break d.msgbox ("You picked host " . tag) return 0 When I print hostchoices, I see : [(1L, 'host1'), (2L, 'host2), (3L, 'host3'), (4L, 'host4'), (6L, 'host6'), (7L, 'host7'), (8L, 'host8')] It produces this traceback : Traceback (most recent call last): File "monshell.py", line 126, in <module> if __name__ == "__main__": main() File "monshell.py", line 119, in main main_menu(d, userid, cursor) File "monshell.py", line 98, in main_menu options[tag](d,userid,cursor) File "monshell.py", line 73, in add_check choices=hostchoices ) File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 1253, in menu File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 825, in _perform File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 765, in _wait_for_program_termination dialog.PythonDialogErrorBeforeExecInChildProcess: <PythonDialogErrorBeforeExecInChildProcess: perhaps the dialog-like program could not be executed; perhaps the system is out of memory; perhaps the maximum number of open file descriptors has been reached> It happens on the Linux and OSX version I have. Any clues about how I can debug this ? Dialog is running ok elsewhere in my application - in fact I also use a static menu elsewhere which builds just fine. Thanks Andy |
From: Andy D. <an...@no...> - 2012-01-08 19:22:50
|
Hi there, Please can I check that this went out? Any ideas? Andy Begin forwarded message: > From: Andy Davidson <an...@no...> > Date: 4 January 2012 14:45:53 GMT > To: pyt...@li... > Subject: [Pythondialog-users] Crash! dialog.PythonDialogErrorBeforeExecInChildProcess - Please help to debug. > > > Dear pythondialog-users. > > Thanks for this software, but please could I request some technical support with regards to an issue I am struggling to debug. I am trying to produce a dialog.menu and populate the menu with items as discovered in a database. > > I see in demo.py that d.menu takes a list of tuples for menu option choices, so this is the data type I am building. > > This is the code I am using : > > def add_check(d, userid, cursor): > cursor.execute ("SELECT id, hostname FROM host WHERE user_id=%s", userid) > hostchoices = list(cursor.fetchall()) > # print hostchoices; > while 1: > (code, tag) = d.menu( "Pick a host to manage?", > width=60, > choices=hostchoices ) > if handle_exit_code(d, code): > break > d.msgbox ("You picked host " . tag) > return 0 > > > > When I print hostchoices, I see : > > [(1L, 'host1'), (2L, 'host2), (3L, 'host3'), (4L, 'host4'), (6L, 'host6'), (7L, 'host7'), (8L, 'host8')] > > > > > It produces this traceback : > > Traceback (most recent call last): > File "monshell.py", line 126, in <module> > if __name__ == "__main__": main() > File "monshell.py", line 119, in main > main_menu(d, userid, cursor) > File "monshell.py", line 98, in main_menu > options[tag](d,userid,cursor) > File "monshell.py", line 73, in add_check > choices=hostchoices ) > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 1253, in menu > > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 825, in _perform > > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 765, in _wait_for_program_termination > > dialog.PythonDialogErrorBeforeExecInChildProcess: <PythonDialogErrorBeforeExecInChildProcess: perhaps the dialog-like program could not be executed; perhaps the system is out of memory; perhaps the maximum number of open file descriptors has been reached> > > > It happens on the Linux and OSX version I have. > > Any clues about how I can debug this ? Dialog is running ok elsewhere in my application - in fact I also use a static menu elsewhere which builds just fine. > > Thanks > Andy > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Pythondialog-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythondialog-users |
From: Jose M. <jos...@gm...> - 2012-01-09 06:59:50
|
On Sun, Jan 8, 2012 at 8:21 PM, Andy Davidson <an...@no...> wrote: > > > Hi there, > > Please can I check that this went out? Any ideas? > > Andy > > Begin forwarded message: > > From: Andy Davidson <an...@no...> > Date: 4 January 2012 14:45:53 GMT > To: pyt...@li... > Subject: [Pythondialog-users] Crash! > dialog.PythonDialogErrorBeforeExecInChildProcess - Please help to debug. > > > Dear pythondialog-users. > > Thanks for this software, but please could I request some technical support > with regards to an issue I am struggling to debug. I am trying to produce a > dialog.menu and populate the menu with items as discovered in a database. > > I see in demo.py that d.menu takes a list of tuples for menu option choices, > so this is the data type I am building. > > This is the code I am using : > > def add_check(d, userid, cursor): > cursor.execute ("SELECT id, hostname FROM host WHERE user_id=%s", > userid) > hostchoices = list(cursor.fetchall()) > # print hostchoices; > while 1: > (code, tag) = d.menu( "Pick a host to manage?", > width=60, > choices=hostchoices ) > if handle_exit_code(d, code): > break > d.msgbox ("You picked host " . tag) > return 0 > > > > When I print hostchoices, I see : > > [(1L, 'host1'), (2L, 'host2), (3L, 'host3'), (4L, 'host4'), (6L, 'host6'), > (7L, 'host7'), (8L, 'host8')] > > > > > It produces this traceback : > > Traceback (most recent call last): > File "monshell.py", line 126, in <module> > if __name__ == "__main__": main() > File "monshell.py", line 119, in main > main_menu(d, userid, cursor) > File "monshell.py", line 98, in main_menu > options[tag](d,userid,cursor) > File "monshell.py", line 73, in add_check > choices=hostchoices ) > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 1253, in menu > > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 825, in _perform > > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 765, in > _wait_for_program_termination > > dialog.PythonDialogErrorBeforeExecInChildProcess: > <PythonDialogErrorBeforeExecInChildProcess: perhaps the dialog-like program > could not be executed; perhaps the system is out of memory; perhaps the > maximum number of open file descriptors has been reached> > > > It happens on the Linux and OSX version I have. > > Any clues about how I can debug this ? Dialog is running ok elsewhere in my > application - in fact I also use a static menu elsewhere which builds just > fine. > > Thanks > Andy > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Pythondialog-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythondialog-users > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Pythondialog-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythondialog-users > 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. Bye |
From: Peter Å. <as...@ce...> - 2012-01-09 08:19:08
|
Try running "strace -f" on the entire application. Rgds, Peter On Wed, 4 Jan 2012, Andy Davidson wrote: > > Dear pythondialog-users. > > Thanks for this software, but please could I request some technical support with regards to an issue I am struggling to debug. I am trying to produce a dialog.menu and populate the menu with items as discovered in a database. > > I see in demo.py that d.menu takes a list of tuples for menu option choices, so this is the data type I am building. > > This is the code I am using : > > def add_check(d, userid, cursor): > cursor.execute ("SELECT id, hostname FROM host WHERE user_id=%s", userid) > hostchoices = list(cursor.fetchall()) > # print hostchoices; > while 1: > (code, tag) = d.menu( "Pick a host to manage?", > width=60, > choices=hostchoices ) > if handle_exit_code(d, code): > break > d.msgbox ("You picked host " . tag) > return 0 > > > > When I print hostchoices, I see : > > [(1L, 'host1'), (2L, 'host2), (3L, 'host3'), (4L, 'host4'), (6L, 'host6'), (7L, 'host7'), (8L, 'host8')] > > > > > It produces this traceback : > > Traceback (most recent call last): > File "monshell.py", line 126, in <module> > if __name__ == "__main__": main() > File "monshell.py", line 119, in main > main_menu(d, userid, cursor) > File "monshell.py", line 98, in main_menu > options[tag](d,userid,cursor) > File "monshell.py", line 73, in add_check > choices=hostchoices ) > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 1253, in menu > > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 825, in _perform > > File "build/bdist.macosx-10.7-intel/egg/dialog.py", line 765, in _wait_for_program_termination > > dialog.PythonDialogErrorBeforeExecInChildProcess: <PythonDialogErrorBeforeExecInChildProcess: perhaps the dialog-like program could not be executed; perhaps the system is out of memory; perhaps the maximum number of open file descriptors has been reached> > > > It happens on the Linux and OSX version I have. > > Any clues about how I can debug this ? Dialog is running ok elsewhere in my application - in fact I also use a static menu elsewhere which builds just fine. > > Thanks > Andy > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Pythondialog-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythondialog-users > --- Peter Åstrand ThinLinc Chief Developer Cendio AB http://www.cendio.com Wallenbergs gata 4 583 30 Linköping Phone: +46-13-21 46 00 |
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 |
From: Andy D. <an...@no...> - 2012-01-12 00:30:10
|
Hi, Guys I solved this : Cast your mind back - I was making a dialog.menu box, and inserting my choices using a database query, like this : > cursor.execute ("SELECT id, hostname FROM host WHERE user_id=%s", userid) > hostchoices = list(cursor.fetchall()) > while 1: > (code, tag) = d.menu( "Pick a host to manage?", > width=60, > choices=hostchoices ) 'id' in the database was actually an integer, and this integer type was being preserved into Python. dialog.menu requires that tags and items are strings, so I changed this code to literally force the type to string : def make_menuchoices(raw): choicelist = [] for row in raw: tag = str(row[0]) item = str(row[1]) tagitem = tag, item choicelist.append(tagitem) return choicelist [...] hostchoices = make_menuchoices(cursor.fetchall()) Now, pythondialog is working exactly as you (well, I...) would expect it to. It would have been more than nice for pythondialog to return some kind of type error, rather than crash with the error message as shown in the subject line. Andy |