Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep going when there is conversion error. #29

Open
xuehuichao opened this issue Nov 21, 2016 · 2 comments
Open

Keep going when there is conversion error. #29

xuehuichao opened this issue Nov 21, 2016 · 2 comments

Comments

@xuehuichao
Copy link
Owner

Right now the script may quit during conversion errors. For example:

INFO: MainThread Exiting freemindlatex ...
Traceback (most recent call last):
  File "/usr/local/google/home/xuehuichao/.local/bin/freemindlatex", line 11, in <module>
    sys.exit(main())
  File "/usr/local/google/home/xuehuichao/.local/lib/python2.7/site-packages/freemindlatex/__main__.py", line 377, in main
    RunEditingEnvironment(cwd)
  File "/usr/local/google/home/xuehuichao/.local/lib/python2.7/site-packages/freemindlatex/__main__.py", line 345, in RunEditingEnvironment
    CompileDir(directory)
  File "/usr/local/google/home/xuehuichao/.local/lib/python2.7/site-packages/freemindlatex/__main__.py", line 259, in CompileDir
    result = _CompileInWorkingDirectory(work_dir)
  File "/usr/local/google/home/xuehuichao/.local/lib/python2.7/site-packages/freemindlatex/__main__.py", line 208, in _CompileInWorkingDirectory
    'utf8').read())
  File "/usr/local/google/home/xuehuichao/.local/lib/python2.7/site-packages/freemindlatex/convert.py", line 345, in __init__
    dom = minidom.parseString(mm_file_content)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: no element found: line 1, column 0

In this case, evince will quit. We should keep going in this case, and possibly produce errors to the compiled pages.

@xuehuichao
Copy link
Owner Author

The conversion error may come from a race condition: freemind writes to the file while we haven't finished the last conversion.

@xuehuichao
Copy link
Owner Author

It is actually because I tried reading files when they are not ready. It is too often that when I hit save, and the program tries to read the file at the same time.

I currently check mtime. mtime changes when the file is open for write, before it's closed. When the writes (e.g. to .mm) takes more than a couple of ms, there is a high chance that my read happens before the write is finished. I currently added a "sleep" statement to avoid this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant