Re: Issue with zipfile and symbolic link
On 2017-05-30 08:45, loial wrote: I am reading a list of pdf files from a directory which is a symbolic link and adding them to a zip file. Issue I have is that the zip files are being added as empty directories rather than the actual pdf files. My code is below. Any idea why this happening? # ZIP pdfs subdirectory if it exists sourcefile = self._dir + os.sep + "pdfs" targetname = "pdfs" if os.path.exists(sourcefile): zf.write(sourcefile,targetname, compress_type=compression) for file in os.listdir(sourcefile): targetname = "pdfs" + os.sep + file zf.write(sourcefile,targetname, compress_type=compression) # Close zip file zf.close() You're not changing 'sourcefile', it's always the path of the folder. -- https://mail.python.org/mailman/listinfo/python-list
Issue with zipfile and symbolic link
I am reading a list of pdf files from a directory which is a symbolic link and adding them to a zip file. Issue I have is that the zip files are being added as empty directories rather than the actual pdf files. My code is below. Any idea why this happening? # ZIP pdfs subdirectory if it exists sourcefile = self._dir + os.sep + "pdfs" targetname = "pdfs" if os.path.exists(sourcefile): zf.write(sourcefile,targetname, compress_type=compression) for file in os.listdir(sourcefile): targetname = "pdfs" + os.sep + file zf.write(sourcefile,targetname, compress_type=compression) # Close zip file zf.close() -- https://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
Peng Yu wrote: I find the following two files that define realpath. But I don't find 'realpath' in os.py. I looked at 'os.py'. But I don't understand how the function realpath is introduced in the name space in os.path. Would you please let me know? gfind . ! -path '*backup*' -name "*.py" -type f -exec grep -n "def realpath" {} \; -printf %p\\n\\n 193:def realpath(path): ./macpath.py 345:def realpath(filename): ./posixpath.py That is where realpath is. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
On Sat, Oct 31, 2009 at 14:48 -0500, Peng Yu wrote: > On Sat, Oct 31, 2009 at 1:46 PM, Terry Reedy wrote: > > Peng Yu wrote: [ snip ] > I find the following two files that define realpath. But I don't find > 'realpath' in os.py. I looked at 'os.py'. But I don't understand how > the function realpath is introduced in the name space in os.path. > Would you please let me know? > gfind . ! -path '*backup*' -name "*.py" -type f -exec grep -n "def > realpath" {} \; -printf %p\\n\\n > 193:def realpath(path): > ./macpath.py > > 345:def realpath(filename): > ./posixpath.py The os module needs to support different platforms. The os.path module is actually one of the platform specific ones (ntpath, posixpath, ...) that are imported 'as path' depending on the platform the code is executed. Have a look at the source code of the os module: --- os.py - Python 2.6.3 --- ... f 'posix' in _names: ... import posixpath as path elif 'nt' in _names: ... import ntpath as path import nt __all__.extend(_get_exports_list(nt)) del nt ... else: raise ImportError, 'no os specific module found' sys.modules['os.path'] = path --- snip --- If you really want to understand how a module is working then have a look at its source code. Python is open source --> Use that privilige! kind regards Wolodja Wentland signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
On Sat, Oct 31, 2009 at 1:46 PM, Terry Reedy wrote: > Peng Yu wrote: >> >> On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille >> wrote: >>> >>> On 10/31/2009 12:03 AM Peng Yu said... >>>> >>>> Suppose that I have the following directory and files. I want to get >>>> the canonical path of a file, a directory or a symbolic link. >>>> For example, for 'b' below, I want to get its canonical path as >>>> '/private/tmp/abspath/b'. >>> >>> So, why isn't realpath working for you? It looks like it is, and it >>> works >>> that way here: >>> >>>>>> os.path.realpath('/home/emile/vmlinuz') >>> >>> '/root/vmlinuz-2.4.7-10' >> >> My definition of 'realpath' is different from the definition of >> 'os.path.realpath'. But I'm not short what term I should use to >> describe. I use the following example to show what I want. >> >> In my example in the original post, >> >> '/tmp/abspath/b' is a symbolic link to '/tmp/abspath/a' and '/tmp' is >> a symbolic link to '/private/tmp'. >> >> Therefore, I want to get '/private/tmp/abspath/b', rather than >> '/private/tmp/abspath/a', as the canonical path of 'b'. >> >> If the argument is a symbolic link os.path.realpath will return the >> actually target of the symbolic link. However, I want the path of the >> symbolic link rather than the path of the target. >> >> Hope this is clear. > > I suspect that you will have to write your own code for your own function. > os and os.path are written in Python, so look at the code for realpath and > modify it for your modified definition. I find the following two files that define realpath. But I don't find 'realpath' in os.py. I looked at 'os.py'. But I don't understand how the function realpath is introduced in the name space in os.path. Would you please let me know? gfind . ! -path '*backup*' -name "*.py" -type f -exec grep -n "def realpath" {} \; -printf %p\\n\\n 193:def realpath(path): ./macpath.py 345:def realpath(filename): ./posixpath.py -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
On Sat, Oct 31, 2009 at 1:10 PM, Emile van Sebille wrote: > On 10/31/2009 10:11 AM Peng Yu said... >> >> My definition of 'realpath' is different from the definition of >> 'os.path.realpath'. But I'm not short what term I should use to >> describe. I use the following example to show what I want. >> >> In my example in the original post, >> >> '/tmp/abspath/b' is a symbolic link to '/tmp/abspath/a' and '/tmp' is >> a symbolic link to '/private/tmp'. >> >> Therefore, I want to get '/private/tmp/abspath/b', rather than >> '/private/tmp/abspath/a', as the canonical path of 'b'. >> > > It still looks like it works here. I've set up a similar structure and > appear to get the results you're asking for using os.path.realpath. > > # pwd > /home/emile > # ls -l > drwxr-xr-x 3 root root 4096 2009-10-31 10:25 private > lrwxrwxrwx 1 root root 11 2009-10-31 10:25 tmp -> private/tmp > > # pwd > /home/emile/tmp/abspath > # ls -l > -rw-r--r-- 1 root root 10 2009-10-31 10:25 a > lrwxrwxrwx 1 root root 1 2009-10-31 10:26 b -> a > > Python 2.6.3 (r263:75183, Oct 15 2009, 15:03:49) [GCC 4.3.2] on linux2 >>>> import os >>>> os.path.realpath('/home/emile/tmp/a') > '/home/emile/private/tmp/a' >>>> os.path.realpath('/home/emile/tmp/b') > '/home/emile/private/tmp/b' > >> If the argument is a symbolic link os.path.realpath will return the >> actually target of the symbolic link. However, I want the path of the >> symbolic link rather than the path of the target. > > Which is what I got above. I'm curious why we get different results. I tried on both linux and mac. Both of them give me the same results. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
Peng Yu wrote: On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille wrote: On 10/31/2009 12:03 AM Peng Yu said... Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want to get its canonical path as '/private/tmp/abspath/b'. So, why isn't realpath working for you? It looks like it is, and it works that way here: os.path.realpath('/home/emile/vmlinuz') '/root/vmlinuz-2.4.7-10' My definition of 'realpath' is different from the definition of 'os.path.realpath'. But I'm not short what term I should use to describe. I use the following example to show what I want. In my example in the original post, '/tmp/abspath/b' is a symbolic link to '/tmp/abspath/a' and '/tmp' is a symbolic link to '/private/tmp'. Therefore, I want to get '/private/tmp/abspath/b', rather than '/private/tmp/abspath/a', as the canonical path of 'b'. If the argument is a symbolic link os.path.realpath will return the actually target of the symbolic link. However, I want the path of the symbolic link rather than the path of the target. Hope this is clear. I suspect that you will have to write your own code for your own function. os and os.path are written in Python, so look at the code for realpath and modify it for your modified definition. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
On 10/31/2009 10:11 AM Peng Yu said... > > My definition of 'realpath' is different from the definition of > 'os.path.realpath'. But I'm not short what term I should use to > describe. I use the following example to show what I want. > > In my example in the original post, > > '/tmp/abspath/b' is a symbolic link to '/tmp/abspath/a' and '/tmp' is > a symbolic link to '/private/tmp'. > > Therefore, I want to get '/private/tmp/abspath/b', rather than > '/private/tmp/abspath/a', as the canonical path of 'b'. > It still looks like it works here. I've set up a similar structure and appear to get the results you're asking for using os.path.realpath. # pwd /home/emile # ls -l drwxr-xr-x 3 root root 4096 2009-10-31 10:25 private lrwxrwxrwx 1 root root 11 2009-10-31 10:25 tmp -> private/tmp # pwd /home/emile/tmp/abspath # ls -l -rw-r--r-- 1 root root 10 2009-10-31 10:25 a lrwxrwxrwx 1 root root 1 2009-10-31 10:26 b -> a Python 2.6.3 (r263:75183, Oct 15 2009, 15:03:49) [GCC 4.3.2] on linux2 >>> import os >>> os.path.realpath('/home/emile/tmp/a') '/home/emile/private/tmp/a' >>> os.path.realpath('/home/emile/tmp/b') '/home/emile/private/tmp/b' If the argument is a symbolic link os.path.realpath will return the actually target of the symbolic link. However, I want the path of the symbolic link rather than the path of the target. Which is what I got above. Hope this is clear. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille wrote: > On 10/31/2009 12:03 AM Peng Yu said... >> >> Suppose that I have the following directory and files. I want to get >> the canonical path of a file, a directory or a symbolic link. >> For example, for 'b' below, I want to get its canonical path as >> '/private/tmp/abspath/b'. > > So, why isn't realpath working for you? It looks like it is, and it works > that way here: > >>>> os.path.realpath('/home/emile/vmlinuz') > '/root/vmlinuz-2.4.7-10' My definition of 'realpath' is different from the definition of 'os.path.realpath'. But I'm not short what term I should use to describe. I use the following example to show what I want. In my example in the original post, '/tmp/abspath/b' is a symbolic link to '/tmp/abspath/a' and '/tmp' is a symbolic link to '/private/tmp'. Therefore, I want to get '/private/tmp/abspath/b', rather than '/private/tmp/abspath/a', as the canonical path of 'b'. If the argument is a symbolic link os.path.realpath will return the actually target of the symbolic link. However, I want the path of the symbolic link rather than the path of the target. Hope this is clear. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the realpath of a symbolic link?
On 10/31/2009 12:03 AM Peng Yu said... Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want to get its canonical path as '/private/tmp/abspath/b'. So, why isn't realpath working for you? It looks like it is, and it works that way here: >>> os.path.realpath('/home/emile/vmlinuz') '/root/vmlinuz-2.4.7-10' Emile -- http://mail.python.org/mailman/listinfo/python-list
How to get the realpath of a symbolic link?
Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want to get its canonical path as '/private/tmp/abspath/b'. However, os.path.abspath('b') gives me '/private/tmp/abspath/b', but os.path.abspath('/tmp/abspath/b') gives me '/tmp/abspath/b'. The results are not the same. So, neither os.path.abspath or os.path.realpath gives me what I want. I'm wondering if there is a way to get the canonical path '/private/tmp/abspath/b', no matter whether the argument is 'b' or '/tmp/abspath/b'. $./test.py /private/tmp/abspath/a /private/tmp/abspath/a /private/tmp/abspath/a /private/tmp/abspath/a /private/tmp/abspath/a /private/tmp/abspath/b /tmp/abspath/a /tmp/abspath/b $cat test.py #!/usr/bin/env python import os.path print os.path.realpath('a') print os.path.realpath('b') print os.path.realpath('/tmp/abspath/a') print os.path.realpath('/tmp/abspath/b') print os.path.abspath('a') print os.path.abspath('b') print os.path.abspath('/tmp/abspath/a') print os.path.abspath('/tmp/abspath/b') $pwd /tmp/abspath $gls -Rgtra .: total 8 -rw-r--r-- 1 wheel 0 2009-10-31 01:52 a lrwxr-xr-x 1 wheel 1 2009-10-31 01:52 b -> a -rwx--x--x 1 wheel 312 2009-10-31 01:54 test.py drwx-- 5 wheel 170 2009-10-31 01:54 . drwxrwxrwt 23 wheel 782 2009-10-31 01:56 .. $gls -lgtr /tmp lrwxr-xr-x 1 admin 11 2009-05-21 04:28 /tmp -> private/tmp -- http://mail.python.org/mailman/listinfo/python-list
Re: How to test if a file is a symbolic link?
Peng Yu writes: > 'symbolic_link' is a symbolic link in the current directory. I run > 'python main.py', but it does not return me anything. I want to check > if a file is a symbolic link. You have the same access to the Python help as we do: >>> import os.path >>> help(os.path) You have the same access to the Python documentation search facility as we do: http://docs.python.org/library/os.path.html>. So I'm puzzled: why do you bring so very many questions to this group that are answered quickly by an obvious search of the standard library? -- \ “I've always wanted to be somebody, but I see now that I should | `\ have been more specific.” —Jane Wagner, via Lily Tomlin | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: How to test if a file is a symbolic link?
import os if os.path.islink('symbolic_link'): print "hello." Cheers, Mahmoud Abdelkader On Oct 28, 2009, at 11:19 PM, Peng Yu wrote: 'symbolic_link' is a symbolic link in the current directory. I run 'python main.py', but it does not return me anything. I want to check if a file is a symbolic link. I'm wondering what is the correct way to do so? $cat main.py import stat import os st = os.stat('symbolic_link') if stat.S_ISLNK(st.st_mode): print "Hello" -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: How to test if a file is a symbolic link?
On Wed, 28 Oct 2009 22:19:55 -0500, Peng Yu wrote: > 'symbolic_link' is a symbolic link in the current directory. I run > 'python main.py', but it does not return me anything. I want to check if > a file is a symbolic link. I'm wondering what is the correct way to do > so? > > $cat main.py > import stat > import os > > st = os.stat('symbolic_link') > if stat.S_ISLNK(st.st_mode): > print "Hello" I believe os.stat follows links, so you're testing if the original file is a symbolic link. You want to use os.lstat, or the os.path.islink() function. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How to test if a file is a symbolic link?
On 2009-10-29 11:19, Peng Yu wrote: 'symbolic_link' is a symbolic link in the current directory. I run 'python main.py', but it does not return me anything. I want to check if a file is a symbolic link. I'm wondering what is the correct way to do so? $cat main.py import stat import os st = os.stat('symbolic_link') if stat.S_ISLNK(st.st_mode): print "Hello" Use os.lstat instead of os.stat to prevent following symbolic links. Or more directly, use os.path.islink() -- http://mail.python.org/mailman/listinfo/python-list
Re: How to test if a file is a symbolic link?
On Wed, 28 Oct 2009 22:19:55 -0500 Peng Yu wrote: > 'symbolic_link' is a symbolic link in the current directory. I run > 'python main.py', but it does not return me anything. I want to check > if a file is a symbolic link. I'm wondering what is the correct way to > do so? > > $cat main.py > import stat > import os As soon as you import os the OS that you are running is relevant. I'll assume some sort of Unix. > st = os.stat('symbolic_link') The os module uses the underlying OS calls. run "man 2 stat" to see what stat does. I think you will find that lstat is what you want. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
How to test if a file is a symbolic link?
'symbolic_link' is a symbolic link in the current directory. I run 'python main.py', but it does not return me anything. I want to check if a file is a symbolic link. I'm wondering what is the correct way to do so? $cat main.py import stat import os st = os.stat('symbolic_link') if stat.S_ISLNK(st.st_mode): print "Hello" -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
On Sep 9, 10:05 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>,samwysewrote: > > > A hard-link, OTOH, allows > > direct access to the contents of a file, as long as it is on the same > > filesystem. No extra steps are required, so the process runs a few > > microseconds faster, and directory-level permissions can't get in the way. > > Hard links are best avoided, because of the confusion they can cause. There are reasons to use hard links, there are reasons to use symbolic links. Depending on the circumstances, either could "cause confusion" simply because either could do something other than what's needed. Here's a handy chart to help decide which is appropriate: http://publib.boulder.ibm.com/iseries/v5r1/ic2924/index.htm?info/ifs/rzaaxmstlinkcmp.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
In message <[EMAIL PROTECTED]>, samwyse wrote: > A hard-link, OTOH, allows > direct access to the contents of a file, as long as it is on the same > filesystem. No extra steps are required, so the process runs a few > microseconds faster, and directory-level permissions can't get in the way. Hard links are best avoided, because of the confusion they can cause. -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
mosscliffe wrote: > On 22 Aug, 00:05, Ian Clark <[EMAIL PROTECTED]> wrote: >> >>>On Aug 19, 4:29 pm,mosscliffe<[EMAIL PROTECTED]> wrote: >>> >>>>The source file is in an area which python can see, but not the >>>>browser. I am trying to make a link in a browser friendly area so I >>>>can use it to display an image file. >> >>My question would be why a symbolic link? Why not a hard link? Are the >>two directories on different mount points? After the script finishes >>does python need to see that image file again? Why not just move it? > > I have tested a hard link now and it seems to work fine. I am > deleting the link/s at the end of the session/s. This is a bit late, but the reason the symbolic link won't work is because it's the web-server that's resolving it. The browser can only see things that the web-server, huh, serves, so what was meant in the first paragraph above was that the web server couldn't access the file in its original location. If you create a sym-link, the web server opens the link, finds out the actual location of the file, and tries to open that file, which it still can't do. A hard-link, OTOH, allows direct access to the contents of a file, as long as it is on the same filesystem. No extra steps are required, so the process runs a few microseconds faster, and directory-level permissions can't get in the way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
In message <[EMAIL PROTECTED]>, Ian Clark wrote: > My question would be why a symbolic link? Why not a hard link? Because of the potential for confusion. For instance, modifying the file without realizing that some other place expects to see the unmodified version. -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
On 22 Aug, 00:05, Ian Clark <[EMAIL PROTECTED]> wrote: > Hyuga wrote: > > On Aug 19, 4:29 pm,mosscliffe<[EMAIL PROTECTED]> wrote: > >> The source file is in an area which python can see, but not the > >> browser. I am trying to make a link in a browser friendly area so I > >> can use it to display an image file. > > > You might want to try using an .htaccess file. Place a file > > called .htaccess in the "browser friendly area" and place in it the > > line: > > > Options +FollowSymLinks > > > Assuming your hosting service will allow that, then it should work. > > If not, then why not just copy the image files? Storage is cheap > > these days. > > > Hyuga > > My question would be why a symbolic link? Why not a hard link? Are the > two directories on different mount points? After the script finishes > does python need to see that image file again? Why not just move it? > > Ian I just imagined a symbolic link would be quicker. I have tested a hard link now and it seems to work fine. I am deleting the link/s at the end of the session/s. I think a link is better than a move, because there is always a possibility I might somehow delete the moved file and then I would lose the original one. Thanks for your help. Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
Hyuga wrote: > On Aug 19, 4:29 pm, mosscliffe <[EMAIL PROTECTED]> wrote: >> The source file is in an area which python can see, but not the >> browser. I am trying to make a link in a browser friendly area so I >> can use it to display an image file. > > You might want to try using an .htaccess file. Place a file > called .htaccess in the "browser friendly area" and place in it the > line: > > Options +FollowSymLinks > > Assuming your hosting service will allow that, then it should work. > If not, then why not just copy the image files? Storage is cheap > these days. > > Hyuga > My question would be why a symbolic link? Why not a hard link? Are the two directories on different mount points? After the script finishes does python need to see that image file again? Why not just move it? Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
On Aug 19, 4:29 pm, mosscliffe <[EMAIL PROTECTED]> wrote: > The source file is in an area which python can see, but not the > browser. I am trying to make a link in a browser friendly area so I > can use it to display an image file. You might want to try using an .htaccess file. Place a file called .htaccess in the "browser friendly area" and place in it the line: Options +FollowSymLinks Assuming your hosting service will allow that, then it should work. If not, then why not just copy the image files? Storage is cheap these days. Hyuga -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
On 19 Aug, 13:16, samwyse <[EMAIL PROTECTED]> wrote: > mosscliffewrote: > > I am trying to create a link to a file, which I can then use in an > > HTML page. > > > The system is Linux on a hosted web service, running python 2.3. > > Other than that I have no knowledge of the system. > > > The link is created OK, but when I try to use it as filename for the > > IMG TAG, it does not get displayed. The page source of the created > > page is pointing to the link as temp/test1.jpg > > What are you trying to do that you can't use the original file instead > of creating a link? There might be a way to side-step the entire problem. The source file is in an area which python can see, but not the browser. I am trying to make a link in a browser friendly area so I can use it to display an image file. Thanks Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
mosscliffe wrote: > I am trying to create a link to a file, which I can then use in an > HTML page. > > The system is Linux on a hosted web service, running python 2.3. > Other than that I have no knowledge of the system. > > The link is created OK, but when I try to use it as filename for the > IMG TAG, it does not get displayed. The page source of the created > page is pointing to the link as temp/test1.jpg What are you trying to do that you can't use the original file instead of creating a link? There might be a way to side-step the entire problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
mosscliffe schrieb: > On 18 Aug, 23:49, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> mosscliffe schrieb: >> >> >> >>> I am trying to create a link to a file, which I can then use in an >>> HTML page. >>> The system is Linux on a hosted web service, running python 2.3. >>> Other than that I have no knowledge of the system. >>> The link is created OK, but when I try to use it as filename for the >>> IMG TAG, it does not get displayed. The page source of the created >>> page is pointing to the link as temp/test1.jpg >>> Any ideas ? >>> srcFile = "temp/test2.jpg" >>> linkFile = "temp/test1.jpg" >>> if os.path.islink(linkFile): >>> print "Link Exists", nl >>> pass >>> else: >>> print "Making Link", nl >>> os.symlink(srcFile, linkFile) >>> print 'the image' % linkFile >>> print 'the image' % srcFile >> In what environment is that script running? If it's apache, it might be >> that the apache settings disallow for following links. >> >> Diez > > It is Apache. > > Can I create some override in the current directory. I am afraid my > Apache skills are almost zero. As are mine. At least from the top of my head. You better ask in a more apache-centric forum. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
On 18 Aug, 23:49, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > mosscliffe schrieb: > > > > > I am trying to create a link to a file, which I can then use in an > > HTML page. > > > The system is Linux on a hosted web service, running python 2.3. > > Other than that I have no knowledge of the system. > > > The link is created OK, but when I try to use it as filename for the > > IMG TAG, it does not get displayed. The page source of the created > > page is pointing to the link as temp/test1.jpg > > > Any ideas ? > > > srcFile = "temp/test2.jpg" > > > linkFile = "temp/test1.jpg" > > > if os.path.islink(linkFile): > > print "Link Exists", nl > > pass > > else: > > print "Making Link", nl > > os.symlink(srcFile, linkFile) > > > print 'the image' % linkFile > > > print 'the image' % srcFile > > In what environment is that script running? If it's apache, it might be > that the apache settings disallow for following links. > > Diez It is Apache. Can I create some override in the current directory. I am afraid my Apache skills are almost zero. Thanks Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
mosscliffe schrieb: > I am trying to create a link to a file, which I can then use in an > HTML page. > > The system is Linux on a hosted web service, running python 2.3. > Other than that I have no knowledge of the system. > > The link is created OK, but when I try to use it as filename for the > IMG TAG, it does not get displayed. The page source of the created > page is pointing to the link as temp/test1.jpg > > Any ideas ? > > srcFile = "temp/test2.jpg" > > linkFile = "temp/test1.jpg" > > if os.path.islink(linkFile): > print "Link Exists", nl > pass > else: > print "Making Link", nl > os.symlink(srcFile, linkFile) > > print 'the image' % linkFile > > print 'the image' % srcFile In what environment is that script running? If it's apache, it might be that the apache settings disallow for following links. Diez -- http://mail.python.org/mailman/listinfo/python-list
Symbolic Link
I am trying to create a link to a file, which I can then use in an HTML page. The system is Linux on a hosted web service, running python 2.3. Other than that I have no knowledge of the system. The link is created OK, but when I try to use it as filename for the IMG TAG, it does not get displayed. The page source of the created page is pointing to the link as temp/test1.jpg Any ideas ? srcFile = "temp/test2.jpg" linkFile = "temp/test1.jpg" if os.path.islink(linkFile): print "Link Exists", nl pass else: print "Making Link", nl os.symlink(srcFile, linkFile) print 'the image' % linkFile print 'the image' % srcFile -- http://mail.python.org/mailman/listinfo/python-list