def run_tests(host, local, remote, port=0, ssl=False, debug=False, base_test=False): if base_test: TESTS.insert(0, BaseTest) if 'http_proxy' in os.environ: proxy = os.environ['http_proxy'].split('//')[1] p_address, p_port = proxy.split(':') p_port = int(p_port) helperlib.info('Using Proxy {}:{}\n'.format(p_address, p_port)) success = [] spinner.waitfor('Testing') for i, test in enumerate(TESTS, 1): spinner.status('{} ({}/{}) '.format(test.__name__, i, len(TESTS))) s = test(host, local, remote, port, ssl, debug) try: s.setup() s.test() except (SMTPError, smtplib.SMTPException): spinner.status_append('${RED}FAIL${NORMAL}') else: spinner.status_append('${GREEN}SUCCESS${NORMAL}') success.append(s) finally: s.teardown() time.sleep(0.5) if len(success): spinner.succeeded() for s in success: helperlib.success("{}: {}".format(type(s).__name__, s)) else: spinner.failed()
def _check_local(self, lfile, lfilename, rfile, rfilename): if os.path.lexists(lfilename): stats = os.lstat(lfilename) mtime, size = map(int, (stats.st_mtime, stats.st_size)) if lfile and mtime != lfile.mtime: if lfile.mtime != rfile.mtime and mtime != rfile.mtime: raise ValueError("Conflict with file %s (Both modified (different timestamp))" % rfilename) if mtime > rfile.mtime: raise ValueError("Conflict with file %s (local file is newer)" % rfilename) if size != rfile.size and mtime == rfile.mtime: raise ValueError("Conflict with file %s (size differs)" % rfilename) if mtime == rfile.mtime and size == rfile.size: print() success("Already downloaded\n") return False return True
def different(sftp, filename, other, current, local, remote): if (other[MODE] & 0o777000) != (current[MODE] & 0o777000) and \ other[MODE] != -1: print() success("Differences in %s" % filename) print(" dst vs src") print(" Mode: %o vs %o" % (other[MODE], current[MODE])) return True elif stat.S_ISLNK(other[MODE]): # symlink rtarget = sftp.readlink(os.path.join(remote, filename)) ltarget = os.readlink(os.path.join(local, filename)) if ltarget != rtarget: print() success("Differences in %s" % filename) print(" dst vs src") print(" Target: %s vs %s" % (ltarget, rtarget)) return True elif (other[MTIME] < current[MTIME] or (other[MTIME] == current[MTIME] and other[SIZE] != current[SIZE])): print() success("Differences in %s" % filename) print(" dst vs src") print(" Time: %r vs %r" % (other[MTIME], current[MTIME])) print(" Size: %r vs %r" % (other[SIZE], current[SIZE])) return True return False
def print_file_info2(filename, f): print() success("File: %s" % filename) print(" Size: %d\n Mode: %o\n Modtime: %d" % ( f[SIZE], f[MODE], f[MTIME]))
def print_file_info(filename, f): print() success("New file: %s" % filename) print(" Size: %d\n UID: %d\n GID: %d\n Mode: %o\n Accesstime: %d\n Modtime: %d" % ( f.st_size, f.st_uid, f.st_gid, f.st_mode, f.st_atime, f.st_mtime))