From: David AW B. <dav...@ci...> - 2008-04-23 09:10:25
|
You can try using: pypath, pyfile = ospath.split(__file__) c.writePDFfile(pypath + '/otherfolder/output') This will put it in a subdir of the python script regardless of where you run it from. (I.e., you can do something like "python /some/absolute/path/script.py" from your home directory and it will put it in /some/absolute/path/otherfolder *rather than* putting it in a subdir of your current directory.) Dave André Wobst wrote: > works for me. > > Example: > > andre@pb:~/python/pyx$ cat hello.py > from pyx import * > > c = canvas.canvas() > c.stroke(path.line(0, 0, 2, 0)) > c.writePDFfile("doesexist/hello") > c.writePDFfile("doesnotexist/hello") > > Running ... > > andre@pb:~/python/pyx$ python hello.py > Traceback (most recent call last): > File "hello.py", line 6, in <module> > c.writePDFfile("doesnotexist/hello") > File "/Users/andre/wobsta/dpg/2008/stat/pyx/canvas.py", line > 288, in wrappedindocument > return method(d, file) > File "/Users/andre/wobsta/dpg/2008/stat/pyx/document.py", line > 171, in writePDFfile > pdfwriter.PDFwriter(self, _outputstream(file, "pdf"), **kwargs) > File "/Users/andre/wobsta/dpg/2008/stat/pyx/document.py", line > 147, in _outputstream > return open("%s.%s" % (file, suffix), "wb") > IOError: [Errno 2] No such file or directory: 'doesnotexist/ > hello.pdf' > > and creates ... > > andre@pb:~/python/pyx$ ls *exist/* > doesexist/hello.pdf > > > > André > > > Am 22.04.2008 um 20:23 schrieb Rich Shepard: > >> On Tue, 22 Apr 2008, Alan G Isaac wrote: >> >>> What happens when you use a relative path? You can always use an >>> absolute >>> path. Or so I recall ... (on the run). >> Alan, >> >> I must have not clearly expressed my question. I cannot get the >> proper >> syntax. >> >> If I use: >> >> g.writePDFfile('./reports/'+curComp + '_' + curSub + '_' + >> curVar) >> >> nothing is written. If I use >> >> g.writePDFfile(./reports/+curComp + '_' + curSub + '_' + curVar) >> >> python finds the '.' to be a syntax error. >> >> So, let me ask the question this way: how do I write the statement >> to >> direct output to a subdirectory immediately below the CWD in which the >> application is running? >> >> Thanks, >> >> Rich >> >> -- >> Richard B. Shepard, Ph.D. | Integrity >> Credibility >> Applied Ecosystem Services, Inc. | Innovation >> <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: >> 503-667-8863 >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference >> Don't miss this year's exciting event. There's still time to save >> $100. >> Use priority code J8TL2D2. >> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >> _______________________________________________ >> PyX-user mailing list >> PyX...@li... >> https://lists.sourceforge.net/lists/listinfo/pyx-user >> > |