eric6/WebBrowser/Sync/FtpSyncHandler.py

changeset 7269
0c63ea7f94bd
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7268:a28338eaf694 7269:0c63ea7f94bd
9 9
10 10
11 import ftplib 11 import ftplib
12 import io 12 import io
13 13
14 from PyQt5.QtCore import pyqtSignal, QTimer, QFileInfo, QCoreApplication, \ 14 from PyQt5.QtCore import (
15 QByteArray 15 pyqtSignal, QTimer, QFileInfo, QCoreApplication, QByteArray
16 )
16 17
17 from E5Network.E5Ftp import E5Ftp, E5FtpProxyType, E5FtpProxyError 18 from E5Network.E5Ftp import E5Ftp, E5FtpProxyType, E5FtpProxyError
18 19
19 from .SyncHandler import SyncHandler 20 from .SyncHandler import SyncHandler
20 21
137 138
138 This action will create the storage path on the server, if it 139 This action will create the storage path on the server, if it
139 does not exist. Upon return, the current directory of the server 140 does not exist. Upon return, the current directory of the server
140 is the sync directory. 141 is the sync directory.
141 """ 142 """
142 storePathList = \ 143 storePathList = Preferences.getWebBrowser("SyncFtpPath").replace(
143 Preferences.getWebBrowser("SyncFtpPath")\ 144 "\\", "/").split("/")
144 .replace("\\", "/").split("/")
145 if storePathList[0] == "": 145 if storePathList[0] == "":
146 storePathList.pop(0) 146 storePathList.pop(0)
147 while storePathList: 147 while storePathList:
148 path = storePathList[0] 148 path = storePathList[0]
149 try: 149 try:
170 # silently ignore parser errors 170 # silently ignore parser errors
171 urlInfo = None 171 urlInfo = None
172 172
173 if urlInfo and urlInfo.isValid() and urlInfo.isFile(): 173 if urlInfo and urlInfo.isValid() and urlInfo.isFile():
174 if urlInfo.name() in self._remoteFiles.values(): 174 if urlInfo.name() in self._remoteFiles.values():
175 self.__remoteFilesFound[urlInfo.name()] = \ 175 self.__remoteFilesFound[urlInfo.name()] = (
176 urlInfo.lastModified() 176 urlInfo.lastModified()
177 )
177 178
178 QCoreApplication.processEvents() 179 QCoreApplication.processEvents()
179 180
180 def __downloadFile(self, type_, fileName, timestamp): 181 def __downloadFile(self, type_, fileName, timestamp):
181 """ 182 """
251 @param type_ type of the synchronization event (string one 252 @param type_ type of the synchronization event (string one
252 of "bookmarks", "history", "passwords", "useragents" or 253 of "bookmarks", "history", "passwords", "useragents" or
253 "speeddial") 254 "speeddial")
254 @param fileName name of the file to be synchronized (string) 255 @param fileName name of the file to be synchronized (string)
255 """ 256 """
256 if not self.__forceUpload and \ 257 if (
257 self._remoteFiles[type_] in self.__remoteFilesFound: 258 not self.__forceUpload and
258 if QFileInfo(fileName).lastModified() < \ 259 self._remoteFiles[type_] in self.__remoteFilesFound
259 self.__remoteFilesFound[self._remoteFiles[type_]]: 260 ):
261 if (
262 QFileInfo(fileName).lastModified() <
263 self.__remoteFilesFound[self._remoteFiles[type_]]
264 ):
260 self.__downloadFile( 265 self.__downloadFile(
261 type_, fileName, 266 type_, fileName,
262 self.__remoteFilesFound[self._remoteFiles[type_]] 267 self.__remoteFilesFound[self._remoteFiles[type_]]
263 .toTime_t()) 268 .toTime_t())
264 else: 269 else:

eric ide

mercurial