Index: trunk/tools/ts-specs/ext-sources/addlog |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +#! /usr/bin/env python |
| 3 | + |
| 4 | +import xmlrpclib |
| 5 | +import os, sys, time, socket |
| 6 | +from getopt import getopt |
| 7 | + |
| 8 | +rpc = 'https://confluence.toolserver.org/rpc/xmlrpc' |
| 9 | + |
| 10 | +loginfile = os.getenv("HOME") + "/.addlog" |
| 11 | + |
| 12 | +servername = socket.gethostname() |
| 13 | +(opts, args) = getopt(sys.argv[1:], "s:") |
| 14 | + |
| 15 | +for v in opts: |
| 16 | + if v[0] == '-s': |
| 17 | + servername = v[1] |
| 18 | + |
| 19 | +h = open(loginfile, "r") |
| 20 | +username = h.readline()[:-1] |
| 21 | +password = h.readline()[:-1] |
| 22 | +h.close() |
| 23 | + |
| 24 | +c = xmlrpclib.Server(rpc) |
| 25 | +auth = c.confluence1.login(username, password) |
| 26 | +log = c.confluence1.getPage(auth, "tech", "Maintenance log") |
| 27 | + |
| 28 | + |
| 29 | +lines = log['content'].replace("\r\n", "\n").split("\n") |
| 30 | +newlines = [] |
| 31 | + |
| 32 | +# Look for the start of the log |
| 33 | +gotnew = False |
| 34 | +for l in lines: |
| 35 | + newlines.append(l) |
| 36 | + if l == "BEGIN LOG": |
| 37 | + # insert the new entry |
| 38 | + newlines.append("* %s: %s: *%s*: %s" % (time.strftime("%Y-%m-%d %H:%M"), os.getlogin(), servername, " " .join(args))) |
| 39 | + gotnew = True |
| 40 | + |
| 41 | +if gotnew == False: |
| 42 | + print "Couldn't find where to insert log entry!" |
| 43 | + print "Page text:" |
| 44 | + for l in lines: |
| 45 | + print "[%s]" % l |
| 46 | + sys.exit(1) |
| 47 | + |
| 48 | +log["content"] = "\n".join(newlines) |
| 49 | +r = c.confluence1.storePage(auth, log) |
Property changes on: trunk/tools/ts-specs/ext-sources/addlog |
___________________________________________________________________ |
Name: svn:executable |
1 | 50 | + * |
Index: trunk/tools/ts-specs/TSaddlog.spec |
— | — | @@ -0,0 +1,35 @@ |
| 2 | +%include Solaris.inc |
| 3 | + |
| 4 | +Name: TSaddlog |
| 5 | +Summary: addlog tool |
| 6 | +Version: 1.0 |
| 7 | +Source1: addlog |
| 8 | + |
| 9 | +SUNW_BaseDir: %{_basedir} |
| 10 | +BuildRoot: %{_tmppath}/%{name}-%{version}-build |
| 11 | +%include default-depend.inc |
| 12 | + |
| 13 | +# Requires: |
| 14 | + |
| 15 | +%prep |
| 16 | +%setup -q -T -c -n %name-%version |
| 17 | +cp %SOURCE1 . |
| 18 | + |
| 19 | +%build |
| 20 | + |
| 21 | +%install |
| 22 | +rm -rf $RPM_BUILD_ROOT |
| 23 | +mkdir -p $RPM_BUILD_ROOT%{_bindir} |
| 24 | +cp addlog $RPM_BUILD_ROOT%{_bindir} |
| 25 | + |
| 26 | +%clean |
| 27 | +rm -rf $RPM_BUILD_ROOT |
| 28 | + |
| 29 | +%files |
| 30 | +%defattr (-, root, bin) |
| 31 | +%dir %attr (0755, root, bin) %{_bindir} |
| 32 | +%attr (0755, root, bin) %{_bindir}/* |
| 33 | + |
| 34 | +%changelog |
| 35 | +* Wed Jan 28 2009 - river@wikimedia.org |
| 36 | +- initial spec |