jpivarski / svgfig

Automatically exported from code.google.com/p/svgfig
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

SVG.Save() on window #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download svgfig
2. write the 'hello world' svg as outlined in tutorial
3. issue the s.save() command

What is the expected output? What do you see instead?
expected to see tmp.svg but error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\svgfig.py", line 433, in save
    f = codecs.open(fileName, "w", encoding=encoding)
  File "C:\Python26\lib\codecs.py", line 865, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or 
directory: 'C:\\home\\AuChan\\Desktop\\tmp.svg

What version of the product are you using? On what operating system?
latest version on window

Please provide any additional information below.
Thank you very much ... 

Original issue reported on code.google.com by kenauc...@gmail.com on 18 Feb 2010 at 11:52

GoogleCodeExporter commented 9 years ago
Try giving an explicit filename to save to, for instance

>>> s.save(r"C:\directory\that\you\know\exists\tmp.svg")

If you don't give save() an explicit filename, it tries to put a new file (or
overwrite an old file) named "tmp.svg" in a reasonable place.  If you're using 
Mac or
Linux, the place where you're running Python is a reasonable place.  If you're 
using
Windows, Python lives in some strange C:\Python26\lib\ directory, where the user
doesn't often venture, and so my Windows test-user complained that this was a 
bad
place.  A much better place, for a Windows user, is on the Desktop (where just 
about
everything goes).  So the following code is used to find where the Desktop is:

if re.search("windows", platform.system(), re.I):
  try:
    import _winreg
    _default_directory =
_winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, \
                       r"Software\Microsoft\Windows\Current Version\Explorer\Shell
Folders"), "Desktop")[0]
#   tmpdir = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
"Environment"), "TEMP")[0]
#   if tmpdir[0:13] != "%USERPROFILE%":
#     tmpdir = os.path.expanduser("~") + tmpdir[13:]
  except:
    _default_directory = os.path.expanduser("~") + os.sep + "Desktop"

The commented-out part chooses the Windows temporary directory--- another place 
the
user doesn't often visit.

It's quite possible that this bit of code, which worked fine on Windows XP, 
doesn't
work on Windows Vista because they might have changed the way things are 
structured.
 If so, does anyone have any input on how this should work now, and possibly also how
to test for XP-versus-Vista (assuming that's the difference we're talking 
about)?

Original comment by jpivar...@gmail.com on 19 Feb 2010 at 1:45