| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9885392 commit 33c0624
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,14 +6,17 @@ | |||
| 6 | 6 | import urllib2 | |
| 7 | 7 | import os | |
| 8 | 8 | import xml.dom.minidom | |
| 9 | + import re | ||
| 9 | 10 | ||
| 10 | 11 | class CloudAPI: | |
| 11 | 12 | ||
| 12 | 13 | @describe("server", "Management Server host name or address") | |
| 13 | 14 | @describe("responseformat", "Response format: xml or json") | |
| 15 | + @describe("stripxml", "True if xml tags have to be stripped in the output, false otherwise") | ||
| 14 | 16 | def __init__(self, | |
| 15 | 17 | server="127.0.0.1:8096", | |
| 16 | 18 | responseformat="xml", | |
| 19 | + stripxml="false" | ||
| 17 | 20 | ): | |
| 18 | 21 | self.__dict__.update(locals()) | |
| 19 | 22 | ||
@@ -35,9 +38,19 @@ def _make_request(self,command,parameters=None): | |||
| 35 | 38 | url += querystring | |
| 36 | 39 | ||
| 37 | 40 | f = urllib2.urlopen(url) | |
| 38 | - | ||
| 39 | 41 | data = f.read() | |
| 40 | - | ||
| 42 | + if self.stripxml == "true": | ||
| 43 | + data=re.sub("<\?.*\?>", "\n", data); | ||
| 44 | + data=re.sub("</[a-z]*>", "\n", data); | ||
| 45 | + data=data.replace(">", "="); | ||
| 46 | + data=data.replace("=<", "\n"); | ||
| 47 | + data=data.replace("\n<", "\n"); | ||
| 48 | + data=re.sub("\n.*cloud-stack-version=.*", "", data); | ||
| 49 | + data=data.replace("\n\n\n", "\n"); | ||
| 50 | + else: | ||
| 51 | + data="\n"+data+"\n" | ||
| 52 | + return data | ||
| 53 | + | ||
| 41 | 54 | return data | |
| 42 | 55 | ||
| 43 | 56 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments