From ab2864e1cbfdffe65e1aef42de717c288fe596f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 24 Oct 2013 18:22:15 +0200 Subject: [PATCH] daca2: use ls-lR file --- tools/daca2.py | 53 ++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/tools/daca2.py b/tools/daca2.py index c4531225a..0b3dff5c2 100644 --- a/tools/daca2.py +++ b/tools/daca2.py @@ -6,51 +6,40 @@ # 4. Optional: tweak FTPSERVER and FTPPATH in this script below. # 5. Run the daca2 script: python daca2.py FOLDER -import ftplib import subprocess import sys import shutil import glob import os -import socket import datetime import time FTPSERVER = 'ftp.sunet.se' -FTPPATH = '/pub/Linux/distributions/Debian/debian/pool/main/' +FTPPATH = '/pub/Linux/distributions/Debian/debian/' def getpackages(folder): - print('Connect') - f = ftplib.FTP(FTPSERVER) - f.login() - - print('Get package list in folder ' + folder) - packages = f.nlst(FTPPATH + folder) + subprocess.call( + ['nice', 'wget', 'ftp://' + FTPSERVER + FTPPATH + 'ls-lR.gz']) + subprocess.call(['nice', 'gunzip', 'ls-lR.gz']) + f = open('ls-lR', 'rt') + lines = f.readlines() + f.close() + subprocess.call(['rm', 'ls-lR']) + path = None archives = [] - for package in packages: - print(package) - filename = None - path = FTPPATH + folder + '/' + package - - time.sleep(1) - files = f.nlst(path) - - for s in files: - if s.find('.orig.tar.') > 0: - filename = s - - if not filename: - for s in files: - if s.find('.tar.') > 0: - filename = s - - if not filename: - archives = [] - return archives - - archives.append(package + '/' + filename) + filename = None + for line in lines: + if len(line) < 4: + if filename: + archives.append(path + '/' + filename) + path = None + filename = None + elif line[:13 + len(folder)] == './pool/main/' + folder + '/': + path = line[2:-2] + elif path and line.find('.orig.tar.') > 0: + filename = line[1 + line.rfind(' '):] return archives @@ -205,7 +194,7 @@ try: # remove all files/folders except results.txt removeAllExceptResults() - scanarchive('ftp://' + FTPSERVER + FTPPATH + FOLDER + '/' + archive) + scanarchive('ftp://' + FTPSERVER + FTPPATH + archive) except EOFError: pass