From 17447cbba68069b0bf043f25ae75f86a0ccc26f7 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Sat, 21 Nov 2009 02:01:30 +0000 Subject: [PATCH] deprecate www directory and its legacy scripts --- Monitor.spec | 10 +- monitor/database/info/findbad.py | 4 +- www/HyperText/Documents.py | 109 ----- www/HyperText/HTML.py | 1 - www/HyperText/HTML40.py | 695 ------------------------------- www/HyperText/SGML.py | 39 -- www/HyperText/XHTML.py | 1 - www/HyperText/XHTML10.py | 572 ------------------------- www/HyperText/XML.py | 42 -- www/HyperText/__init__.py | 0 www/HyperText/license.py | 22 - www/__init__.py | 0 www/database.php | 69 --- www/gadgets/gadget.php | 91 ---- www/gadgets/gadget.xml | 16 - www/gadgets/regions.xml | 16 - www/gadgets/sitemonitor.py | 149 ------- www/gadgets/sitemonitor.xml | 22 - www/printbadnodes.py | 573 ------------------------- www/printbadpcus.php | 332 --------------- www/runlevels.py | 151 ------- www/siteactions.cgi | 143 ------- www/siteactions.php | 198 --------- 23 files changed, 7 insertions(+), 3248 deletions(-) delete mode 100644 www/HyperText/Documents.py delete mode 100644 www/HyperText/HTML.py delete mode 100644 www/HyperText/HTML40.py delete mode 100644 www/HyperText/SGML.py delete mode 100644 www/HyperText/XHTML.py delete mode 100644 www/HyperText/XHTML10.py delete mode 100644 www/HyperText/XML.py delete mode 100644 www/HyperText/__init__.py delete mode 100644 www/HyperText/license.py delete mode 100644 www/__init__.py delete mode 100644 www/database.php delete mode 100644 www/gadgets/gadget.php delete mode 100644 www/gadgets/gadget.xml delete mode 100644 www/gadgets/regions.xml delete mode 100755 www/gadgets/sitemonitor.py delete mode 100644 www/gadgets/sitemonitor.xml delete mode 100755 www/printbadnodes.py delete mode 100644 www/printbadpcus.php delete mode 100755 www/runlevels.py delete mode 100755 www/siteactions.cgi delete mode 100644 www/siteactions.php diff --git a/Monitor.spec b/Monitor.spec index b8e2d31..9d47dec 100644 --- a/Monitor.spec +++ b/Monitor.spec @@ -140,7 +140,7 @@ install -d $RPM_BUILD_ROOT/data/var/lib/%{name} install -d $RPM_BUILD_ROOT/data/var/lib/%{name}/archive-pdb install -d $RPM_BUILD_ROOT/var/lib/%{name} install -d $RPM_BUILD_ROOT/var/lib/%{name}/archive-pdb -install -d $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/ +#install -d $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/ install -d $RPM_BUILD_ROOT/var/www/html/monitorlog/ install -D -m 644 monitor.functions $RPM_BUILD_ROOT/%{_sysconfdir}/plc.d/monitor.functions @@ -152,7 +152,7 @@ rsync -a --exclude www --exclude archive-pdb --exclude .svn --exclude CVS \ ./ $RPM_BUILD_ROOT/usr/share/%{name}/ echo " * Installing web pages" -rsync -a www/ $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/ +#rsync -a www/ $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/ rsync -a log/ $RPM_BUILD_ROOT/var/www/html/monitorlog/ echo " * Installing cron job for automated polling" @@ -170,8 +170,8 @@ rsync -a monitor/ $RPM_BUILD_ROOT/%{python_sitearch}/monitor/ rsync -a pcucontrol/ $RPM_BUILD_ROOT/%{python_sitearch}/pcucontrol/ install -D -m 755 threadpool.py $RPM_BUILD_ROOT/%{python_sitearch}/threadpool.py -touch $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/monitorconfig.php -chmod 777 $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/monitorconfig.php +#touch $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/monitorconfig.php +#chmod 777 $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/monitorconfig.php #install -D -m 755 monitor-default.conf $RPM_BUILD_ROOT/etc/monitor.conf #cp $RPM_BUILD_ROOT/usr/share/%{name}/monitorconfig-default.py $RPM_BUILD_ROOT/usr/share/%{name}/monitorconfig.py @@ -196,7 +196,7 @@ rm -rf $RPM_BUILD_ROOT #%config /etc/monitor.conf /usr/share/%{name} /var/lib/%{name} -/var/www/cgi-bin/monitor +#/var/www/cgi-bin/monitor %{_sysconfdir}/cron.d/monitor-server.cron %{python_sitearch}/threadpool.py %{python_sitearch}/threadpool.pyc diff --git a/monitor/database/info/findbad.py b/monitor/database/info/findbad.py index 6d10dc8..ec85a7b 100644 --- a/monitor/database/info/findbad.py +++ b/monitor/database/info/findbad.py @@ -38,8 +38,8 @@ class FindbadNodeRecord(Entity): # INTERNAL kernel_version = Field(String,default=None) bootcd_version = Field(String,default=None) - boot_server = Field(String,default=None) - install_date = Field(String,default=None) + boot_server = Field(String,default=None) + install_date = Field(String,default=None) nm_status = Field(String,default=None) fs_status = Field(String,default=None) iptables_status = Field(String,default=None) diff --git a/www/HyperText/Documents.py b/www/HyperText/Documents.py deleted file mode 100644 index 60c4f69..0000000 --- a/www/HyperText/Documents.py +++ /dev/null @@ -1,109 +0,0 @@ -__version__ = "$Revision: 1.4 $"[11:-4] - -import HTML -import sys -from string import join - -class Document: - - generator = HTML.META(name="generator", - content="HyperText package (Python)") - DOCTYPE = HTML.DOCTYPE - body_element = HTML.BODY - - def __init__(self, *content, **attrs): - from HTML import HEAD, HTML - self.doctype = self.DOCTYPE - self.body = apply(self.body_element, content, attrs) - self.head = HEAD(self.generator) - if hasattr(self, 'style'): self.head.append(self.style) - if hasattr(self, 'title'): self.head.append(self.title) - self.html = HTML(self.head, self.body) - self.setup() - - def setup(self): pass - - def append(self, *items): map(self.body.content.append, items) - - def __str__(self, indent=0, perlevel=2): - return join([self.doctype.__str__(indent, perlevel), - self.html.__str__(indent, perlevel)], '') - - def writeto(self, fp=sys.stdout, indent=0, perlevel=2): - self.doctype.writeto(fp, indent, perlevel) - self.html.writeto(fp, indent, perlevel) - - -class FramesetDocument(Document): - - DOCTYPE = HTML.DOCTYPE_frameset - body_element = HTML.FRAMESET - - -class CGIMixIn: - - def setup(self): - self.content_type = "text/html" - self.headers = [] - self.nobody = 0 - - def _str_content_type(self): - return 'Content-Type: %s\r\n\r\n' % self.content_type - - def __str__(self, indent=0, perlevel=2): - s = self.headers[:] - s.append(self._str_content_type()) - if not self.nobody: - s.append(self.doctype.__str__(indent, perlevel)) - s.append(self.html.__str__(indent, perlevel)) - return join(s, '') - - def writeto(self, fp=sys.stdout, indent=0, perlevel=2): - fp.writelines(self.headers) - fp.write(self._str_content_type()) - if not self.nobody: - self.doctype.writeto(fp, indent, perlevel) - self.html.writeto(fp, indent, perlevel) - - -class HTTPMixIn(CGIMixIn): - - def setup(self): - CGIMixIn.setup(self) - if not hasattr(self, 'response'): - self.response = (200, 'Output follows') - self.date = None - - http_response_str = "%s %s %s\r\nServer: %s %s\r\nDate: %s\r\n" - - def _str_http_response(self): - if hasattr(self, 'request'): - apply(self.request.log_request, self.response) - return self.http_response_str \ - % (self.request.request_version, - self.response[0], - self.response[1], - self.request.server_version, - self.request.sys_version, - self.date) - else: - return self.http_response_str \ - % ('HTTP/1.0', - self.response[0], - self.response[1], - "Dunno/0.0", - "BeatzMe/0.0", - self.date) - - def __str__(self, indent=0, perlevel=2): - return join([self._str_http_response(), - CGIMixIn.__str__(self, indent, perlevel)], '') - - def writeto(self, fp=sys.stdout, indent=0, perlevel=2): - fp.write(self._str_http_response()) - CGIMixIn.writeto(self, fp, indent, perlevel) - - - - - diff --git a/www/HyperText/HTML.py b/www/HyperText/HTML.py deleted file mode 100644 index 0c7b575..0000000 --- a/www/HyperText/HTML.py +++ /dev/null @@ -1 +0,0 @@ -from HTML40 import * diff --git a/www/HyperText/HTML40.py b/www/HyperText/HTML40.py deleted file mode 100644 index 13fd458..0000000 --- a/www/HyperText/HTML40.py +++ /dev/null @@ -1,695 +0,0 @@ -"""HTML40 -- generate HTML conformant to the 4.0 standard. See: - - http://www.w3.org/TR/REC-html40/ - -All HTML 4.0 elements are implemented except for a few which are -deprecated. All attributes should be implemented. HTML is generally -case-insensitive, whereas Python is not. All elements have been coded -in UPPER CASE, with attributes in lower case. General usage: - - e = ELEMENT(*content, **attr) - -i.e., the positional arguments become the content of the element, and -the keyword arguments set element attributes. All attributes MUST be -specified with keyword arguments, and the content MUST be a series of -positional arguments; if you use content="spam", it will set this as -the attribute content, not as the element content. Multiple content -arguments are simply joined with no separator. Example: - ->>> t = TABLE(TR(TH('SPAM'), TH('EGGS')), TR(TD('foo','bar', colspan=2)) ) ->>> print t - - - - - - -
SPAMEGGS
foobar
- -As with HTMLgen and other HTML generators, you can print the object -and it makes one monster string and writes that to stdout. Unlike -HTMLgen, these objects all have a writeto(fp=stdout, indent=0, -perlevel=2) method. This method may save memory, and it might be -faster possibly (many fewer string joins), plus you get progressive -output. If you want to alter the indentation on the string output, -try: - ->> print t.__str__(indent=5, perlevel=6) - - - - - - -
SPAMEGGS
foobar
- -The output from either method (__str__ or writeto) SHOULD be the -lexically equivalent, regardless of indentation; not all elements are -made pretty, only those which are insensitive to the addition of -whitespace before or after the start/end tags. If you don't like the -indenting, use writeto(perlevel=0) (or __str__(perlevel=0)). - -Element attributes can be set through the normal Python dictionary -operations on the object (they are not Python attributes). - -Note: There are a few HTML attributes with a dash in them. In these -cases, substitute an underscore and the output will be corrected. HTML -4.0 also defines a class attribute, which conflicts with Python's -class statement; use klass instead. The new LABEL element has a for -attribute which also conflicts; use label_for instead. - ->>> print META(http_equiv='refresh',content='60;/index2.html') - - -The output order of attributes is indeterminate (based on hash order), -but this is of no particular importance. The extent of attribute -checking is limited to checking that the attribute is legal for that -element; the values themselves are not checked, but must be -convertible to a string. The content items must be convertible to -strings and/or have a writeto() method. Some elements may have a few -attributes they shouldn't, particularly those which use intrinsic -events. - -Valid attributes are defined for each element with dictionaries, with -the keys being the attributes. If the value is false, it's a boolean; -otherwise the value is printed. - -Subclassing: If all you need to do is have some defaults, override the -defaults dictionary. You will also need to set name to the correct -element name. Example: - ->>> class Refresh(META): defaults = {'http_equiv': 'refresh'}; name = 'META' -... ->>> print Refresh(content='10; /index2.html') - - -Weirdness with Netscape 4.x: It recognizes a border attribute for the -FRAMESET element, though it is not defined in the HTML 4.0 spec. It -seems to recognize the frameborder attribute for FRAME, but border -only changes from a 3D shaded border to a flat, unresizable grey -border. Because of this, there is a border attribute defined for -FRAMESET. Similarly, HTML 4.0 does not define a border attribute for -INPUT (for use with type="image"), but one has been added anyway. - -Historical notes: My first experience with an HTML generator was with -the one which comes with "Internet Programming with Python" by Aaron -Watters, Guido van Rossum, and James C. Ahlstrom. I hate to dis it, -but the thing really drove me nuts after awhile. Horrible to debug -anything, but maybe my understanding of it was incomplete. I then -discovered HTMLgen by Robin Friedrich: - -http://starship.skyport.net/crew/friedrich/HTMLgen/html/main.html - -It worked much better, for me at least, good enough for a major -project. There were, however, some frustrations: Subclassing could -sometimes be difficult (in fairness, I think that was by design), and -there were some missing features I wanted. Plus the thing's huge, as -Python modules go. These are relatively minor gripes, and if you don't -like this module, definitely use HTMLgen. - -Mainly I did this because the methodology to do it just sorta dawned -on me. The result is, I think, some pretty clean code. Really, there's -hardly any actual code at all. Hey, and when was the last time saw a -subclass inherit from only one parent class with only a pass statement -and no attributes defined? There's 27 of them here. There's almost no -logic to it at all; it's pretty much all driven by dictionaries. - -Yes, there are a number of features missing which are present in -HTMLgen, namely the document classes. All the high-level abstractions -are going in another module or two. - -""" - -__version__ = "$Revision: 1.8 $"[11:-4] - -import string -from string import lower, join, replace -from sys import stdout - -coreattrs = {'id': 1, 'klass': 1, 'style': 1, 'title': 1} -i18n = {'lang': 1, 'dir': 1} -intrinsic_events = {'onload': 1, 'onunload': 1, 'onclick': 1, - 'ondblclick': 1, 'onmousedown': 1, 'onmouseup': 1, - 'onmouseover': 1, 'onmousemove': 1, 'onmouseout': 1, - 'onfocus': 1, 'onblur': 1, 'onkeypress': 1, - 'onkeydown': 1, 'onkeyup': 1, 'onsubmit': 1, - 'onreset': 1, 'onselect': 1, 'onchange': 1 } - -attrs = coreattrs.copy() -attrs.update(i18n) -attrs.update(intrinsic_events) - -alternate_text = {'alt': 1} -image_maps = {'shape': 1, 'coords': 1} -anchor_reference = {'href': 1} -target_frame_info = {'target': 1} -tabbing_navigation = {'tabindex': 1} -access_keys = {'accesskey': 1} - -tabbing_and_access = tabbing_navigation.copy() -tabbing_and_access.update(access_keys) - -visual_presentation = {'height': 1, 'width': 1, 'border': 1, 'align': 1, - 'hspace': 1, 'vspace': 1} - -cellhalign = {'align': 1, 'char': 1, 'charoff': 1} -cellvalign = {'valign': 1} - -font_modifiers = {'size': 1, 'color': 1, 'face': 1} - -links_and_anchors = {'href': 1, 'hreflang': 1, 'type': 1, 'rel': 1, 'rev': 1} -borders_and_rules = {'frame': 1, 'rules': 1, 'border': 1} - -from SGML import Markup, Comment -from XML import XMLPI - -DOCTYPE = Markup("DOCTYPE", - 'HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ' \ - '"http://www.w3.org/TR/REC-html40/loose.dtd"') -DOCTYPE_frameset = Markup("DOCTYPE", - 'HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" ' \ - '"http://www.w3.org/TR/REC-HTML/frameset.dtd"') - -class Element(XMLPI): - - defaults = {} - attr_translations = {'klass': 'class', - 'label_for': 'for', - 'http_equiv': 'http-equiv', - 'accept_charset': 'accept-charset'} - - def __init__(self, *content, **attr): - self.dict = {} - if not hasattr(self, 'name'): self.name = self.__class__.__name__ - if self.defaults: self.update(self.defaults) - self.update(attr) - if not self.content_model and content: - raise TypeError, "No content for this element" - self.content = list(content) - - def update(self, d2): - for k, v in d2.items(): self[k] = v - - def __setitem__(self, k, v): - kl = lower(k) - if self.attlist.has_key(kl): self.dict[kl] = v - else: raise KeyError, "Invalid attribute for this element" - - start_tag_string = "<%s %s>" - start_tag_no_attr_string = "<%s>" - end_tag_string = "" - - def str_attribute(self, k): - return self.attlist.get(k, 1) and '%s="%s"' % \ - (self.attr_translations.get(k, k), str(self[k])) \ - or self[k] and k or '' - - def start_tag(self): - a = self.str_attribute_list() - return a and self.start_tag_string % (self.name, a) \ - or self.start_tag_no_attr_string % self.name - - def end_tag(self): - return self.content_model and self.end_tag_string % self.name or '' - - -class PrettyTagsMixIn: - - def writeto(self, fp=stdout, indent=0, perlevel=2): - myindent = '\n' + " "*indent - fp.write(myindent+self.start_tag()) - for c in self.content: - if hasattr(c, 'writeto'): - getattr(c, 'writeto')(fp, indent+perlevel, perlevel) - else: - fp.write(str(c)) - fp.write(self.end_tag()) - - def __str__(self, indent=0, perlevel=2): - myindent = (perlevel and '\n' or '') + " "*indent - s = [myindent, self.start_tag()] - for c in self.content: - try: s.append(apply(c.__str__, (indent+perlevel, perlevel))) - except: s.append(str(c)) - s.append(self.end_tag()) - return join(s,'') - -class CommonElement(Element): attlist = attrs - -class PCElement(PrettyTagsMixIn, CommonElement): pass - -class A(CommonElement): - - attlist = {'name': 1, 'charset': 1} - attlist.update(CommonElement.attlist) - attlist.update(links_and_anchors) - attlist.update(image_maps) - attlist.update(target_frame_info) - attlist.update(tabbing_and_access) - - -class ABBR(CommonElement): pass -class ACRONYM(CommonElement): pass -class CITE(CommonElement): pass -class CODE(CommonElement): pass -class DFN(CommonElement): pass -class EM(CommonElement): pass -class KBD(CommonElement): pass -class PRE(CommonElement): pass -class SAMP(CommonElement): pass -class STRONG(CommonElement): pass -class VAR(CommonElement): pass -class ADDRESS(CommonElement): pass -class B(CommonElement): pass -class BIG(CommonElement): pass -class I(CommonElement): pass -class S(CommonElement): pass -class SMALL(CommonElement): pass -class STRIKE(CommonElement): pass -class TT(CommonElement): pass -class U(CommonElement): pass -class SUB(CommonElement): pass -class SUP(CommonElement): pass - -class DD(PCElement): pass -class DL(PCElement): pass -class DT(PCElement): pass -class NOFRAMES(PCElement): pass -class NOSCRIPTS(PCElement): pass -class P(PCElement): pass - -class AREA(PCElement): - - attlist = {'name': 1, 'nohref': 0} - attlist.update(PCElement.attlist) - attlist.update(image_maps) - attlist.update(anchor_reference) - attlist.update(tabbing_and_access) - attlist.update(alternate_text) - -class MAP(AREA): pass - -class BASE(PrettyTagsMixIn, Element): - - attlist = anchor_reference.copy() - attlist.update(target_frame_info) - content_model = None - -class BDO(Element): - - attlist = coreattrs.copy() - attlist.update(i18n) - -class BLOCKQUOTE(CommonElement): - - attlist = {'cite': 1} - attlist.update(CommonElement.attlist) - -class Q(BLOCKQUOTE): pass - -class BR(PrettyTagsMixIn, Element): - - attlist = coreattrs - content_model = None - -class BUTTON(CommonElement): - - attlist = {'name': 1, 'value': 1, 'type': 1, 'disabled': 0} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_and_access) - -class CAPTION(Element): - - attlist = {'align': 1} - attlist.update(attrs) - -class COLGROUP(PCElement): - - attlist = {'span': 1, 'width': 1} - attlist.update(PCElement.attlist) - attlist.update(cellhalign) - attlist.update(cellvalign) - -class COL(COLGROUP): content_model = None - -class DEL(Element): - - attlist = {'cite': 1, 'datetime': 1} - attlist.update(attrs) - -class INS(DEL): pass - -class FIELDSET(PCElement): pass - -class LEGEND(PCElement): - - attlist = {'align': 1} - attlist.update(PCElement.attlist) - attlist.update(access_keys) - -class BASEFONT(Element): - - attlist = {'id': 1} - attlist.update(font_modifiers) - content_model = None - -class FONT(Element): - - attlist = font_modifiers.copy() - attlist.update(coreattrs) - attlist.update(i18n) - -class FORM(PCElement): - - attlist = {'action': 1, 'method': 1, 'enctype': 1, 'accept_charset': 1, - 'target': 1} - attlist.update(PCElement.attlist) - -class FRAME(PrettyTagsMixIn, Element): - - attlist = {'longdesc': 1, 'name': 1, 'src': 1, 'frameborder': 1, - 'marginwidth': 1, 'marginheight': 1, 'noresize': 0, - 'scrolling': 1} - attlist.update(coreattrs) - content_model = None - -class FRAMESET(PrettyTagsMixIn, Element): - - attlist = {'rows': 1, 'cols': 1, 'border': 1} - attlist.update(coreattrs) - attlist.update(intrinsic_events) - -class Heading(PCElement): - - attlist = {'align': 1} - attlist.update(attrs) - - def __init__(self, level, *content, **attr): - self.level = level - apply(PCElement.__init__, (self,)+content, attr) - - def start_tag(self): - a = self.str_attribute_list() - return a and "" % (self.level, a) or "" % self.level - - def end_tag(self): - return self.content_model and "\n" % self.level or '' - -class HEAD(PrettyTagsMixIn, Element): - - attlist = {'profile': 1} - attlist.update(i18n) - -class HR(Element): - - attlist = {'align': 1, 'noshade': 0, 'size': 1, 'width': 1} - attlist.update(coreattrs) - attlist.update(intrinsic_events) - content_model = None - -class HTML(PrettyTagsMixIn, Element): - - attlist = i18n - -class TITLE(HTML): pass - -class BODY(PCElement): - - attlist = {'background': 1, 'text': 1, 'link': 1, 'vlink': 1, 'alink': 1, - 'bgcolor': 1} - attlist.update(PCElement.attlist) - -class IFRAME(PrettyTagsMixIn, Element): - - attlist = {'longdesc': 1, 'name': 1, 'src': 1, 'frameborder': 1, - 'marginwidth': 1, 'marginheight': 1, 'scrolling': 1, - 'align': 1, 'height': 1, 'width': 1} - attlist.update(coreattrs) - -class IMG(CommonElement): - - attlist = {'src': 1, 'longdesc': 1, 'usemap': 1, 'ismap': 0} - attlist.update(PCElement.attlist) - attlist.update(visual_presentation) - attlist.update(alternate_text) - content_model = None - -class INPUT(CommonElement): - - attlist = {'type': 1, 'name': 1, 'value': 1, 'checked': 0, 'disabled': 0, - 'readonly': 0, 'size': 1, 'maxlength': 1, 'src': 1, - 'usemap': 1, 'accept': 1, 'border': 1} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_and_access) - attlist.update(alternate_text) - content_model = None - -class LABEL(CommonElement): - - attlist = {'label_for': 1} - attlist.update(CommonElement.attlist) - attlist.update(access_keys) - -class UL(PCElement): - - attlist = {'compact': 0} - attlist.update(CommonElement.attlist) - -class OL(UL): - - attlist = {'start': 1} - attlist.update(UL.attlist) - -class LI(UL): - - attlist = {'value': 1, 'type': 1} - attlist.update(UL.attlist) - -class LINK(PCElement): - - attlist = {'charset': 1, 'media': 1} - attlist.update(PCElement.attlist) - attlist.update(links_and_anchors) - content_model = None - -class META(PrettyTagsMixIn, Element): - - attlist = {'http_equiv': 1, 'name': 1, 'content': 1, 'scheme': 1} - attlist.update(i18n) - content_model = None - -class OBJECT(PCElement): - - attlist = {'declare': 0, 'classid': 1, 'codebase': 1, 'data': 1, - 'type': 1, 'codetype': 1, 'archive': 1, 'standby': 1, - 'height': 1, 'width': 1, 'usemap': 1} - attlist.update(PCElement.attlist) - attlist.update(tabbing_navigation) - -class SELECT(PCElement): - - attlist = {'name': 1, 'size': 1, 'multiple': 0, 'disabled': 0} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_navigation) - -class OPTGROUP(PCElement): - - attlist = {'disabled': 0, 'label': 1} - attlist.update(CommonElement.attlist) - -class OPTION(OPTGROUP): - - attlist = {'value': 1, 'selected': 0} - attlist.update(OPTGROUP.attlist) - -class PARAM(Element): - - attlist = {'id': 1, 'name': 1, 'value': 1, 'valuetype': 1, 'type': 1} - -class SCRIPT(Element): - - attlist = {'charset': 1, 'type': 1, 'src': 1, 'defer': 0} - -class SPAN(CommonElement): - - attlist = {'align': 1} - attlist.update(CommonElement.attlist) - -class DIV(PrettyTagsMixIn, SPAN): pass - -class STYLE(PrettyTagsMixIn, Element): - - attlist = {'type': 1, 'media': 1, 'title': 1} - attlist.update(i18n) - -class TABLE(PCElement): - - attlist = {'cellspacing': 1, 'cellpadding': 1, 'summary': 1, 'align': 1, - 'bgcolor': 1, 'width': 1} - attlist.update(CommonElement.attlist) - attlist.update(borders_and_rules) - -class TBODY(PCElement): - - attlist = CommonElement.attlist.copy() - attlist.update(cellhalign) - attlist.update(cellvalign) - -class THEAD(TBODY): pass -class TFOOT(TBODY): pass -class TR(TBODY): pass - -class TH(TBODY): - - attlist = {'abbv': 1, 'axis': 1, 'headers': 1, 'scope': 1, - 'rowspan': 1, 'colspan': 1, 'nowrap': 0, 'width': 1, - 'height': 1} - attlist.update(TBODY.attlist) - -class TD(TH): pass - -class TEXTAREA(CommonElement): - - attlist = {'name': 1, 'rows': 1, 'cols': 1, 'disabled': 0, 'readonly': 0} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_and_access) - -def CENTER(*content, **attr): - c = apply(DIV, content, attr) - c['align'] = 'center' - return c - -def H1(content=[], **attr): return apply(Heading, (1, content), attr) -def H2(content=[], **attr): return apply(Heading, (2, content), attr) -def H3(content=[], **attr): return apply(Heading, (3, content), attr) -def H4(content=[], **attr): return apply(Heading, (4, content), attr) -def H5(content=[], **attr): return apply(Heading, (5, content), attr) -def H6(content=[], **attr): return apply(Heading, (6, content), attr) - -class CSSRule(PrettyTagsMixIn, Element): - - attlist = {'font': 1, 'font_family': 1, 'font_face': 1, 'font_size': 1, - 'border': 1, 'border_width': 1, 'color': 1, - 'background': 1, 'background_color': 1, 'background_image': 1, - 'text_align': 1, 'text_decoration': 1, 'text_indent': 1, - 'line_height': 1, 'margin_left': 1, 'margin_right': 1, - 'clear': 1, 'list_style_type': 1} - content = [] - content_model = None - - def __init__(self, selector, **decl): - self.dict = {} - self.update(decl) - self.name = selector - - start_tag_string = "%s { %s }" - - def end_tag(self): return '' - - def str_attribute(self, k): - kt = replace(k, '_', '-') - if self.attlist[k]: return '%s: %s' % (kt, str(self[k])) - else: return self[k] and kt or '' - - def str_attribute_list(self): - return join(map(self.str_attribute, self.dict.keys()), '; ') - -nbsp = " " - -def quote_body(s): - r=replace; return r(r(r(s, '&', '&'), '<', '<'), '>', '>') - -safe = string.letters + string.digits + '_,.-' - -def url_encode(s): - l = [] - for c in s: - if c in safe: l.append(c) - elif c == ' ': l.append('+') - else: l.append("%%%02x" % ord(c)) - return join(l, '') - -def URL(*args, **kwargs): - url_path = join(args, '/') - a = [] - for k, v in kwargs.items(): - a.append("%s=%s" % (url_encode(k), url_encode(v))) - url_vals = join(a, '&') - return url_vals and join([url_path, url_vals],'?') or url_path - -def Options(options, selected=[], **attrs): - opts = [] - for o, v in options: - opt = apply(OPTION, (o,), attrs) - opt['value'] = v - if v in selected: opt['selected'] = 1 - opts.append(opt) - return opts - -def Select(options, selected=[], **attrs): - return apply(SELECT, tuple(apply(Options, (options, selected))), attrs) - -def Href(url, text, **attrs): - h = apply(A, (text,), attrs) - h['href'] = url - return h - -def Mailto(address, text, subject='', **attrs): - if subject: - url = "mailto:%s?subject=%s" % (address, subject) - else: - url = "mailto:%s" % address - return apply(Href, (url, text), attrs) - -def Image(src, **attrs): - i = apply(IMG, (), a) - i['src'] = src - return i - -def StyledTR(element, row, klasses): - r = TR() - for i in range(len(row)): - r.append(klasses[i] and element(row[i], klass=klasses[i]) \ - or element(row[i])) - return r - -def StyledVTable(klasses, *rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(klasses))) - for row in rows: - r = StyledTR(TD, row[1:], klasses[1:]) - h = klasses[0] and TH(row[0], klass=klasses[0]) \ - or TH(row[0]) - r.content.insert(0,h) - t.append(r) - return t - -def VTable(*rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(rows[0]))) - for row in rows: - r = apply(TR, tuple(map(TD, row[1:]))) - r.content.insert(0, TH(row[0])) - t.append(r) - return t - -def StyledHTable(klasses, headers, *rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(headers))) - t.append(StyledTR(TH, headers, klasses)) - for row in rows: t.append(StyledTR(TD, row, klasses)) - return t - -def HTable(headers, *rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(headers))) - t.append(TR, tuple(map(TH, headers))) - for row in rows: t.append(TR(apply(TD, row))) - return t - -def DefinitionList(*items, **attrs): - dl = apply(DL, (), attrs) - for dt, dd in items: dl.append(DT(dt), DD(dd)) - return dl - - diff --git a/www/HyperText/SGML.py b/www/HyperText/SGML.py deleted file mode 100644 index e8935ae..0000000 --- a/www/HyperText/SGML.py +++ /dev/null @@ -1,39 +0,0 @@ -__version__ = "$Revision: 1.1 $"[11:-4] - -from sys import stdout -from string import lower, join, replace - -class Markup: - - content_model = 1 - - def __init__(self, name, *content): - self.name = name - self.dict = {} - self.content = list(content) - - start_tag_string = "\n" - - def writeto(self, fp=stdout, indent=0, perlevel=0): - fp.write(self.start_tag()) - for c in self.content: - if hasattr(c, 'writeto'): - getattr(c, 'writeto')(fp, indent+perlevel, perlevel) - else: - fp.write(str(c)) - fp.write(self.end_tag()) - - def __str__(self, indent=0, perlevel=0): - # we don't actually indent here, it's for later. - c = map(str, self.content) - return join([self.start_tag()]+c+[self.end_tag()],'') - - -def Comment(*comment): return apply(Markup, ('--',)+comment+(' --',)) - diff --git a/www/HyperText/XHTML.py b/www/HyperText/XHTML.py deleted file mode 100644 index a5bd987..0000000 --- a/www/HyperText/XHTML.py +++ /dev/null @@ -1 +0,0 @@ -from XHTML10 import * diff --git a/www/HyperText/XHTML10.py b/www/HyperText/XHTML10.py deleted file mode 100644 index 92cc9bb..0000000 --- a/www/HyperText/XHTML10.py +++ /dev/null @@ -1,572 +0,0 @@ -"""XHTML10 -- generate XHTML conformant to the 1.0 standard. See: - - http://www.w3.org/TR/xhtml1/ - -Implemented similarly to HTML40; see the docs in that module. - -""" - -__version__ = "$Revision: 1.4 $"[11:-4] - -import string -from string import lower, join, replace -from sys import stdout - -coreattrs = {'id': 1, 'klass': 1, 'style': 1, 'title': 1} -i18n = {'lang': 1, 'dir': 1} -intrinsic_events = {'onload': 1, 'onunload': 1, 'onclick': 1, - 'ondblclick': 1, 'onmousedown': 1, 'onmouseup': 1, - 'onmouseover': 1, 'onmousemove': 1, 'onmouseout': 1, - 'onfocus': 1, 'onblur': 1, 'onkeypress': 1, - 'onkeydown': 1, 'onkeyup': 1, 'onsubmit': 1, - 'onreset': 1, 'onselect': 1, 'onchange': 1 } - -attrs = coreattrs.copy() -attrs.update(i18n) -attrs.update(intrinsic_events) - -alternate_text = {'alt': 1} -image_maps = {'shape': 1, 'coords': 1} -anchor_reference = {'href': 1} -target_frame_info = {'target': 1} -tabbing_navigation = {'tabindex': 1} -access_keys = {'accesskey': 1} - -tabbing_and_access = tabbing_navigation.copy() -tabbing_and_access.update(access_keys) - -visual_presentation = {'height': 1, 'width': 1, 'border': 1, 'align': 1, - 'hspace': 1, 'vspace': 1} - -cellhalign = {'align': 1, 'char': 1, 'charoff': 1} -cellvalign = {'valign': 1} - -font_modifiers = {'size': 1, 'color': 1, 'face': 1} - -links_and_anchors = {'href': 1, 'hreflang': 1, 'type': 1, 'rel': 1, 'rev': 1} -borders_and_rules = {'frame': 1, 'rules': 1, 'border': 1} - -from SGML import Markup, Comment -from XML import XMLPI - -DOCTYPE = Markup("DOCTYPE", - 'html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' \ - '"DTD/xhtml1-transitional.dtd"') -DOCTYPE_frameset = Markup("DOCTYPE", - 'html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" ' \ - '"DTD/xhtml1-frameset.dtd"') - -class Element(XMLPI): - - defaults = {} - - def __init__(self, *content, **attr): - self.dict = {} - if not hasattr(self, 'name'): self.name = lower(self.__class__.__name__) - if self.defaults: self.update(self.defaults) - self.update(attr) - if not self.content_model and content: - raise TypeError, "No content for this element" - self.content = list(content) - - def update(self, d2): - for k, v in d2.items(): self[k] = v - - def __setitem__(self, k, v): - kl = lower(k) - if self.attlist.has_key(kl): self.dict[kl] = v - else: raise KeyError, "Invalid attribute for this element" - - start_tag_string = "<%s %s>" - start_tag_no_attr_string = "<%s>" - end_tag_string = "" - - def start_tag(self): - a = self.str_attribute_list() - return a and self.start_tag_string % (self.name, a) \ - or self.start_tag_no_attr_string % self.name - - def end_tag(self): - return self.end_tag_string % self.name - - -class PrettyTagsMixIn: - - def writeto(self, fp=stdout, indent=0, perlevel=2): - myindent = '\n' + " "*indent - fp.write(myindent+self.start_tag()) - for c in self.content: - if hasattr(c, 'writeto'): - getattr(c, 'writeto')(fp, indent+perlevel, perlevel) - else: - fp.write(str(c)) - fp.write(self.end_tag()) - - def __str__(self, indent=0, perlevel=2): - myindent = (perlevel and '\n' or '') + " "*indent - s = [myindent, self.start_tag()] - for c in self.content: - try: s.append(apply(c.__str__, (indent+perlevel, perlevel))) - except: s.append(str(c)) - s.append(self.end_tag()) - return join(s,'') - -class CommonElement(Element): attlist = attrs - -class PCElement(PrettyTagsMixIn, CommonElement): pass - -class A(CommonElement): - - attlist = {'charset': 1} - attlist.update(CommonElement.attlist) - attlist.update(links_and_anchors) - attlist.update(image_maps) - attlist.update(target_frame_info) - attlist.update(tabbing_and_access) - - -class ABBR(CommonElement): pass -class ACRONYM(CommonElement): pass -class CITE(CommonElement): pass -class CODE(CommonElement): pass -class DFN(CommonElement): pass -class EM(CommonElement): pass -class KBD(CommonElement): pass -class PRE(CommonElement): pass -class SAMP(CommonElement): pass -class STRONG(CommonElement): pass -class VAR(CommonElement): pass -class ADDRESS(CommonElement): pass -class B(CommonElement): pass -class BIG(CommonElement): pass -class I(CommonElement): pass -class S(CommonElement): pass -class SMALL(CommonElement): pass -class STRIKE(CommonElement): pass -class TT(CommonElement): pass -class U(CommonElement): pass -class SUB(CommonElement): pass -class SUP(CommonElement): pass - -class DD(PCElement): pass -class DL(PCElement): pass -class DT(PCElement): pass -class NOFRAMES(PCElement): pass -class NOSCRIPTS(PCElement): pass -class P(PCElement): pass - -class AREA(PCElement): - - attlist = {'nohref': 0} - attlist.update(PCElement.attlist) - attlist.update(image_maps) - attlist.update(anchor_reference) - attlist.update(tabbing_and_access) - attlist.update(alternate_text) - -class MAP(AREA): pass - -class BASE(PrettyTagsMixIn, Element): - - attlist = anchor_reference.copy() - attlist.update(target_frame_info) - content_model = None - -class BDO(Element): - - attlist = coreattrs.copy() - attlist.update(i18n) - -class BLOCKQUOTE(CommonElement): - - attlist = {'cite': 1} - attlist.update(CommonElement.attlist) - -class Q(BLOCKQUOTE): pass - -class BR(PrettyTagsMixIn, Element): - - attlist = coreattrs - content_model = None - -class BUTTON(CommonElement): - - attlist = {'value': 1, 'type': 1, 'disabled': 0} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_and_access) - -class CAPTION(Element): - - attlist = {'align': 1} - attlist.update(attrs) - -class COLGROUP(PCElement): - - attlist = {'span': 1, 'width': 1} - attlist.update(PCElement.attlist) - attlist.update(cellhalign) - attlist.update(cellvalign) - -class COL(COLGROUP): content_model = None - -class DEL(Element): - - attlist = {'cite': 1, 'datetime': 1} - attlist.update(attrs) - -class INS(DEL): pass - -class FIELDSET(PCElement): pass - -class LEGEND(PCElement): - - attlist = {'align': 1} - attlist.update(PCElement.attlist) - attlist.update(access_keys) - -class BASEFONT(Element): - - attlist = {'id': 1} - attlist.update(font_modifiers) - content_model = None - -class FONT(Element): - - attlist = font_modifiers.copy() - attlist.update(coreattrs) - attlist.update(i18n) - -class FORM(PCElement): - - attlist = {'action': 1, 'method': 1, 'enctype': 1, 'accept_charset': 1, - 'target': 1} - attlist.update(PCElement.attlist) - -class FRAME(PrettyTagsMixIn, Element): - - attlist = {'longdesc': 1, 'src': 1, 'frameborder': 1, - 'marginwidth': 1, 'marginheight': 1, 'noresize': 0, - 'scrolling': 1} - attlist.update(coreattrs) - content_model = None - -class FRAMESET(PrettyTagsMixIn, Element): - - attlist = {'rows': 1, 'cols': 1, 'border': 1} - attlist.update(coreattrs) - attlist.update(intrinsic_events) - -class Heading(PCElement): - - attlist = {'align': 1} - attlist.update(attrs) - - def __init__(self, level, *content, **attr): - self.level = level - apply(PCElement.__init__, (self,)+content, attr) - - def start_tag(self): - a = self.str_attribute_list() - return a and "" % (self.level, a) or "" % self.level - - def end_tag(self): - return self.content_model and "\n" % self.level or '' - -class HEAD(PrettyTagsMixIn, Element): - - attlist = {'profile': 1} - attlist.update(i18n) - -class HR(Element): - - attlist = {'align': 1, 'noshade': 0, 'size': 1, 'width': 1} - attlist.update(coreattrs) - attlist.update(intrinsic_events) - content_model = None - -class HTML(PrettyTagsMixIn, Element): - - attlist = i18n - -class TITLE(HTML): pass - -class BODY(PCElement): - - attlist = {'background': 1, 'text': 1, 'link': 1, 'vlink': 1, 'alink': 1, - 'bgcolor': 1} - attlist.update(PCElement.attlist) - -class IFRAME(PrettyTagsMixIn, Element): - - attlist = {'longdesc': 1, 'src': 1, 'frameborder': 1, - 'marginwidth': 1, 'marginheight': 1, 'scrolling': 1, - 'align': 1, 'height': 1, 'width': 1} - attlist.update(coreattrs) - -class IMG(CommonElement): - - attlist = {'src': 1, 'longdesc': 1, 'usemap': 1, 'ismap': 0} - attlist.update(PCElement.attlist) - attlist.update(visual_presentation) - attlist.update(alternate_text) - content_model = None - -class INPUT(CommonElement): - - attlist = {'type': 1, 'value': 1, 'checked': 0, 'disabled': 0, - 'readonly': 0, 'size': 1, 'maxlength': 1, 'src': 1, - 'usemap': 1, 'accept': 1, 'border': 1} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_and_access) - attlist.update(alternate_text) - content_model = None - -class LABEL(CommonElement): - - attlist = {'label_for': 1} - attlist.update(CommonElement.attlist) - attlist.update(access_keys) - -class UL(PCElement): - - attlist = {'compact': 0} - attlist.update(CommonElement.attlist) - -class OL(UL): - - attlist = {'start': 1} - attlist.update(UL.attlist) - -class LI(UL): - - attlist = {'value': 1, 'type': 1} - attlist.update(UL.attlist) - -class LINK(PCElement): - - attlist = {'charset': 1, 'media': 1} - attlist.update(PCElement.attlist) - attlist.update(links_and_anchors) - content_model = None - -class META(PrettyTagsMixIn, Element): - - attlist = {'http_equiv': 1, 'content': 1, 'scheme': 1} - attlist.update(i18n) - content_model = None - -class OBJECT(PCElement): - - attlist = {'declare': 0, 'classid': 1, 'codebase': 1, 'data': 1, - 'type': 1, 'codetype': 1, 'archive': 1, 'standby': 1, - 'height': 1, 'width': 1, 'usemap': 1} - attlist.update(PCElement.attlist) - attlist.update(tabbing_navigation) - -class SELECT(PCElement): - - attlist = {'size': 1, 'multiple': 0, 'disabled': 0} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_navigation) - -class OPTGROUP(PCElement): - - attlist = {'disabled': 0, 'label': 1} - attlist.update(CommonElement.attlist) - -class OPTION(OPTGROUP): - - attlist = {'value': 1, 'selected': 0} - attlist.update(OPTGROUP.attlist) - -class PARAM(Element): - - attlist = {'id': 1, 'value': 1, 'valuetype': 1, 'type': 1} - -class SCRIPT(Element): - - attlist = {'charset': 1, 'type': 1, 'src': 1, 'defer': 0} - -class SPAN(CommonElement): - - attlist = {'align': 1} - attlist.update(CommonElement.attlist) - -class DIV(PrettyTagsMixIn, SPAN): pass - -class STYLE(PrettyTagsMixIn, Element): - - attlist = {'type': 1, 'media': 1, 'title': 1} - attlist.update(i18n) - -class TABLE(PCElement): - - attlist = {'cellspacing': 1, 'cellpadding': 1, 'summary': 1, 'align': 1, - 'bgcolor': 1, 'width': 1} - attlist.update(CommonElement.attlist) - attlist.update(borders_and_rules) - -class TBODY(PCElement): - - attlist = CommonElement.attlist.copy() - attlist.update(cellhalign) - attlist.update(cellvalign) - -class THEAD(TBODY): pass -class TFOOT(TBODY): pass -class TR(TBODY): pass - -class TH(TBODY): - - attlist = {'abbv': 1, 'axis': 1, 'headers': 1, 'scope': 1, - 'rowspan': 1, 'colspan': 1, 'nowrap': 0, 'width': 1, - 'height': 1} - attlist.update(TBODY.attlist) - -class TD(TH): pass - -class TEXTAREA(CommonElement): - - attlist = {'rows': 1, 'cols': 1, 'disabled': 0, 'readonly': 0} - attlist.update(CommonElement.attlist) - attlist.update(tabbing_and_access) - -def CENTER(*content, **attr): - c = apply(DIV, content, attr) - c['align'] = 'center' - return c - -def H1(content=[], **attr): return apply(Heading, (1, content), attr) -def H2(content=[], **attr): return apply(Heading, (2, content), attr) -def H3(content=[], **attr): return apply(Heading, (3, content), attr) -def H4(content=[], **attr): return apply(Heading, (4, content), attr) -def H5(content=[], **attr): return apply(Heading, (5, content), attr) -def H6(content=[], **attr): return apply(Heading, (6, content), attr) - -class CSSRule(PrettyTagsMixIn, Element): - - attlist = {'font': 1, 'font_family': 1, 'font_face': 1, 'font_size': 1, - 'border': 1, 'border_width': 1, 'color': 1, - 'background': 1, 'background_color': 1, 'background_image': 1, - 'text_align': 1, 'text_decoration': 1, 'text_indent': 1, - 'line_height': 1, 'margin_left': 1, 'margin_right': 1, - 'clear': 1, 'list_style_type': 1} - content = [] - content_model = None - - def __init__(self, selector, **decl): - self.dict = {} - self.update(decl) - self.name = selector - - start_tag_string = "%s { %s }" - - def end_tag(self): return '' - - def str_attribute(self, k): - kt = replace(k, '_', '-') - if self.attlist[k]: return '%s: %s' % (kt, str(self[k])) - else: return self[k] and kt or '' - - def str_attribute_list(self): - return join(map(self.str_attribute, self.dict.keys()), '; ') - -nbsp = " " - -def quote_body(s): - r=replace; return r(r(r(s, '&', '&'), '<', '<'), '>', '>') - -safe = string.letters + string.digits + '_,.-' - -def url_encode(s): - l = [] - for c in s: - if c in safe: l.append(c) - elif c == ' ': l.append('+') - else: l.append("%%%02x" % ord(c)) - return join(l, '') - -def URL(*args, **kwargs): - url_path = join(args, '/') - a = [] - for k, v in kwargs.items(): - a.append("%s=%s" % (url_encode(k), url_encode(v))) - url_vals = join(a, '&') - return url_vals and join([url_path, url_vals],'?') or url_path - -def Options(options, selected=[], **attrs): - opts = [] - for o, v in options: - opt = apply(OPTION, (o,), attrs) - opt['value'] = v - if v in selected: opt['selected'] = 1 - opts.append(opt) - return opts - -def Select(options, selected=[], **attrs): - return apply(SELECT, tuple(apply(Options, (options, selected))), attrs) - -def Href(url, text, **attrs): - h = apply(A, (text,), attrs) - h['href'] = url - return h - -def Mailto(address, text, subject='', **attrs): - if subject: - url = "mailto:%s?subject=%s" % (address, subject) - else: - url = "mailto:%s" % address - return apply(Href, (url, text), attrs) - -def Image(src, **attrs): - i = apply(IMG, (), a) - i['src'] = src - return i - -def StyledTR(element, row, klasses): - r = TR() - for i in range(len(row)): - r.append(klasses[i] and element(row[i], klass=klasses[i]) \ - or element(row[i])) - return r - -def StyledVTable(klasses, *rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(klasses))) - for row in rows: - r = StyledTR(TD, row[1:], klasses[1:]) - h = klasses[0] and TH(row[0], klass=klasses[0]) \ - or TH(row[0]) - r.content.insert(0,h) - t.append(r) - return t - -def VTable(*rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(rows[0]))) - for row in rows: - r = apply(TR, tuple(map(TD, row[1:]))) - r.content.insert(0, TH(row[0])) - t.append(r) - return t - -def StyledHTable(klasses, headers, *rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(headers))) - t.append(StyledTR(TH, headers, klasses)) - for row in rows: t.append(StyledTR(TD, row, klasses)) - return t - -def HTable(headers, *rows, **attrs): - t = apply(TABLE, (), attrs) - t.append(COL(span=len(headers))) - t.append(TR, tuple(map(TH, headers))) - for row in rows: t.append(TR(apply(TD, row))) - return t - -def DefinitionList(*items, **attrs): - dl = apply(DL, (), attrs) - for dt, dd in items: dl.append(DT(dt), DD(dd)) - return dl - - diff --git a/www/HyperText/XML.py b/www/HyperText/XML.py deleted file mode 100644 index 5177bc6..0000000 --- a/www/HyperText/XML.py +++ /dev/null @@ -1,42 +0,0 @@ -__version__ = "$Revision: 1.2 $"[11:-4] - -from SGML import Markup, Comment -from string import lower, join, replace - -class XMLPI(Markup): - - attlist = {} - defaults = {'version': '1.0'} - attr_translations = {'id': 'ID', - 'klass': 'class', - 'label_for': 'for', - 'http_equiv': 'http-equiv', - 'accept_charset': 'accept-charset'} - - def __init__(self, **attr): - self.dict = {} - self.content = () - self.name = 'xml' - self.dict.update(self.defaults) - self.dict.update(attr) - - def __getitem__(self, k): return self.dict[k] - - def str_attribute(self, k): - k2 = self.attr_translations.get(k, k) - return '%s="%s"' % \ - (k2, self.attlist.get(k, 1) and str(self[k]) or k2) \ - - def str_attribute_list(self): - return join(map(self.str_attribute, self.dict.keys())) - - start_tag_string = "\n" - - def start_tag(self): - a = self.str_attribute_list() - return self.start_tag_string % (self.name, a) - - def end_tag(self): - return self.end_tag_string - diff --git a/www/HyperText/__init__.py b/www/HyperText/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/www/HyperText/license.py b/www/HyperText/license.py deleted file mode 100644 index 4b7d6f7..0000000 --- a/www/HyperText/license.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -Copyright 1999 by Comstar.net, Inc., Atlanta, GA, US. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Comstar.net, Inc. -or COMSTAR not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -COMSTAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL COMSTAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" -if __name__=="__main__": print __doc__ diff --git a/www/__init__.py b/www/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/www/database.php b/www/database.php deleted file mode 100644 index ce12c8e..0000000 --- a/www/database.php +++ /dev/null @@ -1,69 +0,0 @@ - - /var/www/cgi-bin/monitor/monitorconfig.php"); -include 'monitorconfig.php'; -define("PICKLE_PATH", MONITOR_DATA_ROOT); - -class Pickle -{ - public function load($name) - { - if ( ! $this->exists("production." . $name) ) - { - print "Exception: No such file %s" . $name . "\n"; - return NULL; - } - $name = "production." . $name; - $fname = $this->__file($name); - $o = unserialize(file_get_contents($fname)); - - return $o; - } - public function dump($name, $obj) - { - if ( ! file_exists(PICKLE_PATH) ) - { - if ( ! mkdir(PICKLE_PATH, 0777, True) ) - { - print "Exception: Unable to create directory :" . PICKLE_PATH . "\n"; - } - } - $name = "production." . $name; - $fname = $this->__file($name); - - return file_put_contents($fname, serialize($obj)); - } - private function __file($name) - { - return sprintf("%s/%s.phpserial", PICKLE_PATH, $name); - } - - public function exists($name) - { - return file_exists($this->__file($name)); - } - - public function remove($name) - { - return unlink($this->__file($name)); - } - - public function if_cached_else($cond, $name, $function) - { - if ( $cond and $this->exists("production.%s" % $name) ) - { - $o = $this->load($name); - } else { - $o = $function(); - if ($cond) - { - $this->dump($name, $o); # cache the object using 'name' - } - } - return o; - } -} - -?> diff --git a/www/gadgets/gadget.php b/www/gadgets/gadget.php deleted file mode 100644 index 391bab7..0000000 --- a/www/gadgets/gadget.php +++ /dev/null @@ -1,91 +0,0 @@ -0||sshstatus<0"); -#$unknown = abs($not_alive - $nossh); -#$time = date("D M j G:i:s"); -#$monday_csv_list= trim(file_get_contents("monday.txt")); -#$monday_array = split(",", $monday_csv_list); - -$bad_csv_list= trim(file_get_contents("badcsv.txt")); -$sarray = split(",", $bad_csv_list); # split on comma - -$alpha_running = $sarray[0]; -$prod_running = $sarray[1]; -$oldboot_running = $sarray[2]; -$alpha_debug = $sarray[3]; - -$prod_debug = $sarray[4]; -$oldboot_debug = $sarray[5]; -$down = $sarray[6]; -#$prod_since_monday = $alpha_running - $monday_array[0]; -#$oldboot_since_monday = $monday_array[1] - $oldboot_running; -$monitor_total = $prod_running + $prod_debug + $down +$oldboot_running + $oldboot_debug + $alpha_running + $alpha_debug; -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MONITORBootDebugDown
Production 4.2
Production 4.1----
Old BootCD--
Sums--
-Direct Link -
diff --git a/www/gadgets/gadget.xml b/www/gadgets/gadget.xml deleted file mode 100644 index d860f0c..0000000 --- a/www/gadgets/gadget.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - -]]> - diff --git a/www/gadgets/regions.xml b/www/gadgets/regions.xml deleted file mode 100644 index 580207f..0000000 --- a/www/gadgets/regions.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - -]]> - diff --git a/www/gadgets/sitemonitor.py b/www/gadgets/sitemonitor.py deleted file mode 100755 index 3ec6231..0000000 --- a/www/gadgets/sitemonitor.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/python - -import cgi -import cgitb -cgitb.enable() -print "Content-Type: text/html\r\n" - -import time -from monitor.model import * -from monitor import database -from HyperText.HTML import A, BR, IMG, TABLE, TR, TH, TD, EM, quote_body, CENTER -from HyperText.Documents import Document - -form = cgi.FieldStorage() - -print """ - -""" - -def get(fb, path): - indexes = path.split("/") - values = fb - for index in indexes: - if index in values: - values = values[index] - else: - return None - return values - -def diff_time(timestamp, abstime=True): - import math - now = time.time() - if timestamp == None: - return "unknown" - if abstime: - diff = now - timestamp - else: - diff = timestamp - # return the number of seconds as a difference from current time. - t_str = "" - if diff < 60: # sec in min. - t = diff / 1 - t_str = "%s sec ago" % int(math.ceil(t)) - elif diff < 60*60: # sec in hour - t = diff / (60) - t_str = "%s min ago" % int(math.ceil(t)) - elif diff < 60*60*24: # sec in day - t = diff / (60*60) - t_str = "%s hrs ago" % int(math.ceil(t)) - elif diff < 60*60*24*14: # sec in week - t = diff / (60*60*24) - t_str = "%s days ago" % int(math.ceil(t)) - elif diff <= 60*60*24*30: # approx sec in month - t = diff / (60*60*24*7) - t_str = "%s weeks ago" % int(math.ceil(t)) - elif diff > 60*60*24*30: # approx sec in month - t = diff / (60*60*24*30) - t_str = "%s months ago" % int(t) - return t_str - -def get_value(val): - - if form.has_key(val): - retvalue = form.getvalue(val) - else: - retvalue = None - - return retvalue - -def state_to_color(state): - if state == "BOOT": - return "darkseagreen" - elif state == "DEBUG": - return "gold" - elif state == "DOWN": - return "indianred" - else: - return "lightgrey" - -def main(): - - if form.has_key('loginbase'): - loginbase = form.getvalue('loginbase') - loginbase = loginbase.rstrip("_") - else: - loginbase = "undefined" - - fb = database.dbLoad("findbad") - lb2hn = database.dbLoad("plcdb_lb2hn") - # todo: pull from HistoryNodeRecord table instead - #pf = database.dbLoad("node_persistflags") - - # SETUP header - t = TABLE(border="0", cellspacing="0", cellpadding="0") - r = TR() - - if loginbase not in lb2hn: - value = ("""Select 'Edit settings' to enter your Site's loginbase.

- The loginbase is the unchangable portion of your slicename. - For instance, your slice follows the pattern loginbase_slicename.

- If this hint is unclear, then you can find your loginbase by visiting 'My Site' at 'PlanetLab.org'""", "") - r = TR(TD(value[0])) - t.append(r) - else: - for value in ['Hostname', 'Since']: - r.append(TH(value)) - t.append(r) - nodes = lb2hn[loginbase] - hostnames = [ n['hostname'] for n in nodes ] - hostnames.sort() - - for host in hostnames: - r = TR() - color = state_to_color(fb['nodes'][host]['values']['state']) - url = 'http://www.planet-lab.org/db/nodes/index.php?nodepattern=%s' % host - td = TD(A(host, target='_blank', href=url), bgcolor=color) - r.append(td) - #lc = pf[host].last_changed - lc=-1 - td = TD(diff_time(lc)) - r.append(td) - t.append(r) - - #d = Document(t) - print CENTER(t) - -if __name__ == "__main__": - main() diff --git a/www/gadgets/sitemonitor.xml b/www/gadgets/sitemonitor.xml deleted file mode 100644 index 4eb2922..0000000 --- a/www/gadgets/sitemonitor.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - -]]> - diff --git a/www/printbadnodes.py b/www/printbadnodes.py deleted file mode 100755 index 47ef62e..0000000 --- a/www/printbadnodes.py +++ /dev/null @@ -1,573 +0,0 @@ -#!/usr/bin/python -from monitor import database -from monitor import config -import string -import sys -import time - -categories = {} -ssherror = False -fb = {} - -def sec2days(sec): - if sec == "null": - sec = -(60*60*24) - sec = int(sec) - return sec/(60*60*24) - -def array_to_priority_map(array): - """ Create a mapping where each entry of array is given a priority equal - to its position in the array. This is useful for subsequent use in the - cmpMap() function.""" - map = {} - count = 0 - for i in array: - map[i] = count - count += 1 - return map - -def cmpValMap(v1, v2, map): - if v1 in map and v2 in map and map[v1] < map[v2]: - return 1 - elif v1 in map and v2 in map and map[v1] > map[v2]: - return -1 - elif v1 in map and v2 in map: - return 0 - else: - raise Exception("No index %s or %s in map" % (v1, v2)) - -def cmpMap(l1, l2, index, map): - if index in l1 and index in l2: - if map[l1[index]] < map[l2[index]]: - return -1 - elif map[l1[index]] > map[l2[index]]: - return 1 - else: - return 0 - else: - return 0 - -def cmpLoginBase(l1, l2): - #print "'" + l1['loginbase'] + "'" + " < " + "'" + l2['loginbase'] + "'" + "
" - if l1['loginbase'] == l2['loginbase']: - return 0 - elif l1['loginbase'] < l2['loginbase']: - return -1 - elif l1['loginbase'] > l2['loginbase']: - return 1 - else: - return 0 - -def cmpState(l1, l2): - map = array_to_priority_map([ 'BOOT', 'DEBUG', 'DOWN' ]) - return cmpMap(l1,l2,'state', map) - -def cmpCategoryVal(v1, v2): - map = array_to_priority_map([ None, 'ALPHA', 'PROD', 'OLDPROD', 'OLDBOOTCD', 'UNKNOWN', 'FORCED', 'ERROR', ]) - return cmpValMap(v1,v2,map) - -def cmpCategory(l1, l2): - map = array_to_priority_map([ 'ALPHA', 'PROD', 'OLDPROD', 'OLDBOOTCD', 'UNKNOWN', 'ERROR', ]) - return cmpMap(l1,l2,'category', map) - -def cmpPCU(l1, l2): - """ Either PCU or NOPCU""" - map = array_to_priority_map([ 'PCU', 'NOPCU', 'UNKNOWN']) - return cmpMap(l1, l2, 'pcu', map) - -def cmpSSH(l1, l2): - """ Either SSH or NOSSH """ - map = array_to_priority_map([ 'SSH', 'NOSSH']) - return cmpMap(l1, l2, 'ssh', map) - -def cmpDNS(l1,l2): - """ Compare DNS states """ - map = array_to_priority_map([ 'OK', 'NOHOSTNAME', 'NOENTRY', 'MISMATCH']) - return cmpMap(l1, l2, 'dnsmatch', map) - -def cmpPing(l1,l2): - """ Either PING or NOPING """ - map = array_to_priority_map([ 'PING', 'NOPING']) - return cmpMap(l1, l2, 'ping', map) - -def cmpUname(l1, l2): - # Extract the kernel version from kernel -a string - l_k1 = l1['kernel'].split() - if len(l_k1) > 2: - k1 = l_k1[2] - else: - return 1 - - l_k2 = l2['kernel'].split() - if len(l_k2) > 2: - k2 = l_k2[2] - else: - return -1 - - return cmp(k1, k2) - -def cmpDays(l1, l2): - if l1['comonstats'][config.comon] == "null": - l1['comonstats'][config.comon] = -1 - if l2['comonstats'][config.comon] == "null": - l2['comonstats'][config.comon] = -1 - - if int(l1['comonstats'][config.comon]) > int(l2['comonstats'][config.comon]): - return -1 - elif int(l1['comonstats'][config.comon]) < int(l2['comonstats'][config.comon]): - return 1 - else: - return 0 - -def ssh_error_to_str(str): - ssh_error = "" - if "Connection timed out" in str: - ssh_error = "Timeout" - elif "Connection closed by remote host" in str: - ssh_error = "Closed by remote host" - elif "Connection refused" in str: - ssh_error = "Connection refused" - elif "Temporary failure in name resolution" in str: - ssh_error = "Could not resolve name" - elif "Name or service not known" in str: - ssh_error = "Name not known" - elif "Too many authentication failures" in str: - ssh_error = "Disconnect: root auth failure" - elif "Network is unreachable" in str: - ssh_error = "Network is unreachable" - elif "Connection reset by peer" in str: - ssh_error = "Connection reset by peer" - elif "WARNING" in str: - ssh_error = "WARNING ssh key updated" - else: - ssh_error = str - - return ssh_error - -def pcu_state(pcu_id): - global fb - - if 'nodes' in fb and "id_%s" % pcu_id in fb['nodes'] \ - and 'values' in fb['nodes']["id_%s" % pcu_id]: - rec = fb['nodes']["id_%s" % pcu_id]['values'] - if 'reboot' in rec: - rb = rec['reboot'] - if rb == 0 or rb == "0": - return 0 - elif "NetDown" == rb or "Not_Run" == rb: - return 1 - else: - return -1 - else: - return -1 - else: - return -1 - -def fields_to_html(fields, vals): - global categories - global ssherror - pcu_colorMap = { -1 : 'indianred', - 0 : 'darkseagreen', - 1 : 'gold', } - - colorMap = { 'PING' : 'darkseagreen', - 'NOPING': 'darksalmon', - 'SSH': 'darkseagreen', - 'NOSSH': 'indianred', - 'PCU': 'darkseagreen', - 'NOPCU': 'lightgrey', - 'OLDBOOTCD': 'crimson', - 'DOWN': 'indianred', - 'ALPHA': 'gold', - 'ERROR': 'crimson', - 'PROD': 'darkseagreen', - 'DEBUG': 'darksalmon', - 'DEBUG': 'darksalmon', - 'BOOT': 'lightgreen'} - r_str = "" - f_prev = "" - f_2prev = "" - #print 'inside--------------' - for f in fields: - f = f.strip() - #print f - - if f in ['DOWN', 'BOOT', 'DEBUG']: - #key = "%s-%s-%s" % (f,f_prev,f_2prev) - key = "%s-%s" % (f,f_prev) - if key not in categories: - categories[key] = 1 - else: - categories[key] += 1 - - #print "
%s

" % f - - if f in colorMap: - bgcolor="bgcolor='%s'" % colorMap[f] - else: - bgcolor="" - - if f == 'NOSSH': - if ssherror: - if 'ssherror' in vals: - str_ssh_error = ssh_error_to_str(vals['ssherror']) - else: - str_ssh_error = "NO SSHERROR in VALS" - if str_ssh_error != "Timeout": - r_str += """%s
%s""" % \ - (bgcolor,f,str_ssh_error) - else: - r_str += "%s" % (bgcolor, f) - else: - r_str += "%s" % (bgcolor, f) - elif f == 'PCU': - if len(vals['plcnode']['pcu_ids']) > 0: - #print "pcu_id: %s
" % vals['plcnode']['pcu_ids'][0] - #print "state: %s
" % pcu_state(vals['plcnode']['pcu_ids'][0]) - #print "color: %s
" % pcu_colorMap[pcu_state(vals['plcnode']['pcu_ids'][0])] - bgcolor = "bgcolor='%s'" % pcu_colorMap[pcu_state(vals['plcnode']['pcu_ids'][0])] - url = "PCU" % vals['plcnode']['pcu_ids'][0] - r_str += "%s" % (bgcolor, url) - else: - r_str += "%s" % (bgcolor, f) - f_2prev = f_prev - f_prev = f - - return r_str - -def my_diff_time(timestamp): - now = time.time() - if timestamp == None: - return "not yet contacted" - diff = now - timestamp - # return the number of seconds as a difference from current time. - t_str = "" - if diff < 60: # sec in min. - t = diff - t_str = "%s sec ago" % t - elif diff < 60*60: # sec in hour - t = diff // (60) - t_str = "%s min ago" % int(t) - elif diff < 60*60*24: # sec in day - t = diff // (60*60) - t_str = "%s hours ago" % int(t) - elif diff < 60*60*24*7: # sec in week - t = diff // (60*60*24) - t_str = "%s days ago" % int(t) - elif diff < 60*60*24*30: # approx sec in month - t = diff // (60*60*24*7) - t_str = "%s weeks ago" % int(t) - elif diff > 60*60*24*30 and diff < 60*60*24*30*2: # approx sec in month - month = int( diff // (60*60*24*30) ) - weeks = (diff - (month * (60*60*24*30))) // (60*60*24*7) - if weeks == 0: - t_str = "%s month ago" % int(month) - elif weeks == 4: - t_str = "2 months ago" - else: - t_str = "%s month and %s weeks ago" % ( int(month) , int(weeks) ) - elif diff >= 60*60*24*30*2: - month = diff // (60*60*24*30) - t_str = "%s months ago" % int(month) - return t_str - - -def main(sitefilter, catfilter, statefilter, comonfilter, nodeonlyfilter): - global fb - import os - import datetime - if nodeonlyfilter == None: - print "\n" - - try: - mtime = os.stat("/var/lib/monitor-server/production.findbad.pkl")[-2] - print "Last Updated: %s GMT" % datetime.datetime.fromtimestamp(mtime) - except: - pass - - - db = database.dbLoad(config.dbname) - fb = database.dbLoad("findbadpcus") - - ## Field widths used for printing - maxFieldLengths = { 'nodename' : -45, - 'ping' : 6, - 'ssh' : 6, - 'pcu' : 7, - 'category' : 9, - 'state' : 5, - 'kernel' : 10.65, - 'comonstats' : 5, - 'last_contact' : 10.65, - 'plcsite' : 12, - 'bootcd' : 10.65} - ## create format string based on config.fields - fields = {} - format = "" - format_fields = [] - for f in config.fields.split(','): - fields[f] = "%%(%s)s" % f - #print f - #if f in maxFieldLengths: - # fields[f] = "%%(%s)%ds" % (f, maxFieldLengths[f]) - #else: - # fields[f] = "%%(%s)%ds" % (f, 10) - - format_fields.append(fields[f]) - #print fields - for f in config.fields.split(','): - format += fields[f] + " " - #print format - - d_n = db['nodes'] - l_nodes = d_n.keys() - - # category by site - #bysite = {} - #for nodename in l_nodes: - # if 'plcsite' in d_n[nodename]['values'] and \ - # 'login_base' in d_n[nodename]['values']['plcsite']: - # loginbase = d_n[nodename]['values']['plcsite']['login_base'] - # if loginbase not in bysite: - # bysite[loginbase] = [] - # d_n[nodename]['values']['nodename'] = nodename - # bysite[loginbase].append(d_n[nodename]['values']) - - # d2 was an array of [{node}, {}, ...] - # the bysite is a loginbase dict of [{node}, {node}] - d2 = [] - import re - if sitefilter != None: - sf = re.compile(sitefilter) - else: - sf = None - for nodename in l_nodes: - vals=d_n[nodename]['values'] - v = {} - v.update(vals) - v['nodename'] = nodename - if 'plcsite' in vals and \ - 'status' in vals['plcsite'] and \ - vals['plcsite']['status'] == "SUCCESS": - - url = "%s" % ( vals['plcsite']['login_base'], - vals['plcsite']['login_base']) - - site_string = "%s %2s nodes :: %2s of %4s slices" % ( \ - url, - vals['plcsite']['num_nodes'], - vals['plcsite']['num_slices'], - vals['plcsite']['max_slices']) - loginbase = d_n[nodename]['values']['plcsite']['login_base'] - else: - #print "ERROR: ", nodename, vals, "
" - site_string = "UNKNOWN" - loginbase = "" - - v['site_string'] = site_string - v['loginbase'] = loginbase - if (sitefilter != None and sf.match(loginbase) != None) or sitefilter == None: - d2.append(v) - - - if sitefilter != None: - config.cmpcategory = True - else: - config.cmploginbase = True - - - if config.cmploginbase: - d2.sort(cmp=cmpLoginBase) - elif config.cmpping: - d2.sort(cmp=cmpPing) - elif config.cmpdns: - d2.sort(cmp=cmpDNS) - elif config.cmpssh: - d2.sort(cmp=cmpSSH) - elif config.cmpcategory: - d2.sort(cmp=cmpCategory) - elif config.cmpstate: - d2.sort(cmp=cmpState) - elif config.cmpdays: - d2.sort(cmp=cmpDays) - elif config.cmpkernel: - d2.sort(cmp=cmpUname) - else: - d2.sort(cmp=cmpCategory) - - - if catfilter != None: cf = re.compile(catfilter) - else: cf = None - - if statefilter != None: stf = re.compile(statefilter) - else: stf = None - - if comonfilter != None: cmf = re.compile(comonfilter) - else: cmf = None - - - output_str = "" - #l_loginbase = bysite.keys() - #l_loginbase.sort() - if nodeonlyfilter == None: - output_str += "" - - prev_sitestring = "" - for row in d2: - - vals = row - - #added by guto about last contact information - if (catfilter != None and cf.match(vals['category']) == None): - continue - - if (statefilter != None and stf.match(vals['state']) == None): - continue - - if (comonfilter != None and comonfilter in vals['comonstats'] and vals['comonstats'][comonfilter] != 'null'): - continue - - if nodeonlyfilter != None: - output_str += vals['nodename'] - continue - - site_string = row['site_string'] - if site_string != prev_sitestring: - output_str += "" - else: - output_str += "" - - prev_sitestring = site_string - - - # convert uname values into a single kernel version string - if 'kernel' in vals: - kernel = vals['kernel'].split() - if len(kernel) > 0: - if kernel[0] == "Linux": - vals['kernel'] = kernel[2] - else: - vals['ssherror'] = vals['kernel'] - vals['kernel'] = "" - else: - vals['ssherror'] = "" - vals['kernel'] = "" -# continue - if 'model' in vals or 'protocol' in vals or 'portstatus' in vals: - #vals['model'] = string.replace(vals['model']," ", " ") - #vals['protocol'] = vals['protocol'].replace(" ", " ") - if vals['model'] == None: - vals['model'] = " " - vals['model'] = string.replace(vals['model']," ", "_") - vals['protocol'] = vals['protocol'].replace(" ", "_") - ps = "" - ports = vals['portstatus'] - lports = ports.keys() - lports.sort() - for port in lports: - t = ports[port] - if t != "closed": - ps += "%s: %s
" % (port, ports[port]) - if ps == "": - ps = "All_closed" - - vals['portstatus'] = ps - - if 'reboot' in vals: - vals['reboot'] = "%s" % vals['reboot'] - vals['reboot'] = vals['reboot'].replace(" ", "_") - - if 'nodename' in vals: - url = "%s" % (config.MONITOR_HOSTNAME, vals['nodename'], vals['nodename']) - vals['nodename'] = url - - if 'plcnode' in vals: - if vals['plcnode']['status'] == "GN_FAILED": - vals['last_contact'] = "UNKNOWN" - else: - vals['last_contact'] = my_diff_time(vals['plcnode']['last_contact']) - - try: - str_fields = [] - count = 0 - for f in format_fields: - str_fields.append(f % vals) - count += 1 - except: - print >>sys.stderr, vals - - s = fields_to_html(str_fields, vals) - output_str += s - - output_str += "\n" - - if nodeonlyfilter == None: - output_str += "
" - output_str += site_string - output_str += "
 
" - keys = categories.keys() - keys.sort() - print "" - for cat in keys: - print "" - print "" % cat - print "" % categories[cat] - print "" - if nodeonlyfilter == None: - print "
Total %s%s
" - - print output_str - if nodeonlyfilter == None: - print "\n" - - - -if __name__ == '__main__': - import cgi - import cgitb; - cgitb.enable() - import sys - - form = cgi.FieldStorage() - myfilter = None - - if form.has_key('site'): - myfilter = form.getvalue("site") - else: - myfilter = None - - if form.has_key('category'): - mycategory = form.getvalue("category") - else: - mycategory = None - - if form.has_key('state'): - mystate = form.getvalue("state") - else: - mystate = None - - if form.has_key('comon'): - mycomon = form.getvalue("comon") - else: - mycomon = None - - if form.has_key('nodeonly'): - mynodeonly = form.getvalue("nodeonly") - else: - mynodeonly = None - - config.cmpdays=False - config.comon="sshstatus" - config.fields="nodename,ping,ssh,pcu,category,state,last_contact,kernel,bootcd" - config.dbname="findbad" - config.cmpping=False - config.cmpdns=False - config.cmploginbase=False - config.cmpssh=False - config.cmpcategory=False - - print "Content-Type: text/html\r\n" - if len(sys.argv) > 1: - if sys.argv[1] == "ssherror": - ssherror = True - main(myfilter, mycategory, mystate, mycomon,mynodeonly) diff --git a/www/printbadpcus.php b/www/printbadpcus.php deleted file mode 100644 index 500be1f..0000000 --- a/www/printbadpcus.php +++ /dev/null @@ -1,332 +0,0 @@ - 0 ) { - return join("
", $pcu['complete_entry']); - } else { - return " "; - } -} - -function format_ports($pcu) -{ - $str = ""; - #print print_r(is_array($pcu)) . "
"; - #print print_r(array_key_exists('portstatus', $pcu)) . "
"; - if ( is_array($pcu) && array_key_exists('portstatus', $pcu) && count(array_keys($pcu['portstatus'])) > 0 ) - { - $portstat = $pcu['portstatus']; - - #foreach ( array('22', '23', '80', '443') $portstat as $port => $state) - foreach ( array('22', '23', '80', '443', '9100', '16992') as $port) - { - $state = $portstat[$port]; - switch ($state) - { - case "open": - $color = "lightgreen"; - break; - case "filtered": - $color = "gold"; - break; - case "closed": - $color = "indianred"; - break; - default: - $color = "white"; - break; - } - $str .= "$port "; - # . ": " . $state . "
"; - } - } else { - # print print_r(is_array($pcu)) . "
"; - # print print_r(array_key_exists('portstatus', $pcu)) . "
"; - #echo "
";
-		#print_r($pcu['portstatus']);
-		#echo "
"; - } - if ( $str == "" ) - { - $str = "Closed/Filtered"; - } - return $str; -} -function DNS_to_color($dns) -{ - switch ($dns) - { - case "DNS-OK": - return 'lightgreen'; - case "NOHOSTNAME": - return 'white'; - case "DNS-MISMATCH": - return 'gold'; - case "NO-DNS-OR-IP": - case "DNS-NOENTRY": - return 'indianred'; - } - return 'white'; -} -function reboot_to_str($reboot) -{ - $ret = $reboot; - switch ($reboot) - { - case "0": - $ret = "OK"; - break; - default: - break; - } - return $ret; -} - -function reboot_to_color($reboot) -{ - switch ($reboot) - { - case "0": - return "darkseagreen"; - break; - case "NetDown": - return "lightgrey"; - break; - case "Not_Run": - return "lightgrey"; - break; - case "Unsupported_PCU": - return "indianred"; - break; - default: - if ( strpos($reboot, "error") >= 0) - { - return "indianred"; - } else { - return 'white'; - } - break; - } - return "white"; -} - -function get_pcuid($pcu) { return $pcu['pcu_id']; } -function get_dns($pcu) { return $pcu['dnsmatch']; } -function get_dryrun($pcu) { return $pcu['reboot']; } -function get_model($pcu) { return $pcu['model']; } -function get_category_link($category,$header) -{ - return "$header"; -} - -include 'database.php'; -$p = new Pickle(); -$findbad = $p->load("findbadpcus"); -$findbadpcus = array_keys($findbad['nodes']); - -$pculist = array(); -$c = 0; -foreach ( $findbadpcus as $pcu_id ) -{ - if ( is_array($findbad['nodes'][$pcu_id]) ) - { - #if ( in_array('values', $findbad['nodes'][$pcu]) ) - #{ - # echo $pcu . " true
"; - #} else{ - # echo $pcu . " false
"; - #} - if ( array_key_exists('values', $findbad['nodes'][$pcu_id]) ) - { - $pculist[] = $findbad['nodes'][$pcu_id]['values']; - } - } -} -$total = count($pculist); - - - -if ( $_GET['category'] ) -{ - $category = $_GET['category']; - if ( $category == "node_ids" ) - { - $newfunc = create_function('$pcu', 'return count($pcu[\'' . $category . '\']);'); - } else if ( $category == "login_base" ) - { - $newfunc = create_function('$pcu', 'return $pcu[\'plcsite\'][\'' . $category . '\'];'); - } else { - $newfunc = create_function('$pcu', 'return $pcu[\'' . $category . '\'];'); - } - if ( $newfunc != "" ) - { - $fields = array_map($newfunc, $pculist); - array_multisort($fields, SORT_ASC, SORT_STRING, $pculist); - } else { - echo "ERROR create_function == null
"; - } -} - -if ( $_REQUEST['id'] ) -{ - $id = $_REQUEST['id']; -} else{ - $id = "all"; -} -#print print_r($_SERVER) . "
"; - -//array_multisort($protocols, SORT_ASC, SORT_STRING, $pculist); -?> - -PLC PCU Info - - - - - Total PCUs : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Count
'>'>'>
- Reachable Nodes: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'>'>'>
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Legend for 'DNS Status'
DNS-OKThis indicates that the DNS name and registered IP address match.
DNS-MISMATCHSometimes, the registered IP and DNS IP address do not match. In these cases it is not clear which is correct, - so an error is flagged.
DNS-NOENTRYWhile a hostname is provided in the registration, the hostname is not actually registered in DNS.
NOHOSTNAMEWhile we prefer that a hostname be registered, it is not - strictly required, since simply the IP address, if it is static, is enough to access the PCU.
Legend for 'Port Status'
OpenGreen port numbers are believed to be open.
FilteredGold port numbers are believed to be filtered or simply offline.
ClosedFinally, red ports appear to be closed.
Legend for 'Test Results'
OKThe PCU is accessible, and short of actually rebooting the node, everything appears to work.
NetDownThe PCU is inaccessible from the PlanetLab address block 128.112.139.0/25, or it is simply offline.
Not_RunPrevious errors, such as DNS or an incomplete configuration prevented the actual test from begin performed.
Other ErrorsOther errors are reported by the test that are more specific to the block encountered by the script.
- - - - - diff --git a/www/runlevels.py b/www/runlevels.py deleted file mode 100755 index a61426e..0000000 --- a/www/runlevels.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/python - -import cgi -import cgitb; -from monitor import database -import time -cgitb.enable() - -from HyperText.HTML import A, BR, IMG, TABLE, TR, TH, TD, EM, quote_body -from HyperText.Documents import Document -print "Content-Type: text/html\r\n" - -form = cgi.FieldStorage() - -def get(fb, path): - indexes = path.split("/") - values = fb - for index in indexes: - if index in values: - values = values[index] - else: - return None - return values - -def diff_time(timestamp, abstime=True): - import math - now = time.time() - if timestamp == None: - return "unknown" - if abstime: - diff = now - timestamp - else: - diff = timestamp - # return the number of seconds as a difference from current time. - t_str = "" - if diff < 60: # sec in min. - t = diff / 1 - t_str = "%s sec ago" % int(math.ceil(t)) - elif diff < 60*60: # sec in hour - t = diff / (60) - t_str = "%s min ago" % int(math.ceil(t)) - elif diff < 60*60*24: # sec in day - t = diff / (60*60) - t_str = "%s hrs ago" % int(math.ceil(t)) - elif diff < 60*60*24*14: # sec in week - t = diff / (60*60*24) - t_str = "%s days ago" % int(math.ceil(t)) - elif diff <= 60*60*24*30: # approx sec in month - t = diff / (60*60*24*7) - t_str = "%s wks ago" % int(math.ceil(t)) - elif diff > 60*60*24*30: # approx sec in month - t = diff / (60*60*24*30) - t_str = "%s mnths ago" % int(t) - return t_str - -def get_value(val): - - if form.has_key(val): - retvalue = form.getvalue(val) - else: - retvalue = None - - return retvalue - -vals = {} -vals['ssh'] = get_value('ssh') -vals['state'] = get_value('state') -vals['nm'] = get_value('nm') -vals['dns'] = None -vals['readonlyfs'] = None -vals['plcnode/last_contact'] = None -vals['comonstats/uptime'] = None -vals['princeton_comon'] = get_value('princeton_comon') -vals['princeton_comon_running'] = get_value('princeton_comon_running') -vals['princeton_comon_procs'] = get_value('princeton_comon_procs') - - -rows = "" -fb = database.dbLoad("findbad") -packed_values = [] -node_count = 0 -for mynode in fb['nodes'].keys(): - fbnode = fb['nodes'][mynode]['values'] - row = [] - row.append(mynode) - add=True - if 'readonlyfs' in fbnode: - if 'Read-only file system' in fbnode['readonlyfs']: - fbnode['readonlyfs'] = 'Y' - else: - fbnode['readonlyfs'] = '_' - - if 'dns' in fbnode: - if 'boot.planet-lab.org has address' in fbnode['dns']: - fbnode['dns'] = '_' - else: - fbnode['dns'] = 'N' - - for key in ['ssh', 'state', 'plcnode/last_contact', 'readonlyfs', 'dns', 'nm', 'princeton_comon', 'princeton_comon_running', 'princeton_comon_procs', 'comonstats/uptime']: - if get(fbnode, key) is None: - row.append('nokey') - else: - if vals[key] is not None and vals[key] in get(fbnode, key): - add = True & add - elif vals[key] is None: - add = True & add - else: - add = False - - if 'last_contact' in key: - t = time.time() - lc = get(fbnode,key) - diff = ((t - lc) // (60*60*6)) * 6 - row.append(-int(diff)) - else: - row.append(get(fbnode,key)) - if add: - packed_values.append(row) - - - -def rowcmp(x,y): - for i in range(1,len(x)): - if x[i] == y[i]: continue - if x[i] < y[i]: return -1 - if x[i] > y[i]: return 1 - return 0 - -packed_values.sort(rowcmp) - -t = TABLE(border=1) -r = TR() -for value in ['num', 'host', 'ssh', 'state', 'last
contact', 'readonlyfs', 'dns', 'NM', 'comon
dir', 'comon
vserver', 'comon
procs']: - r.append(TD(value)) -t.append(r) - -i=1 -for row in packed_values: - r = TR() - r.append(TD(i)) - for value in row: - r.append(TD(value)) - i+=1 - t.append(r) - -#r = TR() -#r.append(TD(node_count)) -#t.append(r) - -d = Document(t) -print d diff --git a/www/siteactions.cgi b/www/siteactions.cgi deleted file mode 100755 index 70bab1d..0000000 --- a/www/siteactions.cgi +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/python - -# Read in the act_* databases and print out a human readable version - -import sys -import time -import getopt -import soltesz - - -def fields_to_html(fields): - colorMap = { 'PING' : 'darkseagreen', - 'NOPING': 'darksalmon', - 'SSH': 'darkseagreen', - 'NOSSH': 'indianred', - 'PCU': 'darkseagreen', - 'NOPCU': 'lightgrey', - 'OLDBOOTCD': 'crimson', - 'DOWN': 'indianred', - 'ALPHA': 'gold', - 'ERROR': 'crimson', - 'PROD': 'darkseagreen', - 'DEBUG': 'darksalmon', - 'DEBUG': 'darksalmon', - 'BOOT': 'lightgreen'} - r_str = "" - for f in fields: - if f in colorMap: - bgcolor="bgcolor='%s'" % colorMap[f] - else: - bgcolor="" - r_str += "%s" % (bgcolor, f) - - return r_str - -def rtTicketLink(rt_ticket): - link = """RT #%s""" % (rt_ticket, rt_ticket) - return link - -def main(): - - total_sites = 0 - total_nodes = 0 - total_restored = 0 - total_down = 0 - - act_all = soltesz.dbLoad("act_all") - plcdb_hn2lb = soltesz.dbLoad("plcdb_hn2lb") - sickdb = {} - - sorted_keys = act_all.keys() - sorted_keys.sort() - for nodename in sorted_keys: - diag_nodelist = act_all[nodename] - if nodename in plcdb_hn2lb: - lb = plcdb_hn2lb[nodename] - if lb not in sickdb: - sickdb[lb] = {} - sickdb[lb][nodename] = diag_nodelist - - sorted_keys = sickdb.keys() - sorted_keys.sort() - print "" - for loginbase in sorted_keys: - nodedict = sickdb[loginbase] - sort_nodekeys = nodedict.keys() - sort_nodekeys.sort() - print "", - print "" - total_sites += 1 - for nodename in sort_nodekeys: - total_nodes += 1 - if len(act_all[nodename]) == 0: - #print "" % (nodename) - #print "" - continue - else: - # print just the latest event - event = act_all[nodename][0] - fields = [] - fields += [nodename] - if 'time' in event: - s_time=time.strftime("%Y/%m/%d %H:%M:%S", - time.gmtime(event['time'])) - fields += [s_time] - if 'ticket_id' in event and event['ticket_id'] != "": - link = rtTicketLink(event['ticket_id']) - fields += [link] - else: - if 'found_rt_ticket' in event and event['found_rt_ticket'] != "": - link = rtTicketLink(event['found_rt_ticket']) - fields += [link] - else: - fields += ["No Known RT Ticket"] - - if event['action'] == "close_rt": - total_restored += 1 - else: - total_down += 1 - - for f in ['category', 'action', 'stage', 'info']: - if 'stage' in f and 'stage' in event and 'stage' in event['stage']: - # truncate the stage_ part. - event['stage'] = event['stage'][6:] - if f in event: - if type(event[f]) == type([]): - fields += event[f] - else: - fields += [event[f]] - else: - fields += [" "] - - print "", - print fields_to_html(fields), - print "" - - print "
", - print loginbase, - print " 
%shas no events
" - print "" - print "" - print "" - print "" - print "" - print "" - print "" - - print "" - print "" % total_sites - print "" % total_nodes - print "" % total_restored - print "" % total_down - - print "" - print "
SitesNodesRestoredDown
%s%s%s%s
" - - - -if __name__ == '__main__': - print "Content-Type: text/html\r\n" - print "\n" - main() - print "\n" diff --git a/www/siteactions.php b/www/siteactions.php deleted file mode 100644 index 69ccc10..0000000 --- a/www/siteactions.php +++ /dev/null @@ -1,198 +0,0 @@ -$header"; -} -function rt_link ($ref, $id) -{ - $slink = sprintf("%s #%s", $id, $ref, $id); - return $slink; -} - -function history_link($nodename) -{ - return sprintf("%s", $nodename, $nodename); -} - -class Event -{ - function Event($event_record) - { - $this->data = $event_record; - } - public function getTime() - { - if ( array_key_exists('time', $this->data) ) - { - $stime=strftime("%Y/%m/%d %H:%M", $this->data['time']); - return $stime; - } else { - return ""; - } - } - public function getField($field) - { - if ( array_key_exists($field, $this->data ) ) - { - # truncate the stage_ part. - #event['stage'] = event['stage'][6:] - if ( is_array($this->data[$field]) and $field != "info" ): - $ret = $this->data[$field][0]; - elseif ( is_array($this->data[$field]) and $field == "info" ): - $ar = $this->data[$field]; - $ret = sprintf("%s -> %s", $ar[1] , $ar[2]); - else: - $ret = $this->data[$field]; - endif; - } else { - $ret = " "; - } - return $ret; - - } - public function getRTTicket() - { - if ( array_key_exists('ticket_id', $this->data) and - $this->data['ticket_id'] != "" ) - { - $rt_ticket = $this->data['ticket_id']; - $slink = rt_link("Monitor", $rt_ticket); - - } elseif ( array_key_exists('found_rt_ticket', $this->data) and - $this->data['found_rt_ticket'] != "" ) { - $rt_ticket = $this->data['found_rt_ticket']; - $slink = rt_link("Support", $rt_ticket); - } else { - $slink = "No tickets"; - } - return $slink; - } -} - -include 'database.php'; -$p = new Pickle(); -$act_all = $p->load("act_all"); -$plcdb_hn2lb = $p->load("plcdb_hn2lb"); -$findbad = $p->load("findbadnodes"); -$findbadnodes = array_keys($findbad['nodes']); - -$sickdb = array(); - -$all_hosts = array_keys($act_all); -foreach ( $all_hosts as $nodename): - $diag_nodelist = $act_all[$nodename]; - if ( array_key_exists($nodename, $plcdb_hn2lb) ) - $lb = $plcdb_hn2lb[$nodename]; - if ( ! array_key_exists($lb, $sickdb) ) - $sickdb[$lb] = array(); - $sickdb[$lb][$nodename] = $diag_nodelist; -endforeach; - -if ( array_key_exists('history', $_GET) ) -{ - $history_nodename = $_GET['history']; - $all_loginbases = array($plcdb_hn2lb[$history_nodename]); - $get_history = TRUE; -} else { - $all_loginbases = array_keys($sickdb); - sort($all_loginbases); - $get_history = FALSE; -} - -$display = array(); - -foreach ( $all_loginbases as $loginbase ): - $nodedict = $sickdb[$loginbase]; - $hosts = array_keys($nodedict); - sort($hosts); - if ( $get_history ) { - $nodename = $history_nodename; - foreach ( $act_all[$nodename] as $event_record ): - - $event = new Event($event_record); - $row = array(); - $row['loginbase'] = $loginbase; - $row['hostname'] = history_link($nodename); - $row['time'] = $event->getTime(); - $row['ticket_id'] = $event->getRTTicket(); - foreach ( array('category', 'action', 'stage', 'info') as $field ) - { - $row[$field] = $event->getField($field); - } - $display[] = $row; - endforeach; - } elseif ( ! $get_history ) { - foreach ( $hosts as $nodename ): - if ( count($act_all[$nodename]) == 0 ) continue; - - $event = new Event($act_all[$nodename][0]); - $row = array(); - $row['loginbase'] = $loginbase; - $row['hostname'] = history_link($nodename); - #$row['time'] = "
" . print_r($act_all[$nodename][0], TRUE) .  "
"; - $row['time'] = $event->getTime(); - $row['ticket_id'] = $event->getRTTicket(); - $row['plcstate'] = $event->data['plcnode']['boot_state']; - $row['currentcategory'] = $findbad['nodes'][$nodename]['values']['category'] . - "-" . $findbad['nodes'][$nodename]['values']['state']; - foreach ( array('category', 'action', 'stage', 'info') as $field ) - { - $row[$field] = $event->getField($field); - } - - $display[] = $row; - endforeach; - } -endforeach; -?> - -siteactions.php - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Count
/
- - - -- 2.43.0