annotate MoinMoin/script/xmlrpc/remote.py @ 934:9dcfb8f36524

call scripts remotely, ScriptRequest infrastructure (unfinished)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 09 Jul 2006 10:55:43 +0200
parents
children bb2e053067fb
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 """
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - remote command execution, client part
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 This can be used as client to execute moin scripts remotely.
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 @copyright: 2006 by MoinMoin:ThomasWaldmann
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 """
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 import sys
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 import xmlrpclib
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 from MoinMoin.script import MoinScript, fatal
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 class PluginScript(MoinScript):
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 """ Remote Script Execution Client """
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 def __init__(self, argv, def_values):
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 MoinScript.__init__(self, argv, def_values)
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 self.argv = argv
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 def mainloop(self):
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 try:
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 import remotescriptconf as conf
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 except ImportError:
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 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
28
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 secret = conf.remotescript_secret
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 url = conf.remotescript_url
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 print url, secret, self.argv
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 s = xmlrpclib.ServerProxy(url)
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 # TODO handle stdin
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 # xmlrpclib.Binary(sys.stdin.read())
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 result = s.RemoteScript(secret, self.argv)
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 # TODO handle stdout, stderr
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 if result != "OK":
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 print >>sys.stderr, result
9dcfb8f36524 call scripts remotely, ScriptRequest infrastructure (unfinished)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42