annotate MoinMoin/script/xmlrpc/remote.py @ 3108:2572688e031a

improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 23 Feb 2008 23:40:48 +0100
parents 3d08f1cb4429
children a20de9383481
rev   line source
934
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
3 MoinMoin - remote command execution, client part
934
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
5 @copyright: 2006 MoinMoin:ThomasWaldmann
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
6 @license: GNU GPL, see COPYING for details.
934
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 """
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 import sys
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 import xmlrpclib
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 from MoinMoin.script import MoinScript, fatal
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 class PluginScript(MoinScript):
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
15 """\
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
16 Purpose:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
17 ========
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
18 This tool allows you to execute moin scripts remotely.
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
19
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
20 Detailed Instructions:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
21 ======================
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
22 General syntax: moin [options] xmlrpc remote [remote-options]
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
23
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
24 [options] usually should be:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
25 --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
26
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
27 [remote-options] see below:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
28 0. Verify that you have a remotescriptconf.py configuration file.
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
29
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
30 1. To run the script 'account check' remotely.
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
31 moin ... xmlrpc remote account check
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
32 """
934
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 def __init__(self, argv, def_values):
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 MoinScript.__init__(self, argv, def_values)
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 self.argv = argv
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 def mainloop(self):
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 try:
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 import remotescriptconf as conf
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 except ImportError:
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 fatal("Could not find the file remotescriptconf.py. Maybe you want to use the config param?")
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 secret = conf.remotescript_secret
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 url = conf.remotescript_url
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 print url, secret, self.argv
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 s = xmlrpclib.ServerProxy(url)
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
50 # TODO handle stdin
934
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51 # xmlrpclib.Binary(sys.stdin.read())
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 result = s.RemoteScript(secret, self.argv)
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 # TODO handle stdout, stderr
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 if result != "OK":
2450
3d08f1cb4429 pep8 whitespace fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
56 print >> sys.stderr, result
934
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57