summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2007-09-20 18:46:39 -0400
committerAdrian Likins <alikins@redhat.com>2007-09-20 18:46:39 -0400
commitc52285088c7b1c5744e26ac43e2faf0f1b302585 (patch)
tree82540d9c852a28eab24c473bb180233e3a5b89e5
parentbfc12e218fa56755aa37338c5aa36feee632ed49 (diff)
parent74d7edb0c56505eaf657565a95eb209ea09a3b8f (diff)
downloadthird_party-func-c52285088c7b1c5744e26ac43e2faf0f1b302585.tar.gz
third_party-func-c52285088c7b1c5744e26ac43e2faf0f1b302585.tar.xz
third_party-func-c52285088c7b1c5744e26ac43e2faf0f1b302585.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
-rw-r--r--.gitignore1
-rw-r--r--client/test_func.py1
-rwxr-xr-xmodules/service.py60
-rw-r--r--po/.gitignore1
-rwxr-xr-xserver/config_data.py2
-rwxr-xr-xserver/module_loader.py2
-rwxr-xr-xserver/server.py7
7 files changed, 70 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 1af555f..f5f30f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,5 @@
*.pyo
*.swp
MANIFEST
-po
rpm-build
dist
diff --git a/client/test_func.py b/client/test_func.py
index 21c2009..ede9bbf 100644
--- a/client/test_func.py
+++ b/client/test_func.py
@@ -8,6 +8,7 @@ import xmlrpclib
s = xmlrpclib.ServerProxy("http://127.0.0.1:51234")
print s.test_add(1, 2)
+print s.service_restart("httpd")
diff --git a/modules/service.py b/modules/service.py
new file mode 100755
index 0000000..f0693b0
--- /dev/null
+++ b/modules/service.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+
+## func
+##
+## Copyright 2007, Red Hat, Inc
+## Michael DeHaan <mdehaan@redhat.com>
+##
+## This software may be freely redistributed under the terms of the GNU
+## general public license.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+##
+##
+
+
+from codes import *
+from modules import web_svc
+
+import subprocess
+import os
+
+class Service(web_svc.WebSvc):
+
+ def __init__(self):
+ self.methods = {
+ "service_start" : self.start,
+ "service_stop" : self.stop,
+ "service_restart" : self.restart,
+ "service_reload" : self.reload,
+ "service_status" : self.status
+ }
+ web_svc.WebSvc.__init__(self)
+
+ def __command(self, service_name, command):
+
+ filename = os.path.join("/etc/rc.d/init.d/",service_name)
+ if os.path.exists(filename):
+ return subprocess.call(["/sbin/service", service_name, command])
+ else:
+ raise FuncException("Service not installed: %s" % service_name)
+
+ def start(self, service_name):
+ return self.__command(service_name, "start")
+
+ def stop(self, service_name):
+ return self.__command(service_name, "start")
+
+ def restart(self, service_name):
+ return self.__command(service_name, "restart")
+
+ def reload(self, service_name):
+ return self.__command(service_name, "reload")
+
+ def status(self, service_name):
+ return self.__command(service_name, "status")
+
+methods = Service()
+register_rpc = methods.register_rpc
diff --git a/po/.gitignore b/po/.gitignore
new file mode 100644
index 0000000..1495005
--- /dev/null
+++ b/po/.gitignore
@@ -0,0 +1 @@
+messages.pot
diff --git a/server/config_data.py b/server/config_data.py
index b9a4bc8..7ace8ca 100755
--- a/server/config_data.py
+++ b/server/config_data.py
@@ -35,7 +35,7 @@ class Config:
def read(self):
if not os.path.exists(CONFIG_FILE):
- raise FuncException(comment="Missing %s" % CONFIG_FILE)
+ raise FuncException("Missing %s" % CONFIG_FILE)
cp = ConfigParser.ConfigParser()
diff --git a/server/module_loader.py b/server/module_loader.py
index a18da35..f189623 100755
--- a/server/module_loader.py
+++ b/server/module_loader.py
@@ -47,7 +47,7 @@ def load_modules(blacklist=None):
try:
blip = __import__("modules.%s" % ( modname), globals(), locals(), [modname])
if not hasattr(blip, "register_rpc"):
- errmsg = _("%(module_path)s/%(modname)s module not a proper module")
+ errmsg = _("%(module_path)s%(modname)s module not a proper module")
print errmsg % {'module_path': module_file_path, 'modname':modname}
continue
mods[modname] = blip
diff --git a/server/server.py b/server/server.py
index 6179d86..d6fffd5 100755
--- a/server/server.py
+++ b/server/server.py
@@ -132,6 +132,7 @@ def serve(websvc):
"""
server =FuncXMLRPCServer(('', 51234))
+ server.logRequests = 0 # don't print stuff to console
server.register_instance(websvc)
server.serve_forever()
@@ -155,7 +156,11 @@ def main(argv):
modules = module_loader.load_modules()
print "modules", modules
- websvc = XmlRpcInterface(modules=modules)
+ try:
+ websvc = XmlRpcInterface(modules=modules)
+ except FuncException, e:
+ print >> sys.stderr, 'error: %s' % e
+ sys.exit(1)
if "daemon" in sys.argv or "--daemon" in sys.argv:
utils.daemonize("/var/run/vf_server.pid")