1
#!/usr/bin/python
2
### This file is part of KoFooBot. This file is not licensed and belongs to Public Domain. ###
3
4
import os
5
6
files = [('http://feedparser.googlecode.com/svn/trunk/feedparser', 'feedparser', '.py')]
7
8
for dfile in files:
9
    base_url, name, ending = dfile
10
    url = "%s/%s%s" % dfile
11
    filename = "%s%s" % (name, ending)
12
    if os.path.exists(filename):
13
        print "%s already exists." % filename
14
    else:
15
        print "Downloading '%s'." % filename
16
        ret = os.system('wget -q %s' % url)
17
        if ret:
18
            print " - Failed to download."
19
        else:
20
            print " + Successfull."
21
22
modules = [('http://downloads.sourceforge.net/sourceforge/python-irclib', 'python-irclib', '0.4.8', 'tar.gz', ['irclib.py']),
23
           ('http://pypi.python.org/packages/source/s/simplejson', 'simplejson', '2.0.9', 'tar.gz', []),
24
           ('http://python-twitter.googlecode.com/files', 'python-twitter', '0.6', 'tar.gz', ['twitter.py']),
25
           ('http://downloads.sourceforge.net/sourceforge/mwclient', 'mwclient', '0.6.2', 'tar.gz', [])]
26
27
for module in modules:
28
    base_url, name, version, format, req_files = module
29
    filename = "%s-%s.%s" % (name, version, format)
30
    if os.path.exists(filename):
31
        print "%s already exists." % filename
32
        ret = 0
33
    else:
34
        url = "%s/%s" % (base_url, filename)
35
        print "Downloading '%s' version %s." % (name, version)
36
        ret = os.system('wget -q %s' % url)
37
    if ret:
38
        print " - Download failed."
39
    else:
40
        ret = os.system('tar xf %s' % filename)
41
        if ret:
42
            print " - Could not extract files."
43
        else:
44
            if req_files:
45
                print " + Copy required files: %s" % ', '.join(req_files)
46
                for filename in req_files:
47
                    ret = os.system('mv ./%s/%s ./' % ("%s-%s" % (name, version), filename))
48
                    if ret:
49
                        print "  - Could not copy required file."
50
                    else:
51
                        ret = os.system('rm -R %s' % ("%s-%s" % (name, version)))
52
                        if ret:
53
                            print "  - Could not remove temp. folder."
54
                        else:
55
                            print "  + Temporary folder removed."