[Scons-users] first builder / download

Kraus Philipp philipp.kraus at flashpixx.de
Mon Aug 13 18:16:04 EDT 2012


Hi,

I try to create my first own builder for downloading a file. I read the documentation, but I don't find any good explain to do this.

This is my code

def url_downloadfile(target, source, env) :
target = open( target, "wb" )
f = urllib2.urlopen(source)
target.write(f.read())
target.close()
f.close()
return target, source


def url_emitter(target, source, env) :
if (target[0] == source[0]) :
target[0] = str(source[0]).split("/")[-1]
return target, source



dw = Builder(action = url_downloadfile, emitter = url_emitter, single_source = True )
env = Environment(BUILDERS = {"Downloader" : dw})

env.Downloader( "http://myurl/myfile.tar.gz" )



I know that I can modify the source / target list with the emitter, so I think it is correct
because the source list (here only on element) is the url, but the target list is here the url
also, so I must modify the list, so that the last part of my url should be the target (or a target
is setup manually, so I use this)

But now I get scons: *** [myfile.tar.gz] Source <url> not found, needed by target `myfile.tar.gz'.

This is imho correct, because the url is not a file, so Scons does not know anything about the url.
How can I change this? I think, my input of the command is only a string object and not a FS Entry
object

Thanks

PHil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20120814/42037084/attachment-0001.htm>


More information about the Scons-users mailing list