daca2: refactorings and fix of indentlevel that might have screwed up the script.
This commit is contained in:
parent
911e1f9559
commit
d30ebe268a
|
@ -15,7 +15,9 @@ import glob
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
FOLDER = 'a'
|
FTPSERVER = 'ftp.sunet.se'
|
||||||
|
FTPPATH = '/pub/Linux/distributions/Debian/debian/pool/main/'
|
||||||
|
FOLDER = 'b'
|
||||||
|
|
||||||
def removeAllExceptResults():
|
def removeAllExceptResults():
|
||||||
filenames = glob.glob('[A-Za-z]*')
|
filenames = glob.glob('[A-Za-z]*')
|
||||||
|
@ -25,34 +27,33 @@ def removeAllExceptResults():
|
||||||
elif filename != 'results.txt':
|
elif filename != 'results.txt':
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
def getpackages(c):
|
|
||||||
f = ftplib.FTP('ftp.sunet.se','anonymous','','',60)
|
|
||||||
f.login('anonymous','password')
|
|
||||||
packages = f.nlst('/pub/Linux/distributions/Debian/debian/pool/main/' + c)
|
|
||||||
f.quit()
|
|
||||||
return packages
|
|
||||||
|
|
||||||
workdir = os.path.expanduser('~/daca2/')
|
workdir = os.path.expanduser('~/daca2/')
|
||||||
|
|
||||||
|
print('~/daca2/suppressions.txt')
|
||||||
if not os.path.isfile(workdir + 'suppressions.txt'):
|
if not os.path.isfile(workdir + 'suppressions.txt'):
|
||||||
suppressions = open(workdir + 'suppressions.txt', 'wt')
|
suppressions = open(workdir + 'suppressions.txt', 'wt')
|
||||||
suppressions.write('\n')
|
suppressions.write('\n')
|
||||||
suppressions.close()
|
suppressions.close()
|
||||||
|
|
||||||
|
print('~/daca2/' + FOLDER)
|
||||||
if not os.path.isdir(workdir + FOLDER):
|
if not os.path.isdir(workdir + FOLDER):
|
||||||
os.makedirs(workdir + FOLDER)
|
os.makedirs(workdir + FOLDER)
|
||||||
os.chdir(workdir + FOLDER)
|
os.chdir(workdir + FOLDER)
|
||||||
if os.path.isfile('results.txt'):
|
if os.path.isfile('results.txt'):
|
||||||
os.remove('results.txt')
|
os.remove('results.txt')
|
||||||
|
|
||||||
packages = getpackages(FOLDER)
|
print('Connect to ' + FTPSERVER)
|
||||||
|
f = ftplib.FTP(FTPSERVER)
|
||||||
|
f.login()
|
||||||
|
|
||||||
|
print('Get package list in folder ' + FOLDER)
|
||||||
|
packages = f.nlst(FTPPATH + FOLDER)
|
||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
|
print('package:' + package)
|
||||||
filename = None
|
filename = None
|
||||||
path = '/pub/Linux/distributions/Debian/debian/pool/main/' + FOLDER + '/' + package
|
path = FTPPATH + FOLDER + '/' + package
|
||||||
f = None
|
|
||||||
try:
|
try:
|
||||||
f = ftplib.FTP('ftp.sunet.se','anonymous','password','',60)
|
|
||||||
f.login('anonymous','x')
|
|
||||||
for s in f.nlst(path):
|
for s in f.nlst(path):
|
||||||
if s[-12:] == '.orig.tar.gz':
|
if s[-12:] == '.orig.tar.gz':
|
||||||
filename = s
|
filename = s
|
||||||
|
@ -60,11 +61,6 @@ for package in packages:
|
||||||
pass
|
pass
|
||||||
except ftplib.error_temp:
|
except ftplib.error_temp:
|
||||||
pass
|
pass
|
||||||
if f:
|
|
||||||
try:
|
|
||||||
f.quit()
|
|
||||||
except ftplib.error_reply:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
fullpath = 'ftp://ftp.sunet.se' + path + '/' + filename
|
fullpath = 'ftp://ftp.sunet.se' + path + '/' + filename
|
||||||
|
@ -84,6 +80,7 @@ for package in packages:
|
||||||
comm = p.communicate()
|
comm = p.communicate()
|
||||||
|
|
||||||
results = open('results.txt', 'at')
|
results = open('results.txt', 'at')
|
||||||
|
results.write(fullpath + '\n')
|
||||||
results.write(comm[1] + '\n')
|
results.write(comm[1] + '\n')
|
||||||
results.close()
|
results.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue