X Tutup
Skip to content

Commit 6b7f9c5

Browse files
committed
Created RC1 for 1.1.0, which has fix so that coily can pull plugins from SpringSource S3 site.
git-svn-id: https://src.springframework.org/svn/se-springpython-py/tags/springpython-1.1.0.RC1@775 ce8fead1-4192-4296-8608-a705134b927f
1 parent 96bbe6a commit 6b7f9c5

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

springpython.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ project.key=EXTPY
1313

1414
# This property is uncommented for milestone releases.
1515
release.type=milestone
16-
build.stamp=M2
16+
build.stamp=RC1
1717

1818
# docbook reference documentation
1919
doc.ref.dir=docs/reference

src/plugins/coily-template

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,90 @@ def list_installed_plugins():
6262
print "\t%s is not a valid plugin" % plugin
6363

6464
def list_available_plugins():
65-
print "S3 is no longer browsable. Available plugins are only available in your current working directory."
66-
65+
modules = get_modules_from_s3()
66+
print "S3 from SpringSource has..."
67+
for key in modules:
68+
for rev in modules[key]:
69+
if __version__ in rev[1]:
70+
print "\t%s\t%s" % (key, rev[1])
71+
6772
def install_plugin(name):
6873
"""Go through a series of options to look for Spring Python modules to download."""
6974
if not os.path.exists(plugin_path(name)):
7075
print "Installing plugin %s to %s" % (name, p["plugindir"])
76+
if fetch_from_s3(name):
77+
print "Found %s online. Installing." % name
78+
return
7179
if fetch_locally(name):
7280
print "Found %s locally. Installing." % name
7381
return
7482
print "Couldn't find %s anywhere!" % name
7583
else:
7684
print "%s is already installed. We do NOT support automated upgrades." % name
7785

86+
def get_modules_from_s3():
87+
"""Read the S3 site for information about existing modules."""
88+
info = ""
89+
for bucket in ["milestone", "release"]:
90+
url = "http://s3browse.springsource.com/browse/dist.springframework.org/%s/EXTPY" % bucket
91+
info += urllib.urlopen(url).read()
92+
#print info
93+
#return []
94+
#choicesR = re.compile('<a href="/getObject/(.*?)">(.*?)</a>.*?<td align="right">(.*?)</td>.*?<td align="right">(.*?)</td>', re.DOTALL)
95+
choicesR = re.compile(r'<td class="name-column"><a href="(.*?)">(.*?)</a>', re.DOTALL)
96+
match = choicesR.findall(info)
97+
converted = []
98+
for item in match:
99+
#print "Checking out %s" % str(item)
100+
if "springpython-plugin" not in item[0]: continue
101+
if item[0].endswith(".sha1"): continue
102+
#print "Parsing %s" % item[0]
103+
converted.append(item)
104+
#t = time.strptime(item[3], "%Y-%m-%d %H:%M")
105+
#d = datetime(year=t.tm_year, month=t.tm_mon, day=t.tm_mday, hour=t.tm_hour, minute=t.tm_min)
106+
#converted.append(("http://s3.amazonaws.com/" + item[0], item[1], item[2]+"K", item[3], d))
107+
modules = {}
108+
baseR = re.compile("springpython-plugin-([a-zA-Z-]*)[-.]([0-9a-zA-Z]+.*).tar.gz")
109+
for item in converted:
110+
try:
111+
modules[baseR.match(item[1]).group(1)].append(item)
112+
except KeyError:
113+
modules[baseR.match(item[1]).group(1)] = [item]
114+
return modules
115+
116+
def fetch_from_s3(name):
117+
"""Download a selected item"""
118+
print "Can we find %s online? " % name
119+
selected = None
120+
try:
121+
s3 = get_modules_from_s3()
122+
print "Looking at %s" % s3
123+
print "Ah ha! I can see %s" % str(s3[name])
124+
for item in s3[name]:
125+
print "Is %s the version we want?" % str(item[1])
126+
if __version__ in item[1]:
127+
selected = item
128+
except KeyError, e:
129+
print "KeyError! %s" % e
130+
pass
131+
132+
if selected is None:
133+
print "Couldn't find %s online!" % name
134+
return None
135+
else:
136+
print "Fetching %s as %s" % (selected[0], selected[1])
137+
urllib.urlretrieve(selected[0], selected[1])
138+
t = tarfile.open(selected[1], "r:gz")
139+
top = t.getmembers()[0]
140+
if os.path.exists(name):
141+
shutil.rmtree(name)
142+
for member in t.getmembers():
143+
t.extract(member)
144+
fetch_locally(name)
145+
shutil.rmtree(name)
146+
os.remove(selected[1])
147+
return True
148+
78149
def fetch_locally(name):
79150
"""Scan the local directory for Spring Python modules to install."""
80151
try:

0 commit comments

Comments
 (0)
X Tutup