13 |
13 |
14 from PyQt6.QtCore import ( |
14 from PyQt6.QtCore import ( |
15 pyqtSignal, QTimer, QFileInfo, QCoreApplication, QByteArray |
15 pyqtSignal, QTimer, QFileInfo, QCoreApplication, QByteArray |
16 ) |
16 ) |
17 |
17 |
18 from E5Network.E5Ftp import E5Ftp, E5FtpProxyType, E5FtpProxyError |
18 from EricNetwork.EricFtp import EricFtp, EricFtpProxyType, EricFtpProxyError |
19 |
19 |
20 from .SyncHandler import SyncHandler |
20 from .SyncHandler import SyncHandler |
21 |
21 |
22 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
22 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
23 |
23 |
79 self.__idleTimer = QTimer(self) |
79 self.__idleTimer = QTimer(self) |
80 self.__idleTimer.setInterval( |
80 self.__idleTimer.setInterval( |
81 Preferences.getWebBrowser("SyncFtpIdleTimeout") * 1000) |
81 Preferences.getWebBrowser("SyncFtpIdleTimeout") * 1000) |
82 self.__idleTimer.timeout.connect(self.__idleTimeout) |
82 self.__idleTimer.timeout.connect(self.__idleTimeout) |
83 |
83 |
84 self.__ftp = E5Ftp() |
84 self.__ftp = EricFtp() |
85 |
85 |
86 # do proxy setup |
86 # do proxy setup |
87 proxyType = ( |
87 proxyType = ( |
88 E5FtpProxyType.NO_PROXY |
88 EricFtpProxyType.NO_PROXY |
89 if not Preferences.getUI("UseProxy") else |
89 if not Preferences.getUI("UseProxy") else |
90 Preferences.getUI("ProxyType/Ftp") |
90 Preferences.getUI("ProxyType/Ftp") |
91 ) |
91 ) |
92 if proxyType != E5FtpProxyType.NO_PROXY: |
92 if proxyType != EricFtpProxyType.NO_PROXY: |
93 self.__ftp.setProxy( |
93 self.__ftp.setProxy( |
94 proxyType, |
94 proxyType, |
95 Preferences.getUI("ProxyHost/Ftp"), |
95 Preferences.getUI("ProxyHost/Ftp"), |
96 Preferences.getUI("ProxyPort/Ftp")) |
96 Preferences.getUI("ProxyPort/Ftp")) |
97 if proxyType != E5FtpProxyType.NON_AUTHORIZING: |
97 if proxyType != EricFtpProxyType.NON_AUTHORIZING: |
98 self.__ftp.setProxyAuthentication( |
98 self.__ftp.setProxyAuthentication( |
99 Preferences.getUI("ProxyUser/Ftp"), |
99 Preferences.getUI("ProxyUser/Ftp"), |
100 Preferences.getUI("ProxyPassword/Ftp"), |
100 Preferences.getUI("ProxyPassword/Ftp"), |
101 Preferences.getUI("ProxyAccount/Ftp")) |
101 Preferences.getUI("ProxyAccount/Ftp")) |
102 |
102 |
112 self.__changeToStore() |
112 self.__changeToStore() |
113 self.__ftp.retrlines("LIST", self.__dirListCallback) |
113 self.__ftp.retrlines("LIST", self.__dirListCallback) |
114 self.__initialSync() |
114 self.__initialSync() |
115 self.__state = "idle" |
115 self.__state = "idle" |
116 self.__idleTimer.start() |
116 self.__idleTimer.start() |
117 except (ftplib.all_errors + (E5FtpProxyError,)) as err: |
117 except (ftplib.all_errors + (EricFtpProxyError,)) as err: |
118 self.syncError.emit(str(err)) |
118 self.syncError.emit(str(err)) |
119 |
119 |
120 def __connectAndLogin(self): |
120 def __connectAndLogin(self): |
121 """ |
121 """ |
122 Private method to connect to the FTP server and log in. |
122 Private method to connect to the FTP server and log in. |