~ubuntu-core-dev/ubuntu/xenial/ubuntu-release-upgrader/xenial

« back to all changes in this revision

Viewing changes to utils/update_mirrors.py

  • Committer: Dimitri John Ledkov
  • Date: 2015-01-20 22:30:06 UTC
  • mto: This revision was merged to the branch mainline in revision 2859.
  • Revision ID: dimitri.j.ledkov@intel.com-20150120223006-ba30fbqtp4x2n0og
Fix resource warnings & logging.warn deprecation warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
# read what we have
7
7
current_mirrors = set()
8
 
for line in open(sys.argv[1], "r"):
9
 
    current_mirrors.add(line.strip())
 
8
with open(sys.argv[1], "r") as f:
 
9
    for line in f:
 
10
        current_mirrors.add(line.strip())
10
11
 
11
12
    
12
 
outfile = open(sys.argv[1], "a")
13
13
d = feedparser.parse("https://launchpad.net/ubuntu/+archivemirrors-rss")
14
14
 
15
15
#import pprint
16
16
#pp  = pprint.PrettyPrinter(indent=4)
17
17
#pp.pprint(d)
18
18
 
19
 
for entry in d.entries:
20
 
    for link in entry.links:
21
 
        if link.href not in current_mirrors:
22
 
            outfile.write(link.href + "\n")
 
19
with open(sys.argv[1], "a") as outfile:
 
20
    for entry in d.entries:
 
21
        for link in entry.links:
 
22
            if link.href not in current_mirrors:
 
23
                outfile.write(link.href + "\n")