@@ -61,7 +61,7 @@ class EPPResponseEmptyError(Exception):
61
61
62
62
class EPPConnection :
63
63
64
- def __init__ (self , host , port , user , password , verbose = False , raise_errors = False ):
64
+ def __init__ (self , host , port , user , password , verbose = False , raise_errors = False , return_soup = None ):
65
65
self .host = host
66
66
self .port = int (port )
67
67
self .user = user
@@ -72,6 +72,7 @@ def __init__(self, host, port, user, password, verbose=False, raise_errors=False
72
72
self .format_32 = get_format_32 ()
73
73
self .verbose = verbose
74
74
self .raise_errors = raise_errors
75
+ self .return_soup = return_soup
75
76
76
77
def open (self , timeout = 10 ):
77
78
self .socket = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
@@ -175,15 +176,15 @@ def write(self, xml):
175
176
return None
176
177
return ret
177
178
178
- def call (self , cmd , soup = False ):
179
+ def call (self , cmd , soup = None ):
179
180
if self .write (cmd ):
180
181
if self .verbose :
181
182
logger .debug ('sent %d bytes:\n %s\n ' , len (cmd ), cmd )
182
183
raw = self .read ()
183
184
if raw :
184
185
if self .verbose :
185
186
logger .debug ('received %d bytes:\n %s' , len (raw ), raw .decode ())
186
- if soup :
187
+ if soup is True or ( self . return_soup is True and soup is not False ) :
187
188
try :
188
189
soup = BeautifulSoup (raw , "lxml" )
189
190
result = soup .find ('result' )
@@ -218,79 +219,81 @@ def greeting(self):
218
219
logger .debug ('connected to %s (v%s)' , svid , self .version )
219
220
return greeting_response
220
221
221
- def login (self ):
222
+ def login (self , ** kwargs ):
222
223
if self .verbose :
223
224
logger .debug ('attempt to login with: %r' , self .user )
225
+ kwargs ['soup' ] = False
224
226
login_response = self .call (cmd = commands .login % dict (
225
227
user = self .user ,
226
228
password = self .password ,
227
- ))
229
+ ), ** kwargs )
228
230
soup = BeautifulSoup (login_response , "lxml" )
229
231
result = soup .find ('result' )
230
232
code = int (result .get ('code' ))
231
233
if code != 1000 :
232
234
raise Exception ('login response code: %r' % code )
233
235
return True
234
236
235
- def logout (self ):
236
- logout_response = self .call (cmd = commands .logout )
237
+ def logout (self , ** kwargs ):
238
+ kwargs ['soup' ] = False
239
+ logout_response = self .call (cmd = commands .logout , ** kwargs )
237
240
soup = BeautifulSoup (logout_response , "lxml" )
238
241
result = soup .find ('result' )
239
242
code = int (result .get ('code' ))
240
243
if code not in [1000 , 1300 , 1500 , ]:
241
244
raise Exception ('logout response code: %r' % code )
242
245
return True
243
246
244
- def poll_req (self ):
247
+ def poll_req (self , ** kwargs ):
245
248
return self .call (cmd = commands .poll % dict (
246
249
cltrid = make_cltrid (),
247
- ))
250
+ ), ** kwargs )
248
251
249
- def poll_ack (self , msg_id ):
252
+ def poll_ack (self , msg_id , ** kwargs ):
250
253
return self .call (cmd = commands .poll_ack % dict (
251
254
cltrid = make_cltrid (),
252
255
msgid = msg_id ,
253
- ))
256
+ ), ** kwargs )
254
257
255
- def host_check (self , nameservers_list ):
258
+ def host_check (self , nameservers_list , ** kwargs ):
256
259
return self .call (cmd = commands .nameserver .check % dict (
257
260
cltrid = make_cltrid (),
258
261
nameservers = '\n ' .join ([commands .nameserver .single % ns for ns in nameservers_list ]),
259
- ))
262
+ ), ** kwargs )
260
263
261
- def host_info (self , nameserver ):
264
+ def host_info (self , nameserver , ** kwargs ):
262
265
return self .call (cmd = commands .nameserver .info % dict (
263
266
cltrid = make_cltrid (),
264
267
nameserver = nameserver ,
265
- ))
268
+ ), ** kwargs )
266
269
267
- def host_create (self , nameserver , ip_addresses_list ):
270
+ def host_create (self , nameserver , ip_addresses_list , ** kwargs ):
268
271
return self .call (cmd = commands .nameserver .create % dict (
269
272
cltrid = make_cltrid (),
270
273
nameserver = nameserver ,
271
274
ip_addresses = '\n ' .join ([commands .nameserver .ip_address % ipaddr for ipaddr in ip_addresses_list ])
272
- ))
275
+ ), ** kwargs )
273
276
274
- def contact_check (self , contact ):
277
+ def contact_check (self , contact , ** kwargs ):
275
278
return self .call (cmd = commands .contact .check % dict (
276
279
cltrid = make_cltrid (),
277
280
contacts = commands .contact .single % contact ,
278
- ))
281
+ ), ** kwargs )
279
282
280
- def contact_check_multiple (self , contacts_list ):
283
+ def contact_check_multiple (self , contacts_list , ** kwargs ):
281
284
return self .call (cmd = commands .contact .check % dict (
282
285
cltrid = make_cltrid (),
283
286
contacts = '\n ' .join ([commands .contact .single % c for c in contacts_list ]),
284
- ))
287
+ ), ** kwargs )
285
288
286
- def contact_info (self , contact_id , auth_info = None ):
289
+ def contact_info (self , contact_id , auth_info = None , ** kwargs ):
287
290
return self .call (cmd = commands .contact .info % dict (
288
291
cltrid = make_cltrid (),
289
292
contact_id = contact_id ,
290
293
auth_info = '' if not auth_info else commands .contact .auth_info % auth_info ,
291
- ))
294
+ ), ** kwargs )
292
295
293
- def contact_create (self , contact_id , voice = None , fax = None , email = None , contacts = [], auth_info = None ):
296
+ def contact_create (self , contact_id , voice = None , fax = None , email = None , contacts = [], auth_info = None , ** kwargs ):
294
297
return self .call (cmd = commands .contact .create % dict (
295
298
cltrid = make_cltrid (),
296
299
contact_id = contact_id ,
@@ -317,9 +320,9 @@ def contact_create(self, contact_id, voice=None, fax=None, email=None, contacts=
317
320
) for cont in contacts
318
321
]),
319
322
auth_info = '' if not auth_info else commands .contact .auth_info % auth_info ,
320
- ))
323
+ ), ** kwargs )
321
324
322
- def contact_update (self , contact_id , voice = None , fax = None , email = None , contacts = [], auth_info = None ):
325
+ def contact_update (self , contact_id , voice = None , fax = None , email = None , contacts = [], auth_info = None , ** kwargs ):
323
326
return self .call (cmd = commands .contact .update % dict (
324
327
cltrid = make_cltrid (),
325
328
contact_id = contact_id ,
@@ -346,37 +349,37 @@ def contact_update(self, contact_id, voice=None, fax=None, email=None, contacts=
346
349
) for cont in contacts
347
350
]),
348
351
auth_info = '' if not auth_info else commands .contact .auth_info % auth_info ,
349
- ))
352
+ ), ** kwargs )
350
353
351
- def contact_delete (self , contact_id ):
354
+ def contact_delete (self , contact_id , ** kwargs ):
352
355
return self .call (cmd = commands .contact .delete % dict (
353
356
cltrid = make_cltrid (),
354
357
contact_id = contact_id ,
355
- ))
358
+ ), ** kwargs )
356
359
357
- def domain_check (self , domain_name ):
360
+ def domain_check (self , domain_name , ** kwargs ):
358
361
return self .call (cmd = commands .domain .check % dict (
359
362
cltrid = make_cltrid (),
360
363
domain_names = commands .domain .single % domain_name ,
361
- ))
364
+ ), ** kwargs )
362
365
363
- def domain_check_multiple (self , domains_list ):
366
+ def domain_check_multiple (self , domains_list , ** kwargs ):
364
367
return self .call (cmd = commands .domain .check % dict (
365
368
cltrid = make_cltrid (),
366
369
domain_names = '\n ' .join ([
367
370
commands .domain .single % d for d in domains_list
368
371
]),
369
- ))
372
+ ), ** kwargs )
370
373
371
- def domain_info (self , domain_name , auth_info = None ):
374
+ def domain_info (self , domain_name , auth_info = None , ** kwargs ):
372
375
return self .call (cmd = commands .domain .info % dict (
373
376
cltrid = make_cltrid (),
374
377
domain_name = domain_name ,
375
378
auth_info = '' if not auth_info else commands .domain .auth_info % auth_info ,
376
- ))
379
+ ), ** kwargs )
377
380
378
381
def domain_create (self , domain_name , registrant , nameservers = [], period = 1 , period_units = 'y' ,
379
- contact_admin = None , contact_billing = None , contact_tech = None , auth_info = None ):
382
+ contact_admin = None , contact_billing = None , contact_tech = None , auth_info = None , ** kwargs ):
380
383
return self .call (cmd = commands .domain .create % dict (
381
384
cltrid = make_cltrid (),
382
385
domain_name = domain_name ,
@@ -389,20 +392,20 @@ def domain_create(self, domain_name, registrant, nameservers=[], period=1, perio
389
392
contact_billing = '' if not contact_billing else commands .domain .single_contact1 % dict (type = 'billing' , id = contact_billing ),
390
393
contact_tech = '' if not contact_tech else commands .domain .single_contact1 % dict (type = 'tech' , id = contact_tech ),
391
394
auth_info = '' if not auth_info else commands .domain .auth_info % auth_info ,
392
- ))
395
+ ), ** kwargs )
393
396
394
- def domain_renew (self , domain_name , cur_exp_date , period = 1 , period_units = 'y' ):
397
+ def domain_renew (self , domain_name , cur_exp_date , period = 1 , period_units = 'y' , ** kwargs ):
395
398
return self .call (cmd = commands .domain .renew % dict (
396
399
cltrid = make_cltrid (),
397
400
domain_name = domain_name ,
398
401
cur_exp_date = cur_exp_date ,
399
402
period = '' if period is None else commands .domain .period % dict (value = period , units = period_units or 'y' ),
400
- ))
403
+ ), ** kwargs )
401
404
402
405
def domain_update (self , domain_name , auth_info = None ,
403
406
add_nameservers = [], remove_nameservers = [],
404
407
add_contacts = [], remove_contacts = [], change_registrant = None ,
405
- rgp_restore = None , rgp_restore_report = None ):
408
+ rgp_restore = None , rgp_restore_report = None , ** kwargs ):
406
409
restore_extension = ''
407
410
if rgp_restore :
408
411
restore_extension = commands .domain .restore_request_extension
@@ -428,12 +431,12 @@ def domain_update(self, domain_name, auth_info=None,
428
431
commands .domain .single_registrant % change_registrant
429
432
),
430
433
restore_extension = restore_extension ,
431
- ))
434
+ ), ** kwargs )
432
435
433
- def domain_transfer (self , domain_name , auth_info = None , period = None , period_units = None ):
436
+ def domain_transfer (self , domain_name , auth_info = None , period = None , period_units = None , ** kwargs ):
434
437
return self .call (cmd = commands .domain .transfer % dict (
435
438
cltrid = make_cltrid (),
436
439
domain_name = domain_name ,
437
440
auth_info = '' if not auth_info else commands .domain .auth_info % auth_info ,
438
441
period = '' if period is None else commands .domain .period % dict (value = period , units = period_units or 'y' ),
439
- ))
442
+ ), ** kwargs )
0 commit comments