Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0627628

Browse files
committed
Add automatically generated download list
1 parent 5720ba2 commit 0627628

File tree

4 files changed

+259
-0
lines changed

4 files changed

+259
-0
lines changed

downloads.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4+
5+
6+
<html xmlns="http://www.w3.org/1999/xhtml">
7+
<head>
8+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9+
10+
<title>matplotlib: downloads</title>
11+
12+
<link rel="stylesheet" href="_static/mpl.css" type="text/css" />
13+
</head>
14+
<body>
15+
<link rel="shortcut icon" href="_static/favicon.ico">
16+
17+
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
18+
<a href="index.html"><img src="_static/logo2.png" border="0" alt="matplotlib"/></a>
19+
</div>
20+
21+
<div class="related">
22+
<h3>Navigation</h3>
23+
<ul>
24+
<li><a href="index.html">home</a></li>
25+
</ul>
26+
</div>
27+
28+
<div class="document">
29+
<div class="documentwrapper">
30+
<div class="bodywrapper">
31+
<div class="body">
32+
33+
34+
<h1>Downloads</h1>
35+
36+
37+
<h2>1.2.0 — Latest stable version</h2>
38+
39+
<ul>
40+
41+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0-py2.7-python.org-macosx10.3.dmg">matplotlib-1.2.0-py2.7-python.org-macosx10.3.dmg</a></li>
42+
43+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0-py2.7-python.org-macosx10.6.dmg">matplotlib-1.2.0-py2.7-python.org-macosx10.6.dmg</a></li>
44+
45+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.tar.gz">matplotlib-1.2.0.tar.gz</a></li>
46+
47+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win-amd64-py2.6.exe">matplotlib-1.2.0.win-amd64-py2.6.exe</a></li>
48+
49+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win-amd64-py2.7.exe">matplotlib-1.2.0.win-amd64-py2.7.exe</a></li>
50+
51+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win-amd64-py3.2.exe">matplotlib-1.2.0.win-amd64-py3.2.exe</a></li>
52+
53+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win-amd64-py3.3.exe">matplotlib-1.2.0.win-amd64-py3.3.exe</a></li>
54+
55+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win32-py2.6.exe">matplotlib-1.2.0.win32-py2.6.exe</a></li>
56+
57+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win32-py2.7.exe">matplotlib-1.2.0.win32-py2.7.exe</a></li>
58+
59+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win32-py3.2.exe">matplotlib-1.2.0.win32-py3.2.exe</a></li>
60+
61+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.2.0/matplotlib-1.2.0.win32-py3.3.exe">matplotlib-1.2.0.win32-py3.3.exe</a></li>
62+
63+
</ul>
64+
65+
<h2>1.1.1 — Previous stable version</h2>
66+
67+
<ul>
68+
69+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1-py2.7-python.org-macosx10.3.dmg">matplotlib-1.1.1-py2.7-python.org-macosx10.3.dmg</a></li>
70+
71+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg">matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg</a></li>
72+
73+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.tar.gz">matplotlib-1.1.1.tar.gz</a></li>
74+
75+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.win-amd64-py2.5.exe">matplotlib-1.1.1.win-amd64-py2.5.exe</a></li>
76+
77+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.win-amd64-py2.6.exe">matplotlib-1.1.1.win-amd64-py2.6.exe</a></li>
78+
79+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.win-amd64-py2.7.exe">matplotlib-1.1.1.win-amd64-py2.7.exe</a></li>
80+
81+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.win32-py2.5.exe">matplotlib-1.1.1.win32-py2.5.exe</a></li>
82+
83+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.win32-py2.6.exe">matplotlib-1.1.1.win32-py2.6.exe</a></li>
84+
85+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.win32-py2.7.exe">matplotlib-1.1.1.win32-py2.7.exe</a></li>
86+
87+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1_notests.tar.gz">matplotlib-1.1.1_notests.tar.gz</a></li>
88+
89+
</ul>
90+
91+
92+
<h2>Other downloads</h2>
93+
94+
<a href="https://sourceforge.net/projects/matplotlib/files/">Older
95+
and miscellaneous downloads.</a>
96+
97+
</body>
98+
</html>

downloads.tpl.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4+
5+
6+
<html xmlns="http://www.w3.org/1999/xhtml">
7+
<head>
8+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9+
10+
<title>matplotlib: downloads</title>
11+
12+
<link rel="stylesheet" href="_static/mpl.css" type="text/css" />
13+
</head>
14+
<body>
15+
<link rel="shortcut icon" href="_static/favicon.ico">
16+
17+
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
18+
<a href="index.html"><img src="_static/logo2.png" border="0" alt="matplotlib"/></a>
19+
</div>
20+
21+
<div class="related">
22+
<h3>Navigation</h3>
23+
<ul>
24+
<li><a href="index.html">home</a></li>
25+
</ul>
26+
</div>
27+
28+
<div class="document">
29+
<div class="documentwrapper">
30+
<div class="bodywrapper">
31+
<div class="body">
32+
33+
34+
<h1>Downloads</h1>
35+
36+
{% for version, description, version_files in files %}
37+
<h2>{{version}} — {{description}}</h2>
38+
39+
<ul>
40+
{% for file in version_files %}
41+
<li><a href="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-{{version}}/{{file}}">{{file}}</a></li>
42+
{% endfor %}
43+
</ul>
44+
{% endfor %}
45+
46+
<h2>Other downloads</h2>
47+
48+
<a href="https://sourceforge.net/projects/matplotlib/files/">Older
49+
and miscellaneous downloads.</a>
50+
51+
</body>
52+
</html>

downloads.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.2.0 Latest stable version
2+
1.1.1 Previous stable version

update_downloads.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env python
2+
"""
3+
Uses sftp to get a directory listing from matplotlib's sourceforge
4+
files and then generates a page of direct download links to those
5+
files.
6+
"""
7+
from __future__ import print_function
8+
9+
import paramiko
10+
11+
import base64
12+
import getpass
13+
import os
14+
import socket
15+
import sys
16+
import traceback
17+
18+
19+
# CONSTANTS
20+
hostname = 'frs.sourceforge.net'
21+
port = 22
22+
project_name = 'matplotlib'
23+
dir_template = '/home/frs/project/{0}/{0}/{0}-{{0}}'.format(project_name)
24+
25+
26+
def get_versions():
27+
with open('downloads.txt', 'r') as fd:
28+
versions = [
29+
x.strip() for x in fd.readlines()]
30+
versions = [
31+
x for x in versions if len(x) and not x.startswith('#')]
32+
versions = [
33+
x.split(' ', 1) for x in versions]
34+
return versions
35+
36+
37+
def get_username_and_password(hostname):
38+
# get username
39+
default_username = getpass.getuser()
40+
username = raw_input(
41+
'{0} username [{1}]: '.format(hostname, default_username))
42+
if len(username) == 0:
43+
username = default_username
44+
password = getpass.getpass(
45+
'Password for {0}@{1}: '.format(username, hostname))
46+
return username, password
47+
48+
49+
def get_hostkey_and_type(hostname):
50+
# get host key, if we know one
51+
hostkeytype = None
52+
hostkey = None
53+
host_keys = paramiko.util.load_host_keys(
54+
os.path.expanduser('~/.ssh/known_hosts'))
55+
56+
if hostname in host_keys:
57+
hostkeytype = host_keys[hostname].keys()[0]
58+
hostkey = host_keys[hostname][hostkeytype]
59+
60+
return hostkey, hostkeytype
61+
62+
63+
def get_files_for_version(sftp, version):
64+
sftp.chdir(dir_template.format(version))
65+
return sftp.listdir()
66+
67+
68+
def get_file_listings(hostname, username, password, hostkey, versions):
69+
files = []
70+
71+
try:
72+
t = paramiko.Transport((hostname, port))
73+
t.connect(username=username, password=password, hostkey=hostkey)
74+
sftp = paramiko.SFTPClient.from_transport(t)
75+
76+
for version, description in versions:
77+
version_files = get_files_for_version(sftp, version)
78+
version_files.sort()
79+
files.append((version, description, version_files))
80+
finally:
81+
t.close()
82+
83+
return files
84+
85+
86+
def generate_download_page(files):
87+
from jinja2 import Template
88+
with open("downloads.tpl.html", "r") as fd:
89+
t = Template(fd.read())
90+
stream = t.stream(files=files)
91+
with open("downloads.html", "wb") as fd:
92+
stream.dump(fd)
93+
94+
95+
def main():
96+
versions = get_versions()
97+
98+
username, password = get_username_and_password(hostname)
99+
hostkey, hostkeytype = get_hostkey_and_type(hostname)
100+
101+
files = get_file_listings(hostname, username, password, hostkey, versions)
102+
103+
generate_download_page(files)
104+
105+
106+
if __name__ == '__main__':
107+
main()

0 commit comments

Comments
 (0)