daca2: use ls-lR file
This commit is contained in:
parent
fc9998e439
commit
ab2864e1cb
|
@ -6,51 +6,40 @@
|
||||||
# 4. Optional: tweak FTPSERVER and FTPPATH in this script below.
|
# 4. Optional: tweak FTPSERVER and FTPPATH in this script below.
|
||||||
# 5. Run the daca2 script: python daca2.py FOLDER
|
# 5. Run the daca2 script: python daca2.py FOLDER
|
||||||
|
|
||||||
import ftplib
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import socket
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
FTPSERVER = 'ftp.sunet.se'
|
FTPSERVER = 'ftp.sunet.se'
|
||||||
FTPPATH = '/pub/Linux/distributions/Debian/debian/pool/main/'
|
FTPPATH = '/pub/Linux/distributions/Debian/debian/'
|
||||||
|
|
||||||
|
|
||||||
def getpackages(folder):
|
def getpackages(folder):
|
||||||
print('Connect')
|
subprocess.call(
|
||||||
f = ftplib.FTP(FTPSERVER)
|
['nice', 'wget', 'ftp://' + FTPSERVER + FTPPATH + 'ls-lR.gz'])
|
||||||
f.login()
|
subprocess.call(['nice', 'gunzip', 'ls-lR.gz'])
|
||||||
|
f = open('ls-lR', 'rt')
|
||||||
print('Get package list in folder ' + folder)
|
lines = f.readlines()
|
||||||
packages = f.nlst(FTPPATH + folder)
|
f.close()
|
||||||
|
subprocess.call(['rm', 'ls-lR'])
|
||||||
|
|
||||||
|
path = None
|
||||||
archives = []
|
archives = []
|
||||||
for package in packages:
|
filename = None
|
||||||
print(package)
|
for line in lines:
|
||||||
filename = None
|
if len(line) < 4:
|
||||||
path = FTPPATH + folder + '/' + package
|
if filename:
|
||||||
|
archives.append(path + '/' + filename)
|
||||||
time.sleep(1)
|
path = None
|
||||||
files = f.nlst(path)
|
filename = None
|
||||||
|
elif line[:13 + len(folder)] == './pool/main/' + folder + '/':
|
||||||
for s in files:
|
path = line[2:-2]
|
||||||
if s.find('.orig.tar.') > 0:
|
elif path and line.find('.orig.tar.') > 0:
|
||||||
filename = s
|
filename = line[1 + line.rfind(' '):]
|
||||||
|
|
||||||
if not filename:
|
|
||||||
for s in files:
|
|
||||||
if s.find('.tar.') > 0:
|
|
||||||
filename = s
|
|
||||||
|
|
||||||
if not filename:
|
|
||||||
archives = []
|
|
||||||
return archives
|
|
||||||
|
|
||||||
archives.append(package + '/' + filename)
|
|
||||||
|
|
||||||
return archives
|
return archives
|
||||||
|
|
||||||
|
@ -205,7 +194,7 @@ try:
|
||||||
# remove all files/folders except results.txt
|
# remove all files/folders except results.txt
|
||||||
removeAllExceptResults()
|
removeAllExceptResults()
|
||||||
|
|
||||||
scanarchive('ftp://' + FTPSERVER + FTPPATH + FOLDER + '/' + archive)
|
scanarchive('ftp://' + FTPSERVER + FTPPATH + archive)
|
||||||
|
|
||||||
except EOFError:
|
except EOFError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue