[Buildbot-devel] FileUpload to distinct directory on master

Jimmy John jimmyj_in at yahoo.com
Wed Aug 27 16:40:43 UTC 2008


Nope...

if destfile is an existing file name, dirname will the path leading to that file...

the check os.path.isdir(dirname) would return True and it would not create the dirs....


if one path on the way to the filename does not exists...it will create them recursively...

see example below...

jjohn-macbookpro:~ jjohn$ mkdir testdir
jjohn-macbookpro:~ jjohn$ touch testdir/dummy.txt
jjohn-macbookpro:~ jjohn$ python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> dirname = os.path.dirname('testdir/dummy.txt')
>>> dirname
'testdir'
>>> if not os.path.isdir(dirname):
...    os.makedirs(dirname)
... 
>>> 
>>> dirname = os.path.dirname('testdir/dir_does_not_exist/dummy.txt')
>>> dirname
'testdir/dir_does_not_exist'
>>> if not os.path.isdir(dirname):
...    os.makedirs(dirname)
... 
>>> 
>>> 
>>> 
[2]+  Stopped                 python
jjohn-macbookpro:~ jjohn$ ls testdir/
dir_does_not_exist    dummy.txt
jjohn-macbookpro:~ jjohn$ ls testdir/dir_does_not_exist/
jjohn-macbookpro:~ jjohn$


I have tested his on a Mac / Linux... if I get hold of a windows box i'll test it there as well....






----- Original Message ----
From: Ted Zlatanov <tzz at lifelogs.com>
To: buildbot-devel at lists.sourceforge.net
Sent: Wednesday, August 27, 2008 8:02:12 AM
Subject: Re: [Buildbot-devel] FileUpload to distinct directory on master

On Tue, 26 Aug 2008 16:49:32 -0700 (PDT) Jimmy John <jimmyj_in at yahoo.com> wrote: 

JJ>         #if the directory leading to the file does not exist, create them recursively
JJ>         dirname = os.path.dirname(destfile)
JJ>         if not os.path.isdir(dirname):
JJ>            os.makedirs(dirname)

Would this break if `dirname' was an existing file name?

Ted


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Buildbot-devel mailing list
Buildbot-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/buildbot-devel



      




More information about the devel mailing list