load
This commit is contained in:
parent
3237ea410e
commit
a6f125c8c3
1 changed files with 19 additions and 5 deletions
20
remote.py
20
remote.py
|
@ -5,21 +5,35 @@ import arguments
|
||||||
import hypertext
|
import hypertext
|
||||||
|
|
||||||
|
|
||||||
|
ARCHIVE = '.tar.xz'
|
||||||
|
ARCHITECTURES = ['x86_64', 'i686']
|
||||||
CHARSET = 'u8'
|
CHARSET = 'u8'
|
||||||
DISTRIBUTION = 'distrib'
|
DISTRIBUTION = 'distrib'
|
||||||
|
SIGNATURE = '.sig'
|
||||||
|
|
||||||
|
|
||||||
class Remote:
|
class Remote:
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
self.location = args[arguments.REMOTE]
|
self.location = args[arguments.REMOTE]
|
||||||
|
self.load()
|
||||||
|
|
||||||
def fetch_latest_distribution(self, architecture):
|
def load(self):
|
||||||
|
d = {}
|
||||||
|
for architecture in ARCHITECTURES:
|
||||||
url = os.path.join(self.location, DISTRIBUTION, architecture)
|
url = os.path.join(self.location, DISTRIBUTION, architecture)
|
||||||
html = requests.get(url).content.decode(CHARSET)
|
html = requests.get(url).content.decode(CHARSET)
|
||||||
links = hypertext.get_links(html)
|
links = sorted(hypertext.get_links(html))
|
||||||
print(links)
|
archives = [link for link in links
|
||||||
|
if link.endswith(ARCHIVE)]
|
||||||
|
signatures = [link for link in links
|
||||||
|
if link.endswith(SIGNATURE)]
|
||||||
|
archive = archives[-1]
|
||||||
|
d[architecture] = archive
|
||||||
|
self.archives = d
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'''\
|
return f'''\
|
||||||
Location: {self.location}
|
Location: {self.location}
|
||||||
|
Archives:
|
||||||
|
{self.archives}
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue