and this to download ad extract to unique location:

    from time import strftime,
localtime
    import string
    from urllib2 import Request, urlopen, URLError, HTTPError
    from zipfile import ZipFile,ZipExtFile, ZIP_STORED, ZipInfo

    dateTimeStamp = '{0}'.format(strftime('%y%m%d%H%M%S',
                                 localtime()))

    latestVersion = <returned version number from previous bit above>

    downloads = <some_path>

    uniqueName = '{0}_{1}'.format(dateTimeStamp,
                                  latestVersion)

    uniqueFolderPath = '{0}/{1}'.format(downloads,
                                        uniqueName) # version returned
from above function

    w2pZip = '{0}/{1}_web2py_src.zip'.format(downloads,
                                             uniqueName,
                                             fileName)
    def extractw2p():
        z = zipfile.ZipFile(w2pZip,'r',
                            ZIP_STORED,
                            True)
        z.extractall('{0}/{1}'.format())

    def downloadw2p():
        try:
            oFile = urlopen(url)
            iFile = open(w2pZip, 'wb')
            iFile.write(oFile.read())
            iFile.close()
        except HTTPError as httpErr:
            print('HTTPError: {0}\t{1}'.format(httpErr.code,
                                               url))
        except URLError as urlErr:
            print('URLError: {0}\t{1}'.format(urlErr.reason,
                                              url))

On Dec 27, 5:07 pm, mart <[email protected]> wrote:
> this works for me on ac os x:
>
> import string
> from urllib2 import Request, urlopen, URLError, HTTPError
> url = 'http://www.web2py.com/examples/static/web2py_src.zip'
> req = Request(url)
> try:
>     oFile = urlopen(req)
>     latestVersion =
> string.strip(string.split(string.split(string.split(oFile.read(),
>
> 'web2py/VERSION')[1],
>                                                              ' (')[0],
>                                                 'Version ')[1])
> except HTTPError as httpErr:
>     print('HTTPError: {0}\t{1}'.format(httpErr.code,
>                                        url))
> except URLError as urlErr:
>     print('URLError: {0}\t{1}'.format(urlErr.reason,
>                                       url))
>
> mart
>
> On Dec 27, 3:32 pm, Jonathan Lundell <[email protected]> wrote:
>
>
>
>
>
>
>
> > On Dec 27, 2010, at 12:13 PM, reyelts wrote:
>
> > > I do "wget --no-clobber --directory-prefix=blah
> > >http://www.web2py.com/examples/static/web2py_src.zip"; followed by
> > > "unzip -o -q..." to unravel the file. For both web2py_src.zip and
> > > web2py_win.zip, I got "version". In both cases, other file names with
> > > uppercase characters were extracted normally (like "Makefile" in the
> > > src package and "NEWINSTALL" in the win package). So, files were not
> > > indiscriminately renamed to lower case. I have not tried to repeat
> > > sine the original occurrence... will try that later when I have a
> > > faster connection for the download.
>
> > Unfortunately, I can't try this on Windows, so I'm doing it on OS X. Using 
> > your wget options, I see this:
>
> > blah $ unzip -l web2py_src.zip | grep -i version
> >        37  12-22-10 09:31   web2py/VERSION
>
> > blah $ unzip -l web2py_win.zip | grep -i version
> >        37  12-22-10 09:33   web2py/VERSION
>
> > If I create web2py/version first, it gets overwritten with web2py/VERSION 
> > when I do the unzip (since OS X's default file system, like Windows', is 
> > not case-senstive).
>
> > Is it possible that you had a 'version' there to begin with? If so, perhaps 
> > it's a Windows unzip peculiarity.
>
> > > On Dec 27, 9:52 am, Jonathan Lundell <[email protected]> wrote:
> > >> On Dec 27, 2010, at 7:39 AM, reyelts wrote:
>
> > >>> So is this a packaging error when building the source package for
> > >>> download from web2py.com?
>
> > >> I got VERSION just now when I downloaded it. 
> > >> <http://www.web2py.com/examples/static/web2py_src.zip>
>
> > >> Is 'version' repeatable for you? What OS and file system, and how are 
> > >> you unpacking it?
>
> > >>> On Dec 25, 5:22 pm, Jonathan Lundell <[email protected]> wrote:
> > >>>> On Dec 25, 2010, at 1:40 PM, reyelts wrote:
>
> > >>>>> Either the code should be looking for the name 'version' (since that's
> > >>>>> what is shipped) or the file should be renamed 'VERSION' (since that's
> > >>>>> what's hardcoded in the source). Shipping 'version' and coding
> > >>>>> 'VERSION' is just asking for the problem we currently see.
>
> > >>>> FWIW, it's 'VERSION' in the Mercurial source repository.

Reply via email to