As I was on it here attached another small "improvment" for pyro_wrapper
usage that I think is also "good" : using "pyro" instead of
"shinken.pyro_wrapper" everywhere applicable.
This makes a few lines quite shorter (and some module attribute lookup
(shinken.) removed) and helps a bit readability so.
Jean fyi : it's patched against my previous one..
and this one I tested it (but 2 consecutive Rochefort at this time is a
bit hard ;) )
greg.
diff --git a/shinken/satellite.py b/shinken/satellite.py
index 0c9833e..23bb9dc 100644
--- a/shinken/satellite.py
+++ b/shinken/satellite.py
@@ -40,12 +40,12 @@ import cPickle
import random
try:
- import shinken.pyro_wrapper
+ import shinken.pyro_wrapper as pyro
except ImportError:
print "Shinken require the Python Pyro module. Please install it."
sys.exit(1)
-Pyro = shinken.pyro_wrapper.Pyro
+Pyro = pyro.Pyro
from message import Message
@@ -96,7 +96,7 @@ class IForArbiter(Pyro.core.ObjBase):
s = conf['schedulers'][sched_id]
self.schedulers[sched_id] = s
- uri = shinken.pyro_wrapper.create_uri(s['address'], s['port'], 'Checks')
+ uri = pyro.create_uri(s['address'], s['port'], 'Checks')
self.schedulers[sched_id]['uri'] = uri
if already_got:
@@ -285,7 +285,7 @@ class Satellite(Daemon):
#timeout of 120 s
#and get the running id
try:
- shinken.pyro_wrapper.set_timeout(sched['con'], 5)
+ pyro.set_timeout(sched['con'], 5)
new_run_id = sched['con'].get_running_id()
except (Pyro.errors.ProtocolError,Pyro.errors.NamingError, cPickle.PicklingError, KeyError, Pyro.errors.CommunicationError) , exp:
logger.log("[%s] Scheduler %s is not initilised or got network problem: %s" % (self.name, sched['name'], str(exp)))
@@ -362,7 +362,7 @@ class Satellite(Daemon):
timeout = 1.0
#Arbiter do not already set our have_conf param
while not self.have_conf :
- socks = shinken.pyro_wrapper.get_sockets(self.daemon)
+ socks = pyro.get_sockets(self.daemon)
avant = time.time()
ins,outs,exs = select.select(socks,[],[],timeout) # 'foreign' event loop
@@ -374,7 +374,7 @@ class Satellite(Daemon):
if ins != []:
for sock in socks:
if sock in ins:
- shinken.pyro_wrapper.handleRequests(self.daemon, sock)
+ pyro.handleRequests(self.daemon, sock)
apres = time.time()
diff = apres-avant
timeout = timeout - diff
@@ -393,13 +393,13 @@ class Satellite(Daemon):
#wait, timeout = 0s
#If it send us a new conf, we reinit the connexions of all schedulers
def watch_for_new_conf(self, timeout_daemon):
- socks = shinken.pyro_wrapper.get_sockets(self.daemon)
+ socks = pyro.get_sockets(self.daemon)
ins,outs,exs = select.select(socks,[],[],timeout_daemon)
if ins != []:
for sock in socks:
if sock in ins:
- shinken.pyro_wrapper.handleRequests(self.daemon, sock)
+ pyro.handleRequests(self.daemon, sock)
#have_new_conf is set with put_conf
#so another handle will not make a con_init
@@ -555,7 +555,7 @@ class Satellite(Daemon):
try:
con = sched['con']
if con is not None: #None = not initilized
- shinken.pyro_wrapper.set_timeout(con, 120)
+ pyro.set_timeout(con, 120)
#OK, go for it :)
tmp = con.get_checks(do_checks=do_checks, do_actions=do_actions, poller_tags=self.poller_tags)
print "Ask actions to", sched_id, "got", len(tmp)
@@ -598,15 +598,15 @@ class Satellite(Daemon):
logger.log("Using working directory : %s" % os.path.abspath(self.workdir))
logger.log("Opening port: %s" % self.port)
#Daemon init
- self.daemon = shinken.pyro_wrapper.init_daemon(self.host, self.port)
+ self.daemon = pyro.init_daemon(self.host, self.port)
#Now we create the interfaces
self.interface = IForArbiter(self)
self.brok_interface = IBroks(self)
#And we register them
- self.uri2 = shinken.pyro_wrapper.register(self.daemon, self.interface, "ForArbiter")
- self.uri3 = shinken.pyro_wrapper.register(self.daemon, self.brok_interface, "Broks")
+ self.uri2 = pyro.register(self.daemon, self.interface, "ForArbiter")
+ self.uri3 = pyro.register(self.daemon, self.brok_interface, "Broks")
#We wait for initial conf
self.wait_for_initial_conf()
diff --git a/shinken/satellitelink.py b/shinken/satellitelink.py
index aae9129..423a1a6 100644
--- a/shinken/satellitelink.py
+++ b/shinken/satellitelink.py
@@ -23,8 +23,8 @@
#Arbiter with Conf Dispatcher.
-import shinken.pyro_wrapper
-Pyro = shinken.pyro_wrapper.Pyro
+import shinken.pyro_wrapper as pyro
+Pyro = pyro.Pyro
from shinken.item import Item, Items
@@ -68,9 +68,9 @@ class SatelliteLink(Item):
def create_connexion(self):
- self.uri = shinken.pyro_wrapper.create_uri(self.address, self.port, "ForArbiter")
- self.con = shinken.pyro_wrapper.getProxy(self.uri)
- shinken.pyro_wrapper.set_timeout(self.con, self.timeout)
+ self.uri = pyro.create_uri(self.address, self.port, "ForArbiter")
+ self.con = pyro.getProxy(self.uri)
+ pyro.set_timeout(self.con, self.timeout)
def put_conf(self, conf):
@@ -79,9 +79,9 @@ class SatelliteLink(Item):
#print "Connexion is OK, now we put conf", conf
#print "Try to put conf:", conf
try:
- shinken.pyro_wrapper.set_timeout(self.con, self.data_timeout)
+ pyro.set_timeout(self.con, self.data_timeout)
self.con.put_conf(conf)
- shinken.pyro_wrapper.set_timeout(self.con, self.timeout)
+ pyro.set_timeout(self.con, self.timeout)
return True
except Pyro.errors.URIError , exp:
self.con = None
diff --git a/shinken/scheduler.py b/shinken/scheduler.py
index 50ca0d4..c1a135c 100644
--- a/shinken/scheduler.py
+++ b/shinken/scheduler.py
@@ -21,7 +21,7 @@
import select, time, os
-import shinken.pyro_wrapper
+import shinken.pyro_wrapper as pyro
from shinken.external_command import ExternalCommand
from shinken.check import Check
@@ -815,7 +815,7 @@ class Scheduler:
self.t_each_loop = time.time() #use to track system time change
while self.must_run :
- socks = shinken.pyro_wrapper.get_sockets(self.daemon)
+ socks = pyro.get_sockets(self.daemon)
t_begin = time.time()
#socks.append(self.fifo)
# 'foreign' event loop
@@ -823,7 +823,7 @@ class Scheduler:
if ins != []:
for s in socks:
if s in ins:
- shinken.pyro_wrapper.handleRequests(self.daemon, s)
+ pyro.handleRequests(self.daemon, s)
t_after = time.time()
diff = t_after-t_begin
timeout = timeout - diff
diff --git a/shinken/schedulerlink.py b/shinken/schedulerlink.py
index b8939a1..4a553dc 100644
--- a/shinken/schedulerlink.py
+++ b/shinken/schedulerlink.py
@@ -24,8 +24,8 @@ from shinken.satellitelink import SatelliteLink, SatelliteLinks
from shinken.util import to_int, to_bool, to_split
from shinken.property import UnusedProp, BoolProp, IntegerProp, FloatProp, CharProp, StringProp, ListProp
-import shinken.pyro_wrapper
-Pyro = shinken.pyro_wrapper.Pyro
+from shinken.pyro_wrapper import Pyro
+
class SchedulerLink(SatelliteLink):
id = 0
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel