7 Module implementing a synchronization handler using FTP. |
7 Module implementing a synchronization handler using FTP. |
8 """ |
8 """ |
9 |
9 |
10 import ftplib # secok |
10 import ftplib # secok |
11 import io |
11 import io |
|
12 import contextlib |
12 |
13 |
13 from PyQt5.QtCore import ( |
14 from PyQt5.QtCore import ( |
14 pyqtSignal, QTimer, QFileInfo, QCoreApplication, QByteArray |
15 pyqtSignal, QTimer, QFileInfo, QCoreApplication, QByteArray |
15 ) |
16 ) |
16 |
17 |
391 Public method to shut down the handler. |
392 Public method to shut down the handler. |
392 """ |
393 """ |
393 if self.__idleTimer.isActive(): |
394 if self.__idleTimer.isActive(): |
394 self.__idleTimer.stop() |
395 self.__idleTimer.stop() |
395 |
396 |
396 try: |
397 with contextlib.suppress(ftplib.all_errors): |
397 if self.__connected: |
398 if self.__connected: |
398 self.__ftp.quit() |
399 self.__ftp.quit() |
399 except ftplib.all_errors: |
|
400 pass # ignore FTP errors because we are shutting down anyway |
|
401 self.__connected = False |
400 self.__connected = False |
402 |
401 |
403 def __idleTimeout(self): |
402 def __idleTimeout(self): |
404 """ |
403 """ |
405 Private slot to prevent a disconnect from the server. |
404 Private slot to prevent a disconnect from the server. |