Hi again,

Good news, I guess this is. :)

I copied your logger code into the file but no log is generated there.
So the only explanation would be that the exception thrown is not of
that type. So I expanded it to following Python-like code (:D):

                # Call GraphViz
                import sys
                import logging
                logger = logging.getLogger('zim.plugins.diagrameditor')
                logger.error('---> DEBUGGINGDEBUGGING')
                try:
                        dot = Application(dotcmd)
                        dot.run((self.pngfile, self.dotfile))
                        logger.error('---> SUCCESS')
                except ApplicationError:
                        logger.error('---> EXCEPTION')
                        logger.exception('Error running dot:')
                        return None, None # Sorry, no log
                except:
                        logger.error('UNKNOWN ERROR')
                        logger.error(sys.exc_info()[0])
                        logger.error(sys.exc_info())
                else:
                        logger.error('---> In else: clause')
                        return self.pngfile, None

Okay, reproduce.

And check the log file (personal information erased):

INFO: Locale set to: en_US.***
INFO: This is zim 0.59
DEBUG: Python version is sys.version_info(major=2, minor=7, micro=3,
releaselevel='final', serial=0)
DEBUG: Platform is nt
DEBUG: Zim revision is:
  branch: pyzim
  revision: 636 par...@cpan.org-20130123210740-rquhot1l1yzx9w0i
  date: 2013-01-23 22:07:40 +0100
DEBUG: Running from a source dir: C:\***\zim-0.59\App\ZimDesktopWiki
DEBUG: Set XDG_DATA_HOME to C:\Users\***\AppData\Roaming\zim\data
DEBUG: Set XDG_DATA_DIRS to [<Dir: C:\Users\***\.local\share>]
DEBUG: Set XDG_CONFIG_HOME to C:\Users\***\AppData\Roaming\zim\config
DEBUG: Set XDG_CONFIG_DIRS to [<Dir: C:\Users\***\.config>]
DEBUG: Set XDG_CACHE_HOME to C:\Users\***\AppData\Local\Temp\zim
DEBUG: Running command: gui
DEBUG: Loading config from: C:\***.zim\notebook.zim
DEBUG: Wrote C:\Users\***\AppData\Roaming\zim\config\zim\notebooks.list
INFO: Opening default notebook
DEBUG: Loading config from: <ConfigFile:
C:\Users\***\AppData\Roaming\zim\config\zim\preferences.conf>
DEBUG: Gtk version is (2, 24, 10)
DEBUG: Pygtk version is (2, 24, 0)
DEBUG: Loading config from: <ConfigFile:
C:\Users\***\AppData\Roaming\zim\config\zim\style.conf>
DEBUG: Opening notebook: file:///C:/***.zim
DEBUG: Loading config from: C:\***.zim\notebook.zim
DEBUG: Cache dir: C:\***.zim\.zim
DEBUG: Index database file: C:\***.zim\.zim\index.db
DEBUG: Loading config from: C:\***.zim\.zim\state.conf
DEBUG: Loaded plugin "calendar" (<CalendarPlugin object at 0x2ae0f08
(zim+plugins+PluginClass at 0x8adb0c0)>)
DEBUG: Registered plugin <InsertDiagramPlugin object at 0x2ac3558
(zim+plugins+PluginClass at 0x8adb170)> for image type "diagram"
DEBUG: Loaded plugin "diagrameditor" (<InsertDiagramPlugin object at
0x2ac3558 (zim+plugins+PluginClass at 0x8adb170)>)
DEBUG: Loaded plugin "insertsymbol" (<InsertSymbolPlugin object at
0x2ac51c0 (zim+plugins+PluginClass at 0x8adb410)>)
DEBUG: Loaded plugin "printtobrowser" (<PrintToBrowserPlugin object at
0x2ae6bc0 (zim+plugins+PluginClass at 0x8adb4f0)>)
INFO: Starting async index update
INFO: Open page: <FileStorePage: ***> (<HistoryPath: ***>)
DEBUG: Accelmap: C:\Users\***\AppData\Roaming\zim\config\zim\accelmap
DEBUG: Wrote C:\Users\***\AppData\Roaming\zim\config\zim\preferences.conf
DEBUG: Action: set_pathbar_path
DEBUG: Action: toggle_panes
DEBUG: Action: set_toolbar_icons_only
INFO: Index update done
DEBUG: Action: insert_diagram
DEBUG: Wrote c:\users\***\appdata\local\temp\zim-***\diagram.dot
DEBUG: Opening dialog "Insert Diagram - Zim"
DEBUG: Wrote c:\users\***\appdata\local\temp\zim-***\diagram.dot
ERROR: ---> DEBUGGINGDEBUGGING
INFO: Running: ['dot', '-Tpng', '-o',
'c:\\users\\***\\appdata\\local\\temp\\zim-***\\diagram.png',
'c:\\users\\***\\appdata\\local\\temp\\zim-***\\diagram.dot'] (cwd:
None)
ERROR: UNKNOWN ERROR
ERROR: <type 'exceptions.WindowsError'>
ERROR: (<type 'exceptions.WindowsError'>, WindowsError(6, 'The handle
is invalid'), <traceback object at 0x02AE0738>)
ERROR: Could not generate image
Traceback (most recent call last):
  File "zim\gui\imagegeneratordialog.pyo", line 210, in generate_image
TypeError: 'NoneType' object is not iterable

(End of log file)

As you can see, the exception is exceptions.WindowsError(6, 'The
handle is invalid').

Two pages looked useful from Google result:

https://bitbucket.org/cherrypy/cherrypy/issue/1016/windowserror-error-6-the-handle-is-invalid
http://bugs.python.org/issue3905

I didn't understand a thing about what they're talking about, but
while I scrolled down:

--- quote ---
1. When this is run in a subsystem:windows process (like PythonWin or
IDLE) that is launched from Windows Explorer (e.g. from a Start Menu
shortcut or Desktop shortcut) then `GetStdHandle(STD_INPUT_HANDLE)`
returns None.
...
In this case you *don't* get the error that Todd described, because the
code path taken in subprocess.py then use CreatePipe for the `p2cread`
variable on which `DuplicateHandle` is called.
--- end of quote ---

I don't know what that means, but I tried to start zim.exe from
Explorer and ... (Y^____^Y) I worked!

However, throwing exceptions when it's launched from command line is
still a bug I guess?

Is your Windows 7 32bit or 64bit? Mine is 64bit, this could be the reason?

Bagana

On Thu, Apr 11, 2013 at 5:46 PM, Bagana Khereid <bag...@musiel.org> wrote:
> Thank you for your detailed reply!
>
> I'll look into it tonight.
>
> Regards,
> Bagana
>
> On Thu, Apr 11, 2013 at 5:09 PM, Jaap Karssenberg
> <jaap.karssenb...@gmail.com> wrote:
>> On Thu, Apr 11, 2013 at 10:04 AM, Bagana Khereid <bag...@musiel.org> wrote:
>>>
>>> I'm new to this mailing list. Found it from Zim homepage following
>>> "For user questions and development discussion, please join the
>>> mailing list...", Hope this is the right place for this mail.
>>
>>
>> Feel free to ask here. To report specific issues that need fixes in zim,
>> please use the bug tracker at https://bugs.launchpad.net/zim
>>
>>> I've been using *Zim 0.59* on a *Windows 7 64bit* machine for a while
>>> now, but only with a few pre-installed plugins enabled. When I wanted
>>> to draw some block diagrams in my wiki's a couple days ago, I
>>> downloaded *GraphViz 2.30.1* (with its *bin* directory added in my
>>> PATH variable) along with *Pango 1.29.4-1* and enabled *Diagram
>>> Editor* plugin in Zim Preferences view. But the plugin didn't work.
>>>
>>>     1. In "Insert Diagram" dialogue, an error icon is displayed in the
>>> preview area when I click on the "Preview" button. When I click on the
>>> "OK" button, it says "An error occurred while generating the image. Do
>>> you want to save the source text anyway?".
>>>     2. I confirmed that the "dot" command from GraphViz is working as
>>> expected when I type it in a command line interface (both cmd.exe and
>>> MSYS shell are tested).
>>>     3. Following is a piece of GraphViz code I tested with:
>>>                 digraph G {
>>>                         foo -> bar
>>>                 }
>>>     4. I googled around and got nothing useful.
>>>
>>> So I'm wondering,
>>>
>>>     1. Did anyone see this problem before?
>>
>>
>> Just tested using source version of zim on windows 7 with Graphviz 2.21
>> installed. Works as expected.
>>
>> Not tested:
>> - compiled version of zim
>> - GraphViz 2.30
>>
>>
>>>
>>>     2. I can't find a log file anywhere, is there one? Or is there a
>>> switch to enable/disable logging?
>>
>>
>> The logging from zim can be found in "%TM%/zim.log", to get detailed debug
>> output use "zim -D --standalone". The log will include a line where the
>> "dot" command is executed, but not output from the dot command. Please check
>> this log for any bugs in zim itself (before calling dot).
>>
>>>
>>>     3. In .../zim-0.59/App/ZimDesktopWiki/zim/plugins/diagrameditor.py,
>>> line 107, I found:
>>>                 # Call GraphViz
>>>                 try:
>>>                         dot = Application(dotcmd)
>>>                         dot.run((self.pngfile, self.dotfile))
>>>                 except ApplicationError:
>>>                         return None, None # Sorry, no log
>>>                 else:
>>>                         return self.pngfile, None
>>>
>>> Is that "except" clause the right place to trace down the problem? (I
>>> don't know Python, sorry!)
>>
>>
>> Well, yes, but you don't have much info at that point since the dot command
>> does not generate a log. You can add a statement before "return None, None"
>> like:
>>
>>     except ApplicationError:
>>          import logging
>>          logger = logging.getLogger('zim.plugins.diagrameditor')
>>          logger.exception('Error running dot:')
>>          return None, None # Sorry, no log
>>
>> This will add any information that can be obtained to the log. But might not
>> be very informative.
>>
>> (be aware that python is sensitive to indenting level, so put is at the
>> proper depth)
>>
>>> I found that every ".py" file in that directory has a ".pyo" version,
>>> they seem to be "compiled" Python modules?
>>
>>
>> Yes, but don't worry, they are regenerated when the source is edited - no
>> need to compile anything yourself.
>>
>>>
>>> I don't have a Python compiler/runtime. If this is not a known issue
>>> or there's not a known solution for it, I'm gonna install one and
>>> start to learn some Python. I really love Zim for its simplicity and
>>> extensibility and its file system hierarchy for storage.
>>
>>
>> Actually you have :) it is compiled in the zim executable you have .. but
>> separate version is indeed easier for debugging.
>>
>> Regards,
>>
>> Jaap

_______________________________________________
Mailing list: https://launchpad.net/~zim-wiki
Post to     : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp

Reply via email to