Lines 202-207
Link Here
|
202 |
except OSError: |
200 |
except OSError: |
203 |
debug_msg(_("cannot chagne file permitions on '%s'") % file_name, 2) |
201 |
debug_msg(_("cannot chagne file permitions on '%s'") % file_name, 2) |
204 |
return (file_name, f) |
202 |
return (file_name, f) |
|
|
203 |
|
205 |
def _connection_init(self): |
204 |
def _connection_init(self): |
206 |
account = self.account |
205 |
account = self.account |
207 |
if not self._callback_answer_mode: |
206 |
if not self._callback_answer_mode: |
Lines 380-398
Link Here
|
380 |
self.pppd_exit_code = code / 256 |
380 |
self.pppd_exit_code = code / 256 |
381 |
return 0 |
381 |
return 0 |
382 |
return 1 |
382 |
return 1 |
|
|
383 |
|
383 |
def iteration(self): |
384 |
def iteration(self): |
384 |
account = self.account |
385 |
account = self.account |
|
|
386 |
|
387 |
# Vladimir Smolyar, 02.05.2013: Check whether the interface is (still) up |
388 |
if not (self.linkname and re.search(r'<UP', |
389 |
commands.getoutput( |
390 |
"%s %s 2> /dev/null" % (chestnut_dialer.config.ifconfig, self.linkname)), re.M)): |
391 |
self._interface_up = 0 |
392 |
|
393 |
|
385 |
if not self._interface_up: |
394 |
if not self._interface_up: |
386 |
pppd_kiled = 0 |
395 |
pppd_kiled = 0 |
387 |
buf = "" |
396 |
buf = "" |
388 |
t = time.time() |
397 |
t = time.time() |
389 |
while time.time() - t < 0.1: |
398 |
while time.time() - t < 0.1: |
390 |
if select.select([self._pppd_pty], [], [], 0.02)[0]: |
399 |
if select.select([self._pppd_pty], [], [], 0.02)[0]: |
391 |
try: buf += os.read(self._pppd_pty, 1) |
400 |
try: buf += os.read(self._pppd_pty, 1) |
392 |
except OSError: break |
401 |
except OSError: break |
393 |
else: |
402 |
else: |
394 |
break |
403 |
break |
|
|
404 |
|
395 |
if buf == "" and not self._is_pppd_live(): pppd_kiled = 1 |
405 |
if buf == "" and not self._is_pppd_live(): pppd_kiled = 1 |
|
|
406 |
# Vladimir Smolyar, 02.05.2013: |
407 |
elif buf =="": |
408 |
# the buffer is empty |
409 |
if self.connected: |
410 |
#chestnut-dialer believes that it is connected, but |
411 |
# 1) the _interface_up = 0 |
412 |
# 2) buf == "" |
413 |
# So let's check if the pppd is reconnecting already: |
414 |
if select.select([self._pppd_pty], [], [], 20)[0]: |
415 |
# yes, it is reconnecting just now |
416 |
return |
417 |
# no, it is not reconnecting while it should. |
418 |
# So let's send a signal to it |
419 |
debug_msg("Sending SIGHUP",3) |
420 |
os.kill(self._pppd, signal.SIGHUP) |
421 |
|
422 |
|
396 |
if len(buf): |
423 |
if len(buf): |
397 |
buf = buf.replace("\r", "") |
424 |
buf = buf.replace("\r", "") |
398 |
self.text_queue.put(buf) |
425 |
self.text_queue.put(buf) |
Lines 401-406
Link Here
|
401 |
self._pppd_chars = lines[-1] |
428 |
self._pppd_chars = lines[-1] |
402 |
lines[-1:] = [] |
429 |
lines[-1:] = [] |
403 |
for s in lines: |
430 |
for s in lines: |
|
|
431 |
#killing because of a low speed |
404 |
if not self.speed: |
432 |
if not self.speed: |
405 |
m = self._speed_re.match(s) |
433 |
m = self._speed_re.match(s) |
406 |
if m: |
434 |
if m: |
Lines 474-480
Link Here
|
474 |
self.connected = 1 |
503 |
self.connected = 1 |
475 |
if account['connect_program']: |
504 |
if account['connect_program']: |
476 |
os.system(account['connect_program']) |
505 |
os.system(account['connect_program']) |
|
|
506 |
else: |
507 |
# the interface is down, thus it is not connected |
508 |
self.connected = 0 |
509 |
|
477 |
if not pppd_kiled: return |
510 |
if not pppd_kiled: return |
|
|
511 |
|
512 |
# Vladimir Smolyar, 02.05.2013: |
513 |
# Deleting the chat and password temporary files moved down, |
514 |
# after the pppd is surely killed. |
515 |
# Otherwise it leads to an error when pppd wishes to reconnect and |
516 |
# cannot find the temporary chat file. |
517 |
|
518 |
if self._is_pppd_live(): return |
519 |
|
520 |
# Vladimir Smolyar, 02.05.2013: |
521 |
# deleting the chat and password temporary files |
478 |
if self._chat_temp_file: |
522 |
if self._chat_temp_file: |
479 |
debug_msg(_("removing chat temp file"), 3) |
523 |
debug_msg(_("removing chat temp file"), 3) |
480 |
os.unlink(self._chat_temp_file) |
524 |
os.unlink(self._chat_temp_file) |
Lines 483-489
Link Here
|
483 |
debug_msg(_("removing password temp file"), 3) |
527 |
debug_msg(_("removing password temp file"), 3) |
484 |
os.unlink(self._passwd_temp_file) |
528 |
os.unlink(self._passwd_temp_file) |
485 |
self._passwd_temp_file = None |
529 |
self._passwd_temp_file = None |
486 |
if self._is_pppd_live(): return |
530 |
|
|
|
531 |
|
487 |
os.close(self._pppd_pty) |
532 |
os.close(self._pppd_pty) |
488 |
if self._passwdfdr: |
533 |
if self._passwdfdr: |
489 |
try: os.close(self._passwdfdr) |
534 |
try: os.close(self._passwdfdr) |