2021-10-09 14:02:10 +02:00
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
|
|
|
|
import arguments
|
2021-10-09 23:39:16 +02:00
|
|
|
import catalog
|
2021-10-09 14:02:10 +02:00
|
|
|
import hypertext
|
2021-10-10 03:52:31 +02:00
|
|
|
import msys
|
2021-10-09 14:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Remote:
|
|
|
|
def __init__(self, args):
|
|
|
|
self.location = args[arguments.REMOTE]
|
2021-10-09 19:46:11 +02:00
|
|
|
self.architectures = args[arguments.ARCHITECTURES]
|
2021-10-09 20:01:02 +02:00
|
|
|
self.subsystems = args[arguments.SUBSYSTEMS]
|
2021-10-09 14:36:53 +02:00
|
|
|
self.load()
|
2021-10-09 14:02:10 +02:00
|
|
|
|
2021-10-09 14:36:53 +02:00
|
|
|
def load(self):
|
2021-10-09 20:45:16 +02:00
|
|
|
a = {}
|
|
|
|
c = {}
|
2021-10-09 19:46:11 +02:00
|
|
|
for architecture in self.architectures:
|
2021-10-10 04:43:33 +02:00
|
|
|
subsystems = msys.get_subsystems(architecture, self.subsystems)
|
2021-10-10 04:01:32 +02:00
|
|
|
location = os.path.join(self.location,
|
|
|
|
msys.DISTRIBUTION, architecture)
|
2021-10-10 03:46:44 +02:00
|
|
|
a[architecture] = hypertext.HyperText(location).archive
|
2021-10-09 20:45:16 +02:00
|
|
|
#
|
2021-10-09 21:59:07 +02:00
|
|
|
c[architecture] = {}
|
2021-10-10 04:43:33 +02:00
|
|
|
for subsystem in subsystems:
|
2021-10-10 05:01:21 +02:00
|
|
|
location = os.path.join(self.location,
|
|
|
|
msys.get_subsystem(architecture,
|
|
|
|
subsystem),
|
2021-10-10 04:43:33 +02:00
|
|
|
f'{subsystem}{msys.CATALOG}')
|
|
|
|
binary = requests.get(location).content
|
|
|
|
c[architecture][subsystem] = catalog.Catalog(binary)
|
2021-10-09 20:45:16 +02:00
|
|
|
self.archives = a
|
|
|
|
self.catalogs = c
|
2021-10-09 14:02:10 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
2021-10-09 14:55:05 +02:00
|
|
|
lines = [f'Location: {self.location}',
|
|
|
|
'Archives:']
|
2021-10-09 14:59:07 +02:00
|
|
|
for architecture, archive in reversed(sorted(self.archives.items())):
|
2021-10-09 14:55:05 +02:00
|
|
|
lines.append(f'{architecture} → {archive}')
|
2021-10-09 21:59:07 +02:00
|
|
|
lines.append('Subsystems:')
|
2021-10-09 22:26:39 +02:00
|
|
|
for arch, ss in reversed(sorted(self.catalogs.items())):
|
|
|
|
lines.append(f'{arch} → {list(ss.keys())}')
|
2021-10-09 14:55:05 +02:00
|
|
|
return os.linesep.join(lines)
|