tbevent.py 31.7 KB
Newer Older
1
# This file was automatically generated by SWIG (http://www.swig.org).
2
# Version 2.0.12
3 4 5
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
6 7 8 9




10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
from sys import version_info
if version_info >= (2,6,0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_tbevent', [dirname(__file__)])
        except ImportError:
            import _tbevent
            return _tbevent
        if fp is not None:
            try:
                _mod = imp.load_module('_tbevent', fp, pathname, description)
            finally:
                fp.close()
27
            return _mod
28 29 30 31 32 33 34 35 36
    _tbevent = swig_import_helper()
    del swig_import_helper
else:
    import _tbevent
del version_info
try:
    _swig_property = property
except NameError:
    pass # Python < 2.2 doesn't have 'property'.
37 38
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
    if (name == "thisown"): return self.this.own(value)
39
    if (name == "this"):
40
        if type(value).__name__ == 'SwigPyObject':
41
            self.__dict__[name] = value
42 43 44
            return
    method = class_type.__swig_setmethods__.get(name,None)
    if method: return method(self,value)
45
    if (not static):
46 47 48 49 50 51
        self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)

def _swig_setattr(self,class_type,name,value):
    return _swig_setattr_nondynamic(self,class_type,name,value,0)
52 53

def _swig_getattr(self,class_type,name):
54
    if (name == "thisown"): return self.this.own()
55 56
    method = class_type.__swig_getmethods__.get(name,None)
    if method: return method(self)
57
    raise AttributeError(name)
58

59 60 61 62 63
def _swig_repr(self):
    try: strthis = "proxy of " + self.this.__repr__()
    except: strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

64
try:
65
    _object = object
66 67 68 69 70 71
    _newclass = 1
except AttributeError:
    class _object : pass
    _newclass = 0


72
EVENT_LIBRARY_VERSION = _tbevent.EVENT_LIBRARY_VERSION
73 74 75 76 77 78
MAXHOSTNAMELEN = _tbevent.MAXHOSTNAMELEN
class event_handle(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, event_handle, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, event_handle, name)
79
    __repr__ = _swig_repr
80 81
    __swig_setmethods__["server"] = _tbevent.event_handle_server_set
    __swig_getmethods__["server"] = _tbevent.event_handle_server_get
82
    if _newclass:server = _swig_property(_tbevent.event_handle_server_get, _tbevent.event_handle_server_set)
83 84
    __swig_setmethods__["status"] = _tbevent.event_handle_status_set
    __swig_getmethods__["status"] = _tbevent.event_handle_status_get
85
    if _newclass:status = _swig_property(_tbevent.event_handle_status_get, _tbevent.event_handle_status_set)
86 87
    __swig_setmethods__["keydata"] = _tbevent.event_handle_keydata_set
    __swig_getmethods__["keydata"] = _tbevent.event_handle_keydata_get
88
    if _newclass:keydata = _swig_property(_tbevent.event_handle_keydata_get, _tbevent.event_handle_keydata_set)
89 90
    __swig_setmethods__["keylen"] = _tbevent.event_handle_keylen_set
    __swig_getmethods__["keylen"] = _tbevent.event_handle_keylen_get
91
    if _newclass:keylen = _swig_property(_tbevent.event_handle_keylen_get, _tbevent.event_handle_keylen_set)
92 93
    __swig_setmethods__["do_loop"] = _tbevent.event_handle_do_loop_set
    __swig_getmethods__["do_loop"] = _tbevent.event_handle_do_loop_get
94
    if _newclass:do_loop = _swig_property(_tbevent.event_handle_do_loop_get, _tbevent.event_handle_do_loop_set)
95 96
    __swig_setmethods__["connect"] = _tbevent.event_handle_connect_set
    __swig_getmethods__["connect"] = _tbevent.event_handle_connect_get
97
    if _newclass:connect = _swig_property(_tbevent.event_handle_connect_get, _tbevent.event_handle_connect_set)
98 99
    __swig_setmethods__["disconnect"] = _tbevent.event_handle_disconnect_set
    __swig_getmethods__["disconnect"] = _tbevent.event_handle_disconnect_get
100
    if _newclass:disconnect = _swig_property(_tbevent.event_handle_disconnect_get, _tbevent.event_handle_disconnect_set)
101 102
    __swig_setmethods__["mainloop"] = _tbevent.event_handle_mainloop_set
    __swig_getmethods__["mainloop"] = _tbevent.event_handle_mainloop_get
103
    if _newclass:mainloop = _swig_property(_tbevent.event_handle_mainloop_get, _tbevent.event_handle_mainloop_set)
104 105
    __swig_setmethods__["notify"] = _tbevent.event_handle_notify_set
    __swig_getmethods__["notify"] = _tbevent.event_handle_notify_get
106
    if _newclass:notify = _swig_property(_tbevent.event_handle_notify_get, _tbevent.event_handle_notify_set)
107 108
    __swig_setmethods__["subscribe"] = _tbevent.event_handle_subscribe_set
    __swig_getmethods__["subscribe"] = _tbevent.event_handle_subscribe_get
109
    if _newclass:subscribe = _swig_property(_tbevent.event_handle_subscribe_get, _tbevent.event_handle_subscribe_set)
110 111
    __swig_setmethods__["unsubscribe"] = _tbevent.event_handle_unsubscribe_set
    __swig_getmethods__["unsubscribe"] = _tbevent.event_handle_unsubscribe_get
112 113 114
    if _newclass:unsubscribe = _swig_property(_tbevent.event_handle_unsubscribe_get, _tbevent.event_handle_unsubscribe_set)
    def __init__(self): 
        this = _tbevent.new_event_handle()
115 116 117 118 119 120
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _tbevent.delete_event_handle
    __del__ = lambda self : None;
event_handle_swigregister = _tbevent.event_handle_swigregister
event_handle_swigregister(event_handle)
121 122 123 124 125 126

class event_notification(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, event_notification, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, event_notification, name)
127 128 129
    __repr__ = _swig_repr
    __swig_setmethods__["pubsub_notification"] = _tbevent.event_notification_pubsub_notification_set
    __swig_getmethods__["pubsub_notification"] = _tbevent.event_notification_pubsub_notification_get
130
    if _newclass:pubsub_notification = _swig_property(_tbevent.event_notification_pubsub_notification_get, _tbevent.event_notification_pubsub_notification_set)
131 132
    __swig_setmethods__["has_hmac"] = _tbevent.event_notification_has_hmac_set
    __swig_getmethods__["has_hmac"] = _tbevent.event_notification_has_hmac_get
133 134 135
    if _newclass:has_hmac = _swig_property(_tbevent.event_notification_has_hmac_get, _tbevent.event_notification_has_hmac_set)
    def __init__(self): 
        this = _tbevent.new_event_notification()
136 137 138 139 140 141
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _tbevent.delete_event_notification
    __del__ = lambda self : None;
event_notification_swigregister = _tbevent.event_notification_swigregister
event_notification_swigregister(event_notification)
142 143 144 145 146 147

class address_tuple(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, address_tuple, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, address_tuple, name)
148
    __repr__ = _swig_repr
149 150
    __swig_setmethods__["site"] = _tbevent.address_tuple_site_set
    __swig_getmethods__["site"] = _tbevent.address_tuple_site_get
151
    if _newclass:site = _swig_property(_tbevent.address_tuple_site_get, _tbevent.address_tuple_site_set)
152 153
    __swig_setmethods__["expt"] = _tbevent.address_tuple_expt_set
    __swig_getmethods__["expt"] = _tbevent.address_tuple_expt_get
154
    if _newclass:expt = _swig_property(_tbevent.address_tuple_expt_get, _tbevent.address_tuple_expt_set)
155 156
    __swig_setmethods__["group"] = _tbevent.address_tuple_group_set
    __swig_getmethods__["group"] = _tbevent.address_tuple_group_get
157
    if _newclass:group = _swig_property(_tbevent.address_tuple_group_get, _tbevent.address_tuple_group_set)
158 159
    __swig_setmethods__["host"] = _tbevent.address_tuple_host_set
    __swig_getmethods__["host"] = _tbevent.address_tuple_host_get
160
    if _newclass:host = _swig_property(_tbevent.address_tuple_host_get, _tbevent.address_tuple_host_set)
161 162
    __swig_setmethods__["objtype"] = _tbevent.address_tuple_objtype_set
    __swig_getmethods__["objtype"] = _tbevent.address_tuple_objtype_get
163
    if _newclass:objtype = _swig_property(_tbevent.address_tuple_objtype_get, _tbevent.address_tuple_objtype_set)
164 165
    __swig_setmethods__["objname"] = _tbevent.address_tuple_objname_set
    __swig_getmethods__["objname"] = _tbevent.address_tuple_objname_get
166
    if _newclass:objname = _swig_property(_tbevent.address_tuple_objname_get, _tbevent.address_tuple_objname_set)
167 168
    __swig_setmethods__["eventtype"] = _tbevent.address_tuple_eventtype_set
    __swig_getmethods__["eventtype"] = _tbevent.address_tuple_eventtype_get
169
    if _newclass:eventtype = _swig_property(_tbevent.address_tuple_eventtype_get, _tbevent.address_tuple_eventtype_set)
170 171
    __swig_setmethods__["scheduler"] = _tbevent.address_tuple_scheduler_set
    __swig_getmethods__["scheduler"] = _tbevent.address_tuple_scheduler_get
172
    if _newclass:scheduler = _swig_property(_tbevent.address_tuple_scheduler_get, _tbevent.address_tuple_scheduler_set)
173 174
    __swig_setmethods__["timeline"] = _tbevent.address_tuple_timeline_set
    __swig_getmethods__["timeline"] = _tbevent.address_tuple_timeline_get
175 176 177
    if _newclass:timeline = _swig_property(_tbevent.address_tuple_timeline_get, _tbevent.address_tuple_timeline_set)
    def __init__(self): 
        this = _tbevent.new_address_tuple()
178 179 180 181 182 183
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _tbevent.delete_address_tuple
    __del__ = lambda self : None;
address_tuple_swigregister = _tbevent.address_tuple_swigregister
address_tuple_swigregister(address_tuple)
184 185 186 187

ADDRESSTUPLE_ALL = _tbevent.ADDRESSTUPLE_ALL
OBJECTTYPE_TESTBED = _tbevent.OBJECTTYPE_TESTBED
OBJECTTYPE_TRAFGEN = _tbevent.OBJECTTYPE_TRAFGEN
188 189 190

def address_tuple_alloc():
  return _tbevent.address_tuple_alloc()
191
address_tuple_alloc = _tbevent.address_tuple_alloc
192 193 194

def address_tuple_free(*args):
  return _tbevent.address_tuple_free(*args)
195 196 197 198 199 200 201
address_tuple_free = _tbevent.address_tuple_free
EVENT_HOST_ANY = _tbevent.EVENT_HOST_ANY
EVENT_NULL = _tbevent.EVENT_NULL
EVENT_TEST = _tbevent.EVENT_TEST
EVENT_SCHEDULE = _tbevent.EVENT_SCHEDULE
EVENT_TRAFGEN_START = _tbevent.EVENT_TRAFGEN_START
EVENT_TRAFGEN_STOP = _tbevent.EVENT_TRAFGEN_STOP
202 203 204

def event_register(*args):
  return _tbevent.event_register(*args)
205
event_register = _tbevent.event_register
206 207 208

def event_register_withkeyfile(*args):
  return _tbevent.event_register_withkeyfile(*args)
209
event_register_withkeyfile = _tbevent.event_register_withkeyfile
210 211 212

def event_register_withkeydata(*args):
  return _tbevent.event_register_withkeydata(*args)
213
event_register_withkeydata = _tbevent.event_register_withkeydata
214 215 216

def event_register_withkeyfile_withretry(*args):
  return _tbevent.event_register_withkeyfile_withretry(*args)
217
event_register_withkeyfile_withretry = _tbevent.event_register_withkeyfile_withretry
218 219 220

def event_register_withkeydata_withretry(*args):
  return _tbevent.event_register_withkeydata_withretry(*args)
221
event_register_withkeydata_withretry = _tbevent.event_register_withkeydata_withretry
222 223 224

def event_unregister(*args):
  return _tbevent.event_unregister(*args)
225
event_unregister = _tbevent.event_unregister
226 227 228

def c_event_poll(*args):
  return _tbevent.c_event_poll(*args)
229
c_event_poll = _tbevent.c_event_poll
230 231 232

def c_event_poll_blocking(*args):
  return _tbevent.c_event_poll_blocking(*args)
233
c_event_poll_blocking = _tbevent.c_event_poll_blocking
234 235 236

def dont_use_this_function_because_it_does_not_work(*args):
  return _tbevent.dont_use_this_function_because_it_does_not_work(*args)
237
dont_use_this_function_because_it_does_not_work = _tbevent.dont_use_this_function_because_it_does_not_work
238 239 240

def event_stop_main(*args):
  return _tbevent.event_stop_main(*args)
241
event_stop_main = _tbevent.event_stop_main
242 243 244

def event_notify(*args):
  return _tbevent.event_notify(*args)
245
event_notify = _tbevent.event_notify
246 247 248

def event_schedule(*args):
  return _tbevent.event_schedule(*args)
249
event_schedule = _tbevent.event_schedule
250 251 252

def event_notification_alloc(*args):
  return _tbevent.event_notification_alloc(*args)
253
event_notification_alloc = _tbevent.event_notification_alloc
254 255 256

def event_notification_free(*args):
  return _tbevent.event_notification_free(*args)
257
event_notification_free = _tbevent.event_notification_free
258 259 260

def event_notification_clone(*args):
  return _tbevent.event_notification_clone(*args)
261
event_notification_clone = _tbevent.event_notification_clone
262 263 264

def event_notification_get_double(*args):
  return _tbevent.event_notification_get_double(*args)
265
event_notification_get_double = _tbevent.event_notification_get_double
266 267 268

def event_notification_get_int32(*args):
  return _tbevent.event_notification_get_int32(*args)
269
event_notification_get_int32 = _tbevent.event_notification_get_int32
270 271 272

def event_notification_get_int64(*args):
  return _tbevent.event_notification_get_int64(*args)
273
event_notification_get_int64 = _tbevent.event_notification_get_int64
274 275 276 277 278 279 280 281 282 283 284

def event_notification_get_opaque_length(*args):
  return _tbevent.event_notification_get_opaque_length(*args)
event_notification_get_opaque_length = _tbevent.event_notification_get_opaque_length

def event_notification_get_string_length(*args):
  return _tbevent.event_notification_get_string_length(*args)
event_notification_get_string_length = _tbevent.event_notification_get_string_length

def event_notification_get_opaque(*args):
  return _tbevent.event_notification_get_opaque(*args)
285
event_notification_get_opaque = _tbevent.event_notification_get_opaque
286 287 288

def c_event_notification_get_string(*args):
  return _tbevent.c_event_notification_get_string(*args)
289
c_event_notification_get_string = _tbevent.c_event_notification_get_string
290 291 292

def event_notification_put_double(*args):
  return _tbevent.event_notification_put_double(*args)
293
event_notification_put_double = _tbevent.event_notification_put_double
294 295 296

def event_notification_put_int32(*args):
  return _tbevent.event_notification_put_int32(*args)
297
event_notification_put_int32 = _tbevent.event_notification_put_int32
298 299 300

def event_notification_put_int64(*args):
  return _tbevent.event_notification_put_int64(*args)
301
event_notification_put_int64 = _tbevent.event_notification_put_int64
302 303 304

def event_notification_put_opaque(*args):
  return _tbevent.event_notification_put_opaque(*args)
305
event_notification_put_opaque = _tbevent.event_notification_put_opaque
306 307 308

def event_notification_put_string(*args):
  return _tbevent.event_notification_put_string(*args)
309
event_notification_put_string = _tbevent.event_notification_put_string
310 311 312

def event_notification_remove(*args):
  return _tbevent.event_notification_remove(*args)
313
event_notification_remove = _tbevent.event_notification_remove
314 315 316

def c_event_subscribe(*args):
  return _tbevent.c_event_subscribe(*args)
317
c_event_subscribe = _tbevent.c_event_subscribe
318 319 320

def event_subscribe_auth(*args):
  return _tbevent.event_subscribe_auth(*args)
321
event_subscribe_auth = _tbevent.event_subscribe_auth
322 323 324

def event_async_subscribe(*args):
  return _tbevent.event_async_subscribe(*args)
325
event_async_subscribe = _tbevent.event_async_subscribe
326 327 328

def event_unsubscribe(*args):
  return _tbevent.event_unsubscribe(*args)
329
event_unsubscribe = _tbevent.event_unsubscribe
330 331 332

def event_async_unsubscribe(*args):
  return _tbevent.event_async_unsubscribe(*args)
333
event_async_unsubscribe = _tbevent.event_async_unsubscribe
334 335 336

def event_notification_insert_hmac(*args):
  return _tbevent.event_notification_insert_hmac(*args)
337
event_notification_insert_hmac = _tbevent.event_notification_insert_hmac
338 339 340

def event_set_idle_period(*args):
  return _tbevent.event_set_idle_period(*args)
341
event_set_idle_period = _tbevent.event_set_idle_period
342 343 344

def event_set_failover(*args):
  return _tbevent.event_set_failover(*args)
345
event_set_failover = _tbevent.event_set_failover
346 347 348

def event_arg_get(*args):
  return _tbevent.event_arg_get(*args)
349
event_arg_get = _tbevent.event_arg_get
350 351 352

def event_arg_dup(*args):
  return _tbevent.event_arg_dup(*args)
353 354 355 356 357 358 359 360 361 362 363 364 365 366
event_arg_dup = _tbevent.event_arg_dup
EA_TAG_DONE = _tbevent.EA_TAG_DONE
EA_Site = _tbevent.EA_Site
EA_Experiment = _tbevent.EA_Experiment
EA_Group = _tbevent.EA_Group
EA_Host = _tbevent.EA_Host
EA_Type = _tbevent.EA_Type
EA_Name = _tbevent.EA_Name
EA_Event = _tbevent.EA_Event
EA_Arguments = _tbevent.EA_Arguments
EA_ArgInteger = _tbevent.EA_ArgInteger
EA_ArgFloat = _tbevent.EA_ArgFloat
EA_ArgString = _tbevent.EA_ArgString
EA_When = _tbevent.EA_When
367 368 369

def event_notification_create_v(*args):
  return _tbevent.event_notification_create_v(*args)
370
event_notification_create_v = _tbevent.event_notification_create_v
371 372 373

def event_notification_create(*args):
  return _tbevent.event_notification_create(*args)
374
event_notification_create = _tbevent.event_notification_create
375 376 377

def event_do_v(*args):
  return _tbevent.event_do_v(*args)
378
event_do_v = _tbevent.event_do_v
379 380 381

def event_do(*args):
  return _tbevent.event_do(*args)
382
event_do = _tbevent.event_do
383 384 385

def xmalloc(*args):
  return _tbevent.xmalloc(*args)
386
xmalloc = _tbevent.xmalloc
387 388 389

def xrealloc(*args):
  return _tbevent.xrealloc(*args)
390
xrealloc = _tbevent.xrealloc
391 392 393

def make_timestamp(*args):
  return _tbevent.make_timestamp(*args)
394
make_timestamp = _tbevent.make_timestamp
395 396 397 398 399
class timeval(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, timeval, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, timeval, name)
400
    __repr__ = _swig_repr
401 402
    __swig_setmethods__["tv_sec"] = _tbevent.timeval_tv_sec_set
    __swig_getmethods__["tv_sec"] = _tbevent.timeval_tv_sec_get
403
    if _newclass:tv_sec = _swig_property(_tbevent.timeval_tv_sec_get, _tbevent.timeval_tv_sec_set)
404 405
    __swig_setmethods__["tv_usec"] = _tbevent.timeval_tv_usec_set
    __swig_getmethods__["tv_usec"] = _tbevent.timeval_tv_usec_get
406 407 408
    if _newclass:tv_usec = _swig_property(_tbevent.timeval_tv_usec_get, _tbevent.timeval_tv_usec_set)
    def __init__(self): 
        this = _tbevent.new_timeval()
409 410 411 412 413 414
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _tbevent.delete_timeval
    __del__ = lambda self : None;
timeval_swigregister = _tbevent.timeval_swigregister
timeval_swigregister(timeval)
415

416 417 418 419 420
class callback_data(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, callback_data, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, callback_data, name)
421
    __repr__ = _swig_repr
422 423
    __swig_setmethods__["callback_notification"] = _tbevent.callback_data_callback_notification_set
    __swig_getmethods__["callback_notification"] = _tbevent.callback_data_callback_notification_get
424
    if _newclass:callback_notification = _swig_property(_tbevent.callback_data_callback_notification_get, _tbevent.callback_data_callback_notification_set)
425 426
    __swig_setmethods__["next"] = _tbevent.callback_data_next_set
    __swig_getmethods__["next"] = _tbevent.callback_data_next_get
427 428 429
    if _newclass:next = _swig_property(_tbevent.callback_data_next_get, _tbevent.callback_data_next_set)
    def __init__(self): 
        this = _tbevent.new_callback_data()
430 431 432 433 434 435
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _tbevent.delete_callback_data
    __del__ = lambda self : None;
callback_data_swigregister = _tbevent.callback_data_swigregister
callback_data_swigregister(callback_data)
436

437 438 439

def allocate_callback_data():
  return _tbevent.allocate_callback_data()
440
allocate_callback_data = _tbevent.allocate_callback_data
441 442 443

def free_callback_data(*args):
  return _tbevent.free_callback_data(*args)
444
free_callback_data = _tbevent.free_callback_data
445 446 447

def dequeue_callback_data():
  return _tbevent.dequeue_callback_data()
448
dequeue_callback_data = _tbevent.dequeue_callback_data
449 450 451

def enqueue_callback_data(*args):
  return _tbevent.enqueue_callback_data(*args)
452
enqueue_callback_data = _tbevent.enqueue_callback_data
453 454 455

def perl_stub_callback(*args):
  return _tbevent.perl_stub_callback(*args)
456
perl_stub_callback = _tbevent.perl_stub_callback
457 458 459

def stub_event_subscribe(*args):
  return _tbevent.stub_event_subscribe(*args)
460
stub_event_subscribe = _tbevent.stub_event_subscribe
461 462 463

def event_notification_get_string(*args):
  return _tbevent.event_notification_get_string(*args)
464
event_notification_get_string = _tbevent.event_notification_get_string
465 466 467

def event_notification_get_site(*args):
  return _tbevent.event_notification_get_site(*args)
468
event_notification_get_site = _tbevent.event_notification_get_site
469 470 471

def event_notification_get_expt(*args):
  return _tbevent.event_notification_get_expt(*args)
472
event_notification_get_expt = _tbevent.event_notification_get_expt
473 474 475

def event_notification_get_group(*args):
  return _tbevent.event_notification_get_group(*args)
476
event_notification_get_group = _tbevent.event_notification_get_group
477 478 479

def event_notification_get_host(*args):
  return _tbevent.event_notification_get_host(*args)
480
event_notification_get_host = _tbevent.event_notification_get_host
481 482 483

def event_notification_get_objtype(*args):
  return _tbevent.event_notification_get_objtype(*args)
484
event_notification_get_objtype = _tbevent.event_notification_get_objtype
485 486 487

def event_notification_get_objname(*args):
  return _tbevent.event_notification_get_objname(*args)
488
event_notification_get_objname = _tbevent.event_notification_get_objname
489 490 491

def event_notification_get_eventtype(*args):
  return _tbevent.event_notification_get_eventtype(*args)
492
event_notification_get_eventtype = _tbevent.event_notification_get_eventtype
493 494 495

def event_notification_get_arguments(*args):
  return _tbevent.event_notification_get_arguments(*args)
496
event_notification_get_arguments = _tbevent.event_notification_get_arguments
497 498 499

def event_notification_set_arguments(*args):
  return _tbevent.event_notification_set_arguments(*args)
500
event_notification_set_arguments = _tbevent.event_notification_set_arguments
501 502 503

def event_notification_get_sender(*args):
  return _tbevent.event_notification_get_sender(*args)
504
event_notification_get_sender = _tbevent.event_notification_get_sender
505 506 507

def event_notification_set_sender(*args):
  return _tbevent.event_notification_set_sender(*args)
508
event_notification_set_sender = _tbevent.event_notification_set_sender
509
# This file is compatible with both classic and new-style classes.
510

511 512 513 514 515 516
cvar = _tbevent.cvar

# -*- python -*-
#
# CODE PAST THIS POINT WAS NOT AUTOMATICALLY GENERATED BY SWIG
#
517 518
#
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
538
#
539 540 541 542 543
# For now, this has to get cat'ed onto the end of tbevent.py, since it
# doesn't seem possible to get SWIG to just pass it through into the
# output file
#

544
import sys
545 546 547 548 549 550 551 552 553 554 555 556
import time

class NotificationWrapper:
    """
    Wrapper class for event_notification structures.  Mostly just adds setter
    and getter methods.
    """

    def __init__(self, handle, notification):
        """
        Construct a NotificationWrapper that wraps the given objects.
        
Timothy Stack's avatar
Timothy Stack committed
557 558
        @param handle The event_handle used to create notification.
        @param notification The event_notification structure to wrap.
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
        """
        self.handle = handle
        self.notification = notification
        return

    def __del__(self):
        """
        Deconstruct the object by free'ing the wrapped notification.
        """
        event_notification_free(self.handle, self.notification)
        return

    # For the rest of these, consult the C header file, event.h.

    def getSite(self):
        return event_notification_get_site(self.handle, self.notification)

    def getExpt(self):
        return event_notification_get_expt(self.handle, self.notification)

    def getGroup(self):
        return event_notification_get_group(self.handle, self.notification)

    def getHost(self):
        return event_notification_get_host(self.handle, self.notification)

    def getObjType(self):
        return event_notification_get_objtype(self.handle, self.notification)

    def getObjName(self):
        return event_notification_get_objname(self.handle, self.notification)

    def getEventType(self):
        return event_notification_get_eventtype(self.handle, self.notification)

    def getArguments(self):
        return event_notification_get_arguments(self.handle, self.notification)

    def setArguments(self, args):
        return event_notification_set_arguments(self.handle,
                                                self.notification,
                                                args)

602 603 604
    def getTimeline(self, args):
        return event_notification_get_timeline(self.handle, self.notification)

605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
    def getSender(self):
        return event_notification_get_sender(self.handle, self.notification)

    def setSender(self, sender):
        return event_notification_set_sender(self.handle,
                                             self.notification,
                                             sender)

    pass


class CallbackIterator:
    """
    Python iterator for the callback list created by the SWIG stubs.
    """

    def __init__(self, handle):
        """
        Construct an iterator with the given arguments.

Timothy Stack's avatar
Timothy Stack committed
625
        @param handle The event_handle being polled.
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
        """
        self.last = None
        self.handle = handle
        return

    def __del__(self):
        """
        Deconstruct the iterator.
        """
        if self.last:
            free_callback_data(self.last)
            self.last = None
            pass
        return

    def __iter__(self):
        return self

    def next(self):
        """
        Return the next object in the sequence or raise StopIteration if there
        are no more.  The returned object is a wrapped notification.
        """
        if self.last:
            free_callback_data(self.last)
            self.last = None
            pass
        self.last = dequeue_callback_data()
        if not self.last:
            raise StopIteration
        
        return NotificationWrapper(self.handle,
                                   self.last.callback_notification)

    pass


663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
class EventError:
    """
    Base class for event related exceptions.
    """
    def __init__(self, code):
        self.args = code,
        return
    
    pass


class EventTimedOutError(EventError):
    """
    Exception raised when the run() method of EventClient timed out.
    """
    def __init__(self, timeout):
        self.args = timeout,
        return
    
    pass


# Ugh, elvin likes to crash if we unregister all of the handles, so we keep
# a dummy one around just to keep things happy.
_hack_handle = None

689 690 691 692
class EventClient:
    """
    Event client class, mostly just wraps the SWIG'd versions of the functions.
    """
693
    
694
    def __init__(self, server=None, port=None, url=None, keyfile=None):
695 696 697
        """
        Construct an EventClient object.

Timothy Stack's avatar
Timothy Stack committed
698 699 700
        @param url The server name in url'ish form (e.g. elvin://boss)
        @param server The name of the server.
        @param port The server port number.
701
        """
702 703
        global _hack_handle
        
704 705 706 707 708 709 710 711 712 713
        if url:
            if not url.startswith("elvin:"):
                raise ValueError, "malformed url: " + url
            pass
        else:
            if not server:
                raise ValueError, "url or server must be given"
            url = "elvin://" + server
            if port and len(port) > 0:
                url = url + ":" + port
714
                pass
715
            pass
716 717 718 719 720 721 722 723

        if keyfile:
            self.handle = event_register_withkeyfile(url, 0, keyfile)
            pass
        else:
            self.handle = event_register(url, 0)
            pass
        
724 725 726 727 728 729 730 731 732
        self.timeout = 0
        
        if not _hack_handle:
            # Open a handle for the sole purpose of keeping the event library
            # from calling the elvin cleanup function, because elvin likes to
            # segfault when it has been init'd/clean'd multiple times.
            _hack_handle = event_register(url, 0)
            pass
        
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
        return

    def __del__(self):
        """
        Deconstruct this object by disconnecting from the server.
        """
        event_unregister(self.handle)
        self.handle = None
        return

    def _callbacks(self):
        """
        Return an iterator that traverses the list of callbacks generated by
        the SWIG wrapper.
        """
        return CallbackIterator(self.handle)

    def handle_event(self, ev):
        """
        Default implementation of the event handling method.  Should be
        overridden by subclasses.
754 755

        @return None to continue processing events, any other value to stop.
756
        """
757
        return None
758 759 760 761 762

    def subscribe(self, tuple):
        """
        Subscribe to some events.

Timothy Stack's avatar
Timothy Stack committed
763
        @param tuple The address tuple describing the subscription.
764 765 766 767 768
        """
        return stub_event_subscribe(self.handle, tuple.this)

    def create_notification(self, tuple):
        """
Timothy Stack's avatar
Timothy Stack committed
769
        @return A notification that is bound to this client.
770 771 772 773 774 775 776 777 778 779 780
        """
        return NotificationWrapper(self.handle,
                                   event_notification_alloc(self.handle,
                                                            tuple.this))

    def notify(self, en):
        """
        Send a notification.
        """
        return event_notify(self.handle, en.notification)

781 782 783 784 785 786
    def schedule(self, en, tv):
        """
        Schedule a notification.
        """
        return event_schedule(self.handle, en.notification, tv)

787 788 789 790 791 792 793
    def set_timeout(self, timeout):
        """
        @param timeout The timeout, in seconds, for the run() loop.
        """
        self.timeout = timeout * 1000
        return

794 795 796
    def run(self):
        """
        Main loop used to wait for and process events.
797 798

        @return The not None value returned by handle_event.
799
        """
800 801 802
        retval = None
        while not retval:
            rc = c_event_poll_blocking(self.handle, self.timeout)
803 804
            if rc != 0:
                sys.stderr.write("c_event_poll_blocking: " + str(rc) + "\n")
805
                raise EventError, rc
806 807
            else:
                for ev in self._callbacks():
808 809 810 811 812 813 814 815 816 817 818 819 820 821
                    retval = self.handle_event(ev)
                    if retval:
                        # Not None return value, stop the bus.
                        break
                    pass
                else:
                    if self.timeout != 0:
                        # We're making a bit of an assumption here that no
                        # callbacks means a timeout occurred, oh well.
                        raise EventTimedOutError, self.timeout
                    pass
                
                if not retval:
                    time.sleep(0.1) # Forcefully slow down the poll.
822 823 824
                    pass
                pass
            pass
825
        return retval
826

827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846
    def poll(self):
        """
        Polling interface; returns events to caller, one at a time.
        """

        while True:
            try:
                #
                # First see if anything not yet delivered.
                #
                ev = CallbackIterator(self.handle).next()
                return ev;
            except StopIteration, e:
                pass
            
            rc = c_event_poll_blocking(self.handle, 0)        
            if rc != 0:
                sys.stderr.write("c_event_poll_blocking: " + str(rc) + "\n")
                raise IOError, "Reading events"
            pass
847 848
    pass