Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48356
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jarrodhenry@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'else:': 0.03; 'charset:iso-8859-7': 0.04; 'elif': 0.05; 'encoding': 0.05; 'correct.': 0.07; 'encoded': 0.07; 'none:': 0.07; 'rename': 0.07; 'stops': 0.07; "subject:' ": 0.07; 'utf-8': 0.07; 'clean.': 0.09; 'data:': 0.09; 'filename': 0.09; 'filenames': 0.09; 'filenames:': 0.09; 'host,': 0.09; 'moving.': 0.09; 'subject:Why': 0.09; 'subject:into': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'suggest': 0.14; 'thread': 0.14; '<form': 0.16; '<input': 0.16; "'''": 0.16; "'utf-8',": 0.16; '(filename,': 0.16; '12:57': 0.16; 'compute': 0.16; 'letting': 0.16; 'nick': 0.16; 'ought': 0.16; 'outputs': 0.16; 'spurious': 0.16; 'subject:format': 0.16; 'url:py': 0.16; 'utf8': 0.16; 'wrongly': 0.16; 'files.': 0.16; 'sat,': 0.16; 'hire': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'thanks.': 0.20; '8bit%:5': 0.22; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'skip': 0.24; 'skip:\xa0 20': 0.24; 'unicode': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; '15,': 0.26; 'switch': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'idea': 0.28; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'assert': 0.31; 'correctly.': 0.31; "skip:' 40": 0.31; 'skip:= 40': 0.31; 'steven': 0.31; 'file': 0.32; 'another': 0.32; 'url:python': 0.33; 'skip:b 30': 0.33; 'noticed': 0.34; 'subject:the': 0.34; 'display': 0.35; 'except': 0.35; 'skip:u 20': 0.35; 'something': 0.35; 'convert': 0.35; 'received:google.com': 0.35; 'skip:\xd0 10': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'button': 0.38; 'skip:& 10': 0.38; 'thank': 0.38; 'follows:': 0.38; 'skip:[ 10': 0.38; 'files': 0.38; 'pm,': 0.38; 'does': 0.39; 'delete': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'is.': 0.60; 'most': 0.60; 'first': 0.61; 'you.': 0.62; 'name': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'total': 0.65; 'here': 0.66; 'mar': 0.68; 'anything.': 0.68; 'skip:a 40': 0.72; 'url:page': 0.74; '</td>': 0.84; '</tr>': 0.84; '<tr>': 0.84; 'hammer': 0.84; 'to:addr:support': 0.84; '8bit%:67': 0.93; 'browse': 0.95; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=nwaNXzv+/NWS6MaEOI9xW/TV2kNfCj9pAfofpmCZOCM=; b=h0U451WaxSMreKQ9I4BLq8eVVVyVW09z5M7+dVEz86/1KWdtDtTW4UQ7xz6Zbetzm4 ix1Di3ZZ5jyUmKYGN1h6ymLJIyjofPXImupl+o3eFEUzQ85ub6xJKTcUL5CMzOwTwLfd KL+SPUBEjFDYyJ5giOZbPXwDY1VkGd0gP5amFk+x9Wp+vkg57MbvfYsoQquX4b/1K39C B8T+K3Vv2tb/kP4MXxqoLQJsGd5FewrpUFwGSc6GWwMccWom6bhTcCPE7pPntqS1NSDT UykgdPp/It/7i1kSDkxBZeyduIJlE3dbbwjxUnPN+n+2soXtLHBP2DApkrSSqrsed4AE c75A== |
| X-Received | by 10.152.29.169 with SMTP id l9mr3691506lah.31.1371325639108; Sat, 15 Jun 2013 12:47:19 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <kpifru$3kp$3@news.ntua.gr> |
| References | <kpifru$3kp$3@news.ntua.gr> |
| From | Jarrod Henry <jarrodhenry@gmail.com> |
| Date | Sat, 15 Jun 2013 14:46:59 -0500 |
| Subject | Re: Why 'files.py' does not print the filenames into a table format? |
| To | Nick the Gr33k <support@superhost.gr> |
| Content-Type | multipart/alternative; boundary=089e0158bfde972e0504df36a1f0 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3401.1371325647.3114.python-list@python.org> (permalink) |
| Lines | 391 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1371325647 news.xs4all.nl 15900 [2001:888:2000:d::a6]:41120 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:48356 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Nick, at this point, you need to hire someone to do your work for you.
We are not here to do your job. I would suggest finding a coder for hire
and letting them do this job correctly.
Thanks.
On Sat, Jun 15, 2013 at 2:38 PM, Nick the Gr33k <support@superhost.gr>wrote:
> Hello,
>
> Trying to browse http://superhost.gr/?page=**files.py<http://superhost.gr/?page=files.py>with tailing -F of the error_log i noticed that error log outputs no error!
>
> So that means that the script is correct.
>
> here are the directory app's files.
>
> nikos@superhost.gr [~/www/data/apps]# ls -l
> total 412788
> drwxr-xr-x 2 nikos nikos 4096 Jun 12 12:03 ./
> drwxr-xr-x 6 nikos nikos 4096 May 26 21:13 ../
> -rwxr-xr-x 1 nikos nikos 13157283 Mar 17 12:57 100\ Mythoi\ tou\
> Aiswpou.pdf*
> -rwxr-xr-x 1 nikos nikos 29524686 Mar 11 18:17 Anekdotologio.exe*
> -rw-r--r-- 1 nikos nikos 42413964 Jun 2 20:29 Battleship.exe
> -rw-r--r-- 1 nikos nikos 51819750 Jun 2 20:04 Luxor\ Evolved.exe
> -rw-r--r-- 1 nikos nikos 60571648 Jun 2 14:59 Monopoly.exe
> -rwxr-xr-x 1 nikos nikos 1788164 Mar 14 11:31 Online\ Movie\ Player.zip*
> -rw-r--r-- 1 nikos nikos 5277287 Jun 1 18:35 O\ Nomos\ tou\ Merfy\
> v1-2-3.zip
> -rwxr-xr-x 1 nikos nikos 16383001 Jun 22 2010 Orthodoxo\ Imerologio.exe*
> -rw-r--r-- 1 nikos nikos 6084806 Jun 1 18:22 Pac-Man.exe
> -rw-r--r-- 1 nikos nikos 45297713 Jun 10 12:38 Raptor\ Chess.exe
> -rw-r--r-- 1 nikos nikos 25476584 Jun 2 19:50 Scrabble.exe
> -rwxr-xr-x 1 nikos nikos 49141166 Mar 17 12:48 To\ 1o\ mou\ vivlio\ gia\
> to\ skaki.pdf*
> -rwxr-xr-x 1 nikos nikos 3298310 Mar 17 12:45 Vivlos\ gia\
> Atheofovous.pdf*
> -rw-r--r-- 1 nikos nikos 1764864 May 29 21:50 V-Radio\ v2.4.msi
> -rw-r--r-- 1 nikos nikos 3511233 Jun 4 14:11 Ευχή\ του\ Ιησού.mp3
> -rwxr-xr-x 1 nikos nikos 66896732 Mar 17 13:13 Κοσμάς\ Αιτωλός\ -\
> Προφητείες.pdf*
> -rw-r--r-- 1 nikos nikos 236032 Jun 4 14:10 Σκέψου\ έναν\ αριθμό.exe
>
>
> The code is as follows:
>
> # ==============================**==============================**
> ==============================**=======================
> # Convert wrongly encoded filenames to utf-8
> # ==============================**==============================**
> ==============================**=======================
> path = b'/home/nikos/public_html/**data/apps/'
> filenames = os.listdir( path )
>
> utf8_filenames = []
>
> for filename in filenames:
> # Compute 'path/to/filename'
> filename_bytes = path + filename
> encoding = guess_encoding( filename_bytes )
>
> if encoding == 'utf-8':
> # File name is valid UTF-8, so we can skip to the next
> file.
> utf8_filenames.append( filename_bytes )
> continue
> elif encoding is None:
> # No idea what the encoding is. Hit it with a hammer until
> it stops moving.
> filename = filename_bytes.decode( 'utf-8',
> 'xmlcharrefreplace' )
> else:
> filename = filename_bytes.decode( encoding )
>
> # Rename the file to something which ought to be UTF-8 clean.
> newname_bytes = filename.encode('utf-8')
> os.rename( filename_bytes, newname_bytes )
> utf8_filenames.append( newname_bytes )
>
> # Once we get here, the file ought to be UTF-8 clean and the
> Unicode name ought to exist:
> assert os.path.exists( newname_bytes.decode('utf-8') )
>
>
> # Switch filenames from utf8 bytestrings => unicode strings
> filenames = []
>
> for utf8_filename in utf8_filenames:
> filenames.append( utf8_filename.decode('utf-8') )
>
> # Check the presence of a database file against the dir files and delete
> record if it doesn't exist
> cur.execute('''SELECT url FROM files''')
> data = cur.fetchall()
>
> for url in data:
> if url not in filenames:
> # Delete spurious
> cur.execute('''DELETE FROM files WHERE url = %s''', url )
>
>
> # ==============================**==============================**
> ==============================**=======================
> # Display ALL files, each with its own download button
> # ==============================**==============================**
> ==============================**=======================
> print('''<body background='/data/images/star.**jpg'>
> <center><img src='/data/images/download.**gif'><br><br>
> <table border=5 cellpadding=5 bgcolor=green>
> ''')
>
> try:
> cur.execute( '''SELECT * FROM files ORDER BY lastvisit DESC''' )
> data = cur.fetchall()
>
> for row in data:
> (filename, hits, host, lastvisit) = row
> lastvisit = lastvisit.strftime('%A %e %b, %H:%M')
>
> print('''
> <form method="get" action="/cgi-bin/files.py">
> <tr>
> <td> <center> <input type="submit"
> name="filename" value="%s"> </td>
> <td> <center> <font color=yellow size=5>
> %s </td>
> <td> <center> <font color=orange size=4>
> %s </td>
> <td> <center> <font color=silver size=4>
> %s </td>
> </tr>
> </form>
> ''' % (filename, hits, host, lastvisit) )
> print( '''</table><br><br>''' )
> except pymysql.ProgrammingError as e:
> print( repr(e) )
>
> ==============================**=============
> PLEASE take a look, its not a huge code, the encoding was of Steven
> idea's, so from another thread is a bit more or less already known to the
> most of you.
>
> I just want to know why it doesn't print anything.
>
> Thank you and please whoever does not feel like helping, please at least
> not spam the thread.
>
> --
> What is now proved was at first only imagined!
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-15 22:38 +0300
Re: Why 'files.py' does not print the filenames into a table format? Jarrod Henry <jarrodhenry@gmail.com> - 2013-06-15 14:46 -0500
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-15 22:51 +0300
Re: Why 'files.py' does not print the filenames into a table format? Benjamin Schollnick <benjamin@schollnick.net> - 2013-06-15 16:29 -0400
Re: Why 'files.py' does not print the filenames into a table format? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-15 21:37 +0100
Re: Why 'files.py' does not print the filenames into a table format? Νίκος <support@superhost.gr> - 2013-06-17 08:58 +0300
Re: Why 'files.py' does not print the filenames into a table format? Νίκος <support@superhost.gr> - 2013-06-17 09:11 +0300
Re: Why 'files.py' does not print the filenames into a table format? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-17 07:00 +0000
Re: Why 'files.py' does not print the filenames into a table format? Simpleton <support@superhost.gr> - 2013-06-17 12:07 +0300
Re: Why 'files.py' does not print the filenames into a table format? Simpleton <support@superhost.gr> - 2013-06-17 12:18 +0300
Re: Why 'files.py' does not print the filenames into a table format? Simpleton <support@superhost.gr> - 2013-06-17 13:26 +0300
Re: Why 'files.py' does not print the filenames into a table format? Chris Angelico <rosuav@gmail.com> - 2013-06-16 08:51 +1000
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:07 +0300
Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-16 05:06 +0000
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Nick the Gr33k <support@superhost.gr> - 2013-06-16 11:28 +0300
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-16 10:33 +0000
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Ferrous Cranus <support@superhost.gr> - 2013-06-16 13:57 +0300
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-16 12:09 +0100
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Ferrous Cranus <support@superhost.gr> - 2013-06-16 14:12 +0300
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-06-16 13:19 +0200
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-06-16 13:03 +0200
Re: Why 'files.py' does not print the filenames into a table format? Ferrous Cranus <support@superhost.gr> - 2013-06-16 16:57 +0300
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:10 +0300
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:24 +0300
Re: Why 'files.py' does not print the filenames into a table format? Grant Edwards <invalid@invalid.invalid> - 2013-06-17 14:50 +0000
Re: Why 'files.py' does not print the filenames into a table format? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 22:29 +0100
Re: Why 'files.py' does not print the filenames into a table format? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-16 00:10 +0000
Re: Why 'files.py' does not print the filenames into a table format? alex23 <wuwei23@gmail.com> - 2013-06-16 17:04 -0700
Re: Why 'files.py' does not print the filenames into a table format? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-17 01:31 +0100
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:03 +0300
Re: Why 'files.py' does not print the filenames into a table format? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-16 02:10 +0100
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:28 +0300
Re: Why 'files.py' does not print the filenames into a table format? Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-16 07:23 +0000
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 11:35 +0300
Re: Why 'files.py' does not print the filenames into a table format? Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-16 08:55 +0000
Re: Why 'files.py' does not print the filenames into a table format? Ferrous Cranus <support@superhost.gr> - 2013-06-16 16:59 +0300
Re: Why 'files.py' does not print the filenames into a table format? jmfauth <wxjmfauth@gmail.com> - 2013-06-16 05:57 -0700
csiph-web