Back to index

moin  1.9.0~rc2
remote.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003 MoinMoin - remote command execution, client part
00004 
00005 @copyright: 2006 MoinMoin:ThomasWaldmann
00006 @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 import sys
00010 import xmlrpclib
00011 
00012 from MoinMoin.script import MoinScript, fatal
00013 
00014 class PluginScript(MoinScript):
00015     """\
00016 Purpose:
00017 ========
00018 This tool allows you to execute moin scripts remotely.
00019 
00020 Detailed Instructions:
00021 ======================
00022 General syntax: moin [options] xmlrpc remote [remote-options]
00023 
00024 [options] usually should be:
00025     --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/
00026 
00027 [remote-options] see below:
00028     0. Verify that you have a remotescriptconf.py configuration file.
00029 
00030     1. To run the script 'account check' remotely.
00031        moin ... xmlrpc remote account check
00032 """
00033 
00034     def __init__(self, argv, def_values):
00035         MoinScript.__init__(self, argv, def_values)
00036         self.argv = argv
00037 
00038     def mainloop(self):
00039         try:
00040             import remotescriptconf as conf
00041         except ImportError:
00042             fatal("Could not find the file remotescriptconf.py. Maybe you want to use the config param?")
00043 
00044         secret = conf.remotescript_secret
00045         url = conf.remotescript_url
00046         print url, secret, self.argv
00047 
00048         s = xmlrpclib.ServerProxy(url)
00049 
00050         # TODO handle stdin
00051         # xmlrpclib.Binary(sys.stdin.read())
00052         result = s.RemoteScript(secret, self.argv)
00053         # TODO handle stdout, stderr
00054 
00055         if result != "OK":
00056             print >> sys.stderr, result
00057