~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/script/xmlrpc/remote.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
MoinMoin - remote command execution, client part
 
4
 
 
5
@copyright: 2006 MoinMoin:ThomasWaldmann
 
6
@license: GNU GPL, see COPYING for details.
 
7
"""
 
8
 
 
9
import sys
 
10
import xmlrpclib
 
11
 
 
12
from MoinMoin.script import MoinScript, fatal
 
13
 
 
14
class PluginScript(MoinScript):
 
15
    """\
 
16
Purpose:
 
17
========
 
18
This tool allows you to execute moin scripts remotely.
 
19
 
 
20
Detailed Instructions:
 
21
======================
 
22
General syntax: moin [options] xmlrpc remote [remote-options]
 
23
 
 
24
[options] usually should be:
 
25
    --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/
 
26
 
 
27
[remote-options] see below:
 
28
    0. Verify that you have a remotescriptconf.py configuration file.
 
29
 
 
30
    1. To run the script 'account check' remotely.
 
31
       moin ... xmlrpc remote account check
 
32
"""
 
33
 
 
34
    def __init__(self, argv, def_values):
 
35
        MoinScript.__init__(self, argv, def_values)
 
36
        self.argv = argv
 
37
 
 
38
    def mainloop(self):
 
39
        try:
 
40
            import remotescriptconf as conf
 
41
        except ImportError:
 
42
            fatal("Could not find the file remotescriptconf.py. Maybe you want to use the config param?")
 
43
 
 
44
        secret = conf.remotescript_secret
 
45
        url = conf.remotescript_url
 
46
        print url, secret, self.argv
 
47
 
 
48
        s = xmlrpclib.ServerProxy(url)
 
49
 
 
50
        # TODO handle stdin
 
51
        # xmlrpclib.Binary(sys.stdin.read())
 
52
        result = s.RemoteScript(secret, self.argv)
 
53
        # TODO handle stdout, stderr
 
54
 
 
55
        if result != "OK":
 
56
            print >> sys.stderr, result
 
57