Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40509 > unrolled thread
| Started by | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-03-05 01:00 -0800 |
| Last post | 2013-03-05 14:04 +0000 |
| Articles | 15 — 6 participants |
Back to article view | Back to comp.lang.python
Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 01:00 -0800
Re: Downloading a file form a displayed table Dave Angel <davea@davea.name> - 2013-03-05 04:45 -0500
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 01:48 -0800
Re: Downloading a file form a displayed table Dave Angel <davea@davea.name> - 2013-03-05 05:05 -0500
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 01:48 -0800
Re: Downloading a file form a displayed table Dave Angel <davea@davea.name> - 2013-03-05 04:51 -0500
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 02:24 -0800
Re: Downloading a file form a displayed table Lele Gaifax <lele@metapensiero.it> - 2013-03-05 12:29 +0100
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 02:24 -0800
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 05:01 -0800
Re: Downloading a file form a displayed table Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-05 08:38 -0500
Re: Downloading a file form a displayed table "Vytas D." <vytasd2013@gmail.com> - 2013-03-05 13:38 +0000
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 06:37 -0800
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 06:37 -0800
Re: Downloading a file form a displayed table Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-05 14:04 +0000
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 01:00 -0800 |
| Subject | Downloading a file form a displayed table |
| Message-ID | <f99ae3d5-6f1f-4dfc-84da-78b758a5147a@googlegroups.com> |
# =================================================================================================================
# display download button for each file and downlaod it on click
# =================================================================================================================
if form.getvalue('show') == 'files':
print ( "<center><a href='http://superhost.gr/files.html'> <img src='/data/images/download.png'></a><br>" )
print ( "<table border=5 cellpadding=5 bgcolor=blue>" )
path = "/data/files/"
for filename in os.walk(path):
print '''
<form method="get" action="%s">
print( "<tr><td><center> <button type='submit'> %s </button> </td></tr>" ) % filename
</form>
'''
sys.exit(0)
========================
I use the above code to tidplay a filenames table so the user cna download a displayed button style lookign file but its not printing anything for me just an emptry table
'/data/files' has 5 files in it but its not showing any.
I dont see what iam doign wrong
[toc] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-03-05 04:45 -0500 |
| Message-ID | <mailman.2872.1362476722.2939.python-list@python.org> |
| In reply to | #40509 |
On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote:
> # =================================================================================================================
> # display download button for each file and downlaod it on click
> # =================================================================================================================
> if form.getvalue('show') == 'files':
>
> print ( "<center><a href='http://superhost.gr/files.html'> <img src='/data/images/download.png'></a><br>" )
> print ( "<table border=5 cellpadding=5 bgcolor=blue>" )
>
> path = "/data/files/"
>
> for filename in os.walk(path):
> print '''
> <form method="get" action="%s">
> print( "<tr><td><center> <button type='submit'> %s </button> </td></tr>" ) % filename
> </form>
> '''
>
> sys.exit(0)
>
> ========================
>
> I use the above code to tidplay a filenames table so the user cna download a displayed button style lookign file but its not printing anything for me just an emptry table
>
> '/data/files' has 5 files in it but its not showing any.
> I dont see what iam doign wrong
>
It would be useful to actually specifying the context of this fragment
of code. Presumably it's running on a web server somewhere, and you're
expecting the filenames to somehow show up on a browser. Which OS and
which version of Python for that server, and what brand and version of
browser?
Have you considered closing the table, and ending the body of the page?
Have you looked at the result with View->Source in your browser?
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 01:48 -0800 |
| Message-ID | <d1eb23c3-8ad2-4131-b3ed-2a3602105b26@googlegroups.com> |
| In reply to | #40510 |
Τη Τρίτη, 5 Μαρτίου 2013 11:45:09 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > It would be useful to actually specifying the context of this fragment > > of code. Presumably it's running on a web server somewhere, and you're > > expecting the filenames to somehow show up on a browser. Which OS and > > which version of Python for that server, and what brand and version of > > browser? > > > > Have you considered closing the table, and ending the body of the page? The server run Linux and python version is v2.7 and the browser is Chrome v27 The source appears empty. Frankly i dont see anythign wrong with my code: path = "/data/files/" for filename in os.walk(path): print ''' <form method="get" action="%s"> <tr><td><center> <button type="submit"> %s </button> </td></tr> </form> ''' % (filename, filename) sys.exit(0)
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-03-05 05:05 -0500 |
| Message-ID | <mailman.2876.1362477912.2939.python-list@python.org> |
| In reply to | #40512 |
On 03/05/2013 04:48 AM, Νίκος Γκρ33κ wrote: > Τη Τρίτη, 5 Μαρτίου 2013 11:45:09 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > >> It would be useful to actually specifying the context of this fragment >> >> of code. Presumably it's running on a web server somewhere, and you're >> >> expecting the filenames to somehow show up on a browser. Which OS and >> >> which version of Python for that server, and what brand and version of >> >> browser? >> >> >> >> Have you considered closing the table, and ending the body of the page? > > The server run Linux and python version is v2.7 and the browser is Chrome v27 > > The source appears empty. In that case, there's something wrong far outside of this code fragment. A web page (html) has lots of required elements which were presumably in other parts of the script that are not shown here. > > Frankly i dont see anythign wrong with my code: > > path = "/data/files/" > > for filename in os.walk(path): > print ''' > <form method="get" action="%s"> > <tr><td><center> <button type="submit"> %s </button> </td></tr> > </form> > ''' % (filename, filename) > > sys.exit(0) > -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 01:48 -0800 |
| Message-ID | <mailman.2874.1362476930.2939.python-list@python.org> |
| In reply to | #40510 |
Τη Τρίτη, 5 Μαρτίου 2013 11:45:09 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > It would be useful to actually specifying the context of this fragment > > of code. Presumably it's running on a web server somewhere, and you're > > expecting the filenames to somehow show up on a browser. Which OS and > > which version of Python for that server, and what brand and version of > > browser? > > > > Have you considered closing the table, and ending the body of the page? The server run Linux and python version is v2.7 and the browser is Chrome v27 The source appears empty. Frankly i dont see anythign wrong with my code: path = "/data/files/" for filename in os.walk(path): print ''' <form method="get" action="%s"> <tr><td><center> <button type="submit"> %s </button> </td></tr> </form> ''' % (filename, filename) sys.exit(0)
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-03-05 04:51 -0500 |
| Message-ID | <mailman.2875.1362477114.2939.python-list@python.org> |
| In reply to | #40509 |
On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote: > > <snip> > for filename in os.walk(path): But os.walk() doesn't return a filename. It returns a tuple. Have you tested any of this code outside of a server? Also, you're using tabs here. They don't show up in most email programs, so you're better off replacing them with an appropriate number of spaces. After all, indentation matters. > print ''' > <form method="get" action="%s"> > print( "<tr><td><center> <button type='submit'> %s </button> </td></tr>" ) % filename > </form> > ''' > > sys.exit(0) > -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 02:24 -0800 |
| Message-ID | <91d6d661-1e6b-4365-8fa3-e46425705d78@googlegroups.com> |
| In reply to | #40514 |
Τη Τρίτη, 5 Μαρτίου 2013 11:51:41 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote: > > > > > > <snip> > > > > > for filename in os.walk(path): > > > > But os.walk() doesn't return a filename. It returns a tuple. Have you > > tested any of this code outside of a server? > > > > Also, you're using tabs here. They don't show up in most email > > programs, so you're better off replacing them with an appropriate number > > of spaces. After all, indentation matters. > > > > > > > print ''' > > > <form method="get" action="%s"> > > > print( "<tr><td><center> <button type='submit'> %s </button> </td></tr>" ) % filename > > > </form> > > > ''' > > > > > > sys.exit(0) > > > > > -- > > DaveA How is this lien supposed to be written do to iterate over a list of filenames? for filename in list( os.walk(path) ): i tried the above but still it doesn't work out.
[toc] | [prev] | [next] | [standalone]
| From | Lele Gaifax <lele@metapensiero.it> |
|---|---|
| Date | 2013-03-05 12:29 +0100 |
| Message-ID | <mailman.2878.1362482981.2939.python-list@python.org> |
| In reply to | #40516 |
Νίκος Γκρ33κ <nikos.gr33k@gmail.com> writes:
> How is this lien supposed to be written do to iterate over a list of filenames?
>
> for filename in list( os.walk(path) ):
>
> i tried the above but still it doesn't work out.
Please learn how Python itself can help you:
$ python
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> help(os.walk)
Help on function walk in module os:
walk(top, topdown=True, onerror=None, followlinks=False)
Directory tree generator.
...
Example:
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
...
In general, the builtin help() function displays the documentation for
either a single function or a whole module.
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it | -- Fortunato Depero, 1929.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 02:24 -0800 |
| Message-ID | <mailman.2887.1362494522.2939.python-list@python.org> |
| In reply to | #40514 |
Τη Τρίτη, 5 Μαρτίου 2013 11:51:41 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote: > > > > > > <snip> > > > > > for filename in os.walk(path): > > > > But os.walk() doesn't return a filename. It returns a tuple. Have you > > tested any of this code outside of a server? > > > > Also, you're using tabs here. They don't show up in most email > > programs, so you're better off replacing them with an appropriate number > > of spaces. After all, indentation matters. > > > > > > > print ''' > > > <form method="get" action="%s"> > > > print( "<tr><td><center> <button type='submit'> %s </button> </td></tr>" ) % filename > > > </form> > > > ''' > > > > > > sys.exit(0) > > > > > -- > > DaveA How is this lien supposed to be written do to iterate over a list of filenames? for filename in list( os.walk(path) ): i tried the above but still it doesn't work out.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 05:01 -0800 |
| Message-ID | <ebde8f97-46c4-49c6-a0e1-7056455352d7@googlegroups.com> |
| In reply to | #40509 |
Please help me correct thois code, iam tryign ti for hours and i cant seem to get it working....it irritates me....
path = "/home/nikos/public_html/data/files/"
for filename in os.walk(path):
try:
#find the needed counter for the page URL
cur.execute('''SELECT ID FROM files WHERE URL = %s''', (filename,) )
data = cur.fetchone() #URL is unique, so should only be one
if not data:
#first time for page; primary key is automatic, hit is defaulted
cur.execute('''INSERT INTO files (URL, lastvisit) VALUES (%s, %s)''', (filename, date) )
cID = cur.lastrowid #get the primary key value of the new record
else:
#found the page, save primary key and use it to issue hit UPDATE
cID = data[0]
cur.execute('''UPDATE files SET hits = hits + 1, lastvisit = %s WHERE ID = %s''', (date, cID)
except MySQLdb.Error, e:
print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-03-05 08:38 -0500 |
| Message-ID | <mailman.2883.1362490711.2939.python-list@python.org> |
| In reply to | #40525 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Mar 5, 2013 at 8:01 AM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> Please help me correct thois code, iam tryign ti for hours and i cant seem
> to get it working....it irritates me....
>
There is no question here. No indication of what isn't working as you
like. No traceback.
>
> path = "/home/nikos/public_html/data/files/"
> for filename in os.walk(path):
> try:
> #find the needed counter for the page URL
> cur.execute('''SELECT ID FROM files WHERE URL = %s''',
> (filename,) )
> data = cur.fetchone() #URL is unique, so should
> only be one
>
> if not data:
> #first time for page; primary key is automatic,
> hit is defaulted
> cur.execute('''INSERT INTO files (URL, lastvisit)
> VALUES (%s, %s)''', (filename, date) )
> cID = cur.lastrowid #get the primary key
> value of the new record
> else:
> #found the page, save primary key and use it to
> issue hit UPDATE
> cID = data[0]
> cur.execute('''UPDATE files SET hits = hits + 1,
> lastvisit = %s WHERE ID = %s''', (date, cID)
> except MySQLdb.Error, e:
> print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Joel Goldstick
http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | "Vytas D." <vytasd2013@gmail.com> |
|---|---|
| Date | 2013-03-05 13:38 +0000 |
| Message-ID | <mailman.2884.1362490737.2939.python-list@python.org> |
| In reply to | #40525 |
[Multipart message — attachments visible in raw view] — view raw
Hi,
It is really complicated to reproduce the errors you get by running your
code since it involves database queries.
Though one thing that really needs your attention is how you handle the
results from os.walk(path).
Dave Angel told you already that: "But os.walk() doesn't return a filename.
It returns a tuple.".
To show where you are wrong I have create the directory structure:
Folder "folder1" that has files "file4.txt" and "file3.txt" inside.
In Python 2.6.5:
>>> import os
>>> for filename in os.walk('folder1'):
... print(filename)
...
('folder1', [], ['file4.txt', 'file3.txt'])
>>>
So your code is treating results from os.walk() incorrectly. You get tuple,
so extract data you need from it first. In case you don't know how:
Print files only (no directories. Adapt code to your needs):
>>> for result in os.walk('folder1'):
... for filename in result[2]:
... print(filename)
...
file4.txt
file3.txt
In http://docs.python.org/2/library/os.html you will find:
os.walk(top, topdown=True, onerror=None, followlinks=False)
Generate the file names in a directory tree by walking the tree either
top-down or bottom-up. For each directory in the tree rooted at directory
top (including top itself), it yields a 3-tuple (dirpath, dirnames,
filenames).
...
Vytas
On Tue, Mar 5, 2013 at 1:01 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> Please help me correct thois code, iam tryign ti for hours and i cant seem
> to get it working....it irritates me....
>
> path = "/home/nikos/public_html/data/files/"
> for filename in os.walk(path):
> try:
> #find the needed counter for the page URL
> cur.execute('''SELECT ID FROM files WHERE URL = %s''',
> (filename,) )
> data = cur.fetchone() #URL is unique, so should
> only be one
>
> if not data:
> #first time for page; primary key is automatic,
> hit is defaulted
> cur.execute('''INSERT INTO files (URL, lastvisit)
> VALUES (%s, %s)''', (filename, date) )
> cID = cur.lastrowid #get the primary key
> value of the new record
> else:
> #found the page, save primary key and use it to
> issue hit UPDATE
> cID = data[0]
> cur.execute('''UPDATE files SET hits = hits + 1,
> lastvisit = %s WHERE ID = %s''', (date, cID)
> except MySQLdb.Error, e:
> print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> --
> http://mail.python.org/mailman/listinfo/python-list
>
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 06:37 -0800 |
| Message-ID | <e0b628f4-e11f-44b4-b3ed-ac2cd8abcd0b@googlegroups.com> |
| In reply to | #40527 |
Τη Τρίτη, 5 Μαρτίου 2013 3:38:49 μ.μ. UTC+2, ο χρήστης Vytas D. έγραψε:
> Hi,
>
> It is really complicated to reproduce the errors you get by running your code since it involves database queries.
>
> Though one thing that really needs your attention is how you handle the results from os.walk(path).
>
>
> Dave Angel told you already that: "But os.walk() doesn't return a filename. It returns a tuple.".
>
>
>
> To show where you are wrong I have create the directory structure:
>
> Folder "folder1" that has files "file4.txt" and "file3.txt" inside.
>
>
>
>
> In Python 2.6.5:
> >>> import os
> >>> for filename in os.walk('folder1'):
> ... print(filename)
> ...
> ('folder1', [], ['file4.txt', 'file3.txt'])
>
> >>>
>
>
> So your code is treating results from os.walk() incorrectly. You get tuple, so extract data you need from it first. In case you don't know how:
>
>
> Print files only (no directories. Adapt code to your needs):
>
> >>> for result in os.walk('folder1'):
> ... for filename in result[2]:
> ... print(filename)
> ...
> file4.txt
> file3.txt
>
>
>
> In http://docs.python.org/2/library/os.html you will find:
>
> os.walk(top, topdown=True, onerror=None, followlinks=False)
> Generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory top (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames).
>
> ...
>
>
>
> Vytas
>
>
>
>
> On Tue, Mar 5, 2013 at 1:01 PM, Νίκος Γκρ33κ <nikos...@gmail.com> wrote:
>
> Please help me correct thois code, iam tryign ti for hours and i cant seem to get it working....it irritates me....
>
>
>
>
> path = "/home/nikos/public_html/data/files/"
>
> for filename in os.walk(path):
>
> try:
>
> #find the needed counter for the page URL
>
> cur.execute('''SELECT ID FROM files WHERE URL = %s''', (filename,) )
>
> data = cur.fetchone() #URL is unique, so should only be one
>
>
>
> if not data:
>
> #first time for page; primary key is automatic, hit is defaulted
>
> cur.execute('''INSERT INTO files (URL, lastvisit) VALUES (%s, %s)''', (filename, date) )
>
> cID = cur.lastrowid #get the primary key value of the new record
>
> else:
>
> #found the page, save primary key and use it to issue hit UPDATE
>
> cID = data[0]
>
> cur.execute('''UPDATE files SET hits = hits + 1, lastvisit = %s WHERE ID = %s''', (date, cID)
>
> except MySQLdb.Error, e:
>
> print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
>
> --
>
> http://mail.python.org/mailman/listinfo/python-list
Yes indeed! the problem was at the way os.walk resulted the data.
one would think that os.walk would return the actual filenames ina tuple but it also returned coupel things more before the file themselevrs.
thank you a lot for poitning this out to me.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-05 06:37 -0800 |
| Message-ID | <mailman.2886.1362494274.2939.python-list@python.org> |
| In reply to | #40527 |
Τη Τρίτη, 5 Μαρτίου 2013 3:38:49 μ.μ. UTC+2, ο χρήστης Vytas D. έγραψε:
> Hi,
>
> It is really complicated to reproduce the errors you get by running your code since it involves database queries.
>
> Though one thing that really needs your attention is how you handle the results from os.walk(path).
>
>
> Dave Angel told you already that: "But os.walk() doesn't return a filename. It returns a tuple.".
>
>
>
> To show where you are wrong I have create the directory structure:
>
> Folder "folder1" that has files "file4.txt" and "file3.txt" inside.
>
>
>
>
> In Python 2.6.5:
> >>> import os
> >>> for filename in os.walk('folder1'):
> ... print(filename)
> ...
> ('folder1', [], ['file4.txt', 'file3.txt'])
>
> >>>
>
>
> So your code is treating results from os.walk() incorrectly. You get tuple, so extract data you need from it first. In case you don't know how:
>
>
> Print files only (no directories. Adapt code to your needs):
>
> >>> for result in os.walk('folder1'):
> ... for filename in result[2]:
> ... print(filename)
> ...
> file4.txt
> file3.txt
>
>
>
> In http://docs.python.org/2/library/os.html you will find:
>
> os.walk(top, topdown=True, onerror=None, followlinks=False)
> Generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory top (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames).
>
> ...
>
>
>
> Vytas
>
>
>
>
> On Tue, Mar 5, 2013 at 1:01 PM, Νίκος Γκρ33κ <nikos...@gmail.com> wrote:
>
> Please help me correct thois code, iam tryign ti for hours and i cant seem to get it working....it irritates me....
>
>
>
>
> path = "/home/nikos/public_html/data/files/"
>
> for filename in os.walk(path):
>
> try:
>
> #find the needed counter for the page URL
>
> cur.execute('''SELECT ID FROM files WHERE URL = %s''', (filename,) )
>
> data = cur.fetchone() #URL is unique, so should only be one
>
>
>
> if not data:
>
> #first time for page; primary key is automatic, hit is defaulted
>
> cur.execute('''INSERT INTO files (URL, lastvisit) VALUES (%s, %s)''', (filename, date) )
>
> cID = cur.lastrowid #get the primary key value of the new record
>
> else:
>
> #found the page, save primary key and use it to issue hit UPDATE
>
> cID = data[0]
>
> cur.execute('''UPDATE files SET hits = hits + 1, lastvisit = %s WHERE ID = %s''', (date, cID)
>
> except MySQLdb.Error, e:
>
> print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
>
> --
>
> http://mail.python.org/mailman/listinfo/python-list
Yes indeed! the problem was at the way os.walk resulted the data.
one would think that os.walk would return the actual filenames ina tuple but it also returned coupel things more before the file themselevrs.
thank you a lot for poitning this out to me.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-03-05 14:04 +0000 |
| Message-ID | <mailman.2885.1362492205.2939.python-list@python.org> |
| In reply to | #40509 |
On 05/03/2013 09:00, Νίκος Γκρ33κ wrote:
> # =================================================================================================================
> # display download button for each file and downlaod it on click
> # =================================================================================================================
> if form.getvalue('show') == 'files':
>
> print ( "<center><a href='http://superhost.gr/files.html'> <img src='/data/images/download.png'></a><br>" )
> print ( "<table border=5 cellpadding=5 bgcolor=blue>" )
>
> path = "/data/files/"
>
> for filename in os.walk(path):
> print '''
> <form method="get" action="%s">
> print( "<tr><td><center> <button type='submit'> %s </button> </td></tr>" ) % filename
> </form>
> '''
>
> sys.exit(0)
>
> ========================
>
> I use the above code to tidplay a filenames table so the user cna download a displayed button style lookign file but its not printing anything for me just an emptry table
>
> '/data/files' has 5 files in it but its not showing any.
> I dont see what iam doign wrong
>
You're doing at least two things wrong.
1) Not reading documentation
2) Not trying the interactive prompt.
3) Not using the print statement/function.
4) Not taking any notice of what people tell you.
5) Not showing what you expect to happen and what actually happens.
6) You're not doing six wrong.
--
Cheers.
Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web