#! /usr/bin/env python 
import sys
import socket
import os
import SimpleXMLRPCServer
import gobject
from wizbit import ServicePublisher, ServiceBrowser

WIZBIT_SERVER_PORT = 3492

from wizbit import Shares, Directory
from wizbit import *

class WizbitServer():
	def getShares(self):
		shares = Shares.getShares()
		return shares
	
	def getPath(self, uuid):
		shares = Shares.getShares()
		for id, shareId, directory in shares:
			if uuid == id:
				break
		return directory

	def getLastConfSeen(self, uuid):
		return "Not Implemented"

	def setConf(self, uuid, confstring):
		return "Not Implemented"

	def getConf(self, uuid):
		shares = Shares.getShares()
		for id, shareId, directory in shares:
			if uuid == id:
				break
		wizpath = Paths(directory)
		file = open(wizpath.getWizconf(), "r")
		conf = file.read()
		file.close()
		return conf

	def pushNotify(self, dirId, remoteShareId, host):
		#For every local directory with the same shareId, pull 
		#from the remote directory
		shares = Shares.getShares()
		for id, localShareId, directory in shares:
			if localShareId == remoteShareId:
				Directory.pull(directory, dirId, host)

def server_socket_error():
	print "RPC server socket was disconnected, exiting"
	global main_loop
	main_loop.quit()

def server_callback(source, cb_condition, server):
    server.handle_request()

def main(args):
	servinst = WizbitServer()
	server = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 0))
	server.register_instance(servinst)
	server.register_introspection_functions()
	gobject.io_add_watch (server.fileno(), gobject.IO_IN, server_callback, server)
	gobject.io_add_watch (server.fileno(), gobject.IO_HUP | gobject.IO_ERR, server_socket_error)

	sp = ServicePublisher("Wizbit", "_wizbit._tcp", server.server_address[1])
	sb = ServiceBrowser("_wizbit._tcp")

	global main_loop
	main_loop = gobject.MainLoop()

	try:
		main_loop.run()
	except KeyboardInterrupt:
		pass

if __name__ == '__main__':
	sys.exit(main(sys.argv))

#! /usr/bin/env python 
import sys
import socket
import os
import SimpleXMLRPCServer
import gobject
from wizbit import ServicePublisher, ServiceBrowser

WIZBIT_SERVER_PORT = 3492

from wizbit import Shares, Directory
from wizbit import *

class WizbitServer():
	def getShares(self):
		shares = Shares.getShares()
		return shares
	
	def getPath(self, uuid):
		shares = Shares.getShares()
		for id, shareId, directory in shares:
			if uuid == id:
				break
		return directory

	def getLastConfSeen(self, uuid):
		return "Not Implemented"

	def setConf(self, uuid, confstring):
		return "Not Implemented"

	def getConf(self, uuid):
		shares = Shares.getShares()
		for id, shareId, directory in shares:
			if uuid == id:
				break
		wizpath = Paths(directory)
		file = open(wizpath.getWizconf(), "r")
		conf = file.read()
		file.close()
		return conf

	def pushNotify(self, dirId, remoteShareId, host):
		#For every local directory with the same shareId, pull 
		#from the remote directory
		shares = Shares.getShares()
		for id, localShareId, directory in shares:
			if localShareId == remoteShareId:
				Directory.pull(directory, dirId, host)

def server_socket_error():
	print "RPC server socket was disconnected, exiting"
	global main_loop
	main_loop.quit()

def server_callback(source, cb_condition, server):
    server.handle_request()


def start_wizbit_server():
	servinst = WizbitServer()
	server = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 0))
	server.register_instance(servinst)
	server.register_introspection_functions()
	gobject.io_add_watch (server.fileno(), gobject.IO_IN, server_callback, server)
	gobject.io_add_watch (server.fileno(), gobject.IO_HUP | gobject.IO_ERR, server_socket_error)

	sp = ServicePublisher("Wizbit", "_wizbit._tcp", server.server_address[1])
	sb = ServiceBrowser("_wizbit._tcp")


def main(args):
	global main_loop

        start_wizbit_server()

	main_loop = gobject.MainLoop()

	try:
		main_loop.run()
	except KeyboardInterrupt:
		pass

if __name__ == '__main__':
	sys.exit(main(sys.argv))

Add start_wizbit_server function that registers and publishes a wizbit server.