@@ -195,6 +195,7 class SendToFTP(Operation): | |||
|
195 | 195 | Operation.__init__(self) |
|
196 | 196 | self.ftp = None |
|
197 | 197 | self.ready = False |
|
198 | self.current_time = time.time() | |
|
198 | 199 | |
|
199 | 200 | def setup(self, server, username, password, timeout, **kwargs): |
|
200 | 201 | ''' |
@@ -219,7 +220,7 class SendToFTP(Operation): | |||
|
219 | 220 | |
|
220 | 221 | log.log('Connecting to ftp://{}'.format(self.server), self.name) |
|
221 | 222 | try: |
|
222 |
self.ftp = ftplib.FTP(self.server, timeout= |
|
|
223 | self.ftp = ftplib.FTP(self.server, timeout=1) | |
|
223 | 224 | except ftplib.all_errors: |
|
224 | 225 | log.error('Server connection fail: {}'.format(self.server), self.name) |
|
225 | 226 | if self.ftp is not None: |
@@ -245,6 +246,11 class SendToFTP(Operation): | |||
|
245 | 246 | def check(self): |
|
246 | 247 | |
|
247 | 248 | try: |
|
249 | if not self.ready: | |
|
250 | if time.time()-self.current_time < self.timeout: | |
|
251 | return | |
|
252 | else: | |
|
253 | self.current_time = time.time() | |
|
248 | 254 | self.ftp.voidcmd("NOOP") |
|
249 | 255 | except: |
|
250 | 256 | log.warning('Connection lost... trying to reconnect', self.name) |
@@ -328,7 +334,7 class SendToFTP(Operation): | |||
|
328 | 334 | self.times[x] = self.dataOut.utctime |
|
329 | 335 | self.latest[x] = srcname |
|
330 | 336 | |
|
331 |
def run(self, dataOut, server, username, password, timeout= |
|
|
337 | def run(self, dataOut, server, username, password, timeout=60, **kwargs): | |
|
332 | 338 | |
|
333 | 339 | if not self.isConfig: |
|
334 | 340 | self.setup( |
@@ -343,7 +349,8 class SendToFTP(Operation): | |||
|
343 | 349 | |
|
344 | 350 | self.dataOut = dataOut |
|
345 | 351 | self.check() |
|
346 |
self. |
|
|
352 | if self.ready: | |
|
353 | self.send_files() | |
|
347 | 354 | |
|
348 | 355 | def close(self): |
|
349 | 356 |
General Comments 0
You need to be logged in to leave comments.
Login now