Opened 15 years ago
Closed 15 years ago
#7037 closed defect (fixed)
The DiaVisView plugin does not work on Windows
Reported by: | Glenn Ramsey | Owned by: | robert_martin |
---|---|---|---|
Priority: | normal | Component: | DiaVisViewPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
DiaVisView plugin does not work on Windows. It fails with the message:
32The process cannot access the file because it is being used by another process
This is appears to be because it uses the popen2.Popen4 class, which is not available on Windows.
The log says this:
2010-04-28 15:49:08,358 Trac[loader] ERROR: Skipping "DiaVisView.DiaVisView = DiaVisView.DiaVisView": (can't import "ImportError: cannot import name Popen4") 2010-04-28 15:49:31,187 Trac[diavisview] INFO: Getting file modification times. 2010-04-28 15:49:31,203 Trac[diavisview] INFO: Comparing dia and png file modification times : 1268358663.05, 1268358663.05 2010-04-28 15:49:31,203 Trac[diavisview] INFO: Running Dia : dia -l --filter=png --export=c:\trac\attachments\wiki\diatest\Diagram1.png c:\trac\attachments\wiki\diatest\Diagram1.dia 2010-04-28 15:49:31,203 Trac[diavisview] INFO: Dia failed with exception= 'module' object has no attribute 'Popen4' 2010-04-28 15:49:31,203 Trac[diavisview] INFO: Error unlinking uncompressed file for Dia:- c:\trac\attachments\wiki\diatest\decomp_Diagram1.dia 2010-04-28 15:49:31,217 Trac[formatter] ERROR: Macro DiaVisView(Diagram1.dia) failed: Traceback (most recent call last): File "C:\Python25\lib\site-packages\trac-0.11.5rc1-py2.5-win32.egg\trac\wiki\formatter.py", line 480, in _macro_formatter return macro.process(args, in_paragraph=True) File "C:\Python25\lib\site-packages\trac-0.11.5rc1-py2.5-win32.egg\trac\wiki\formatter.py", line 180, in process text = self.processor(text) File "C:\Python25\lib\site-packages\trac-0.11.5rc1-py2.5-win32.egg\trac\wiki\formatter.py", line 167, in _macro_processor text) File "build\bdist.win32\egg\DiaVisView\DiaVisView.py", line 177, in expand_macro os.unlink(decompFileName) WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'c:\\trac\\attachments\\wiki\\diatest\\decomp_Diagram1.dia'
Attachments (0)
Change History (6)
comment:1 Changed 15 years ago by
comment:2 follow-up: 3 Changed 15 years ago by
Yes, that works. Thanks. Another issue is that the block of code above that which tries to decompress the file also doesn't work on Windows. One of the issues is that it uses os.link() which AFAIK is unix only. I have commented that block out in my version.
comment:3 follow-up: 4 Changed 15 years ago by
Replying to glennr:
Another issue is that the block of code above that which tries to decompress the file also doesn't work on Windows.
I have no idea why the plugin has this decompression feature anyway. Dia does (de-) compression transparently anyway, so there is no need for this feature, IMHO.
One of the issues is that it uses os.link() which AFAIK is unix only. I have commented that block out in my version.
Like this?
--- DiaVisView.py.orig 2010-06-02 10:39:51.034011345 +0200 +++ DiaVisView.py 2010-06-02 10:44:30.746010956 +0200 @@ -13,7 +13,6 @@ import os import popen2 import re -import gzip import Image @@ -133,31 +132,6 @@ if (dia_mtime > png_mtime) or (existing_width != width): try: - # The file maybe compressed. The name has to be prepended to keep the extension. - (attachDir, attachFile) = os.path.split(dia_path) - decompFileName = os.path.join(attachDir, 'decomp_' + attachFile) - try: - decompFile = open(decompFileName , 'w') - except Exception, e: - self.env.log.info('Creating temp uncompressed file for Dia Failed = %s',e) - raise Exception('Dia execution failed.') - try: - for line in gzip.GzipFile(dia_path): - decompFile.write(line) - except IOError, e: - if e.message == 'Not a gzipped file': - self.env.log.info('Not a gzipped file, so linking %s', dia_path) - try: - os.unlink(decompFileName) - os.link(dia_path, decompFileName) - except Exception, e: - self.env.log.info('Error linking uncompressed file for Dia:- %s', dia_path) - raise - else: - self.env.log.info('Error decompressing file for Dia = %s',e) - raise Exception('Dia execution failed.') - finally: - decompFile.close if width: diacmd = 'dia -l --filter=png --size=%dx --export=%s %s' % (int(width), png_path, dia_path) else: @@ -172,12 +146,6 @@ except Exception, e: self.env.log.info('Dia failed with exception= %s',e) raise Exception('Dia execution failed.') - finally: - try: - os.unlink(decompFileName) - except Exception, e: - self.env.log.info('Error unlinking uncompressed file for Dia:- %s', decompFileName) - raise (png_file_size, png_file_time) = os.stat(png_path)[6:8] # Based on attachment.py, insert
(Careful! Untested patch.)
comment:4 Changed 15 years ago by
comment:5 Changed 15 years ago by
comment:6 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Could you please try the following patch? It uses the subprocess API instead of popen and works well on Debian GNU/Linux. I don't have a Windows machine to test.