mrmp/synchronization.py

45 lines
1.3 KiB
Python
Raw Normal View History

2021-10-09 17:46:11 +00:00
import os
2021-10-10 11:45:02 +00:00
import shutil
2021-10-09 17:46:11 +00:00
2021-10-10 11:45:02 +00:00
import arguments
2021-10-10 12:07:15 +00:00
import file
2021-10-10 12:44:22 +00:00
import local
2021-10-09 17:46:11 +00:00
import remote
class Synchronization:
2021-10-10 17:02:34 +00:00
def __init__(self):
self.remote = remote.Remote()
self.repository = local.Local()
2021-10-09 17:46:11 +00:00
self.temporary = self.repository.get_temporary()
2021-10-10 17:02:34 +00:00
self.threads = arguments.threads
2021-10-10 11:45:02 +00:00
def run(self):
for architecture in self.remote.architectures:
2021-10-10 19:30:40 +00:00
for subsystem in architecture.subsystems.values():
for _, package in sorted(subsystem.catalog.packages.items()):
2021-10-10 12:07:15 +00:00
f = file.File(
2021-10-10 19:30:40 +00:00
os.path.join(self.remote.location, subsystem.path),
2021-10-10 12:07:15 +00:00
package.name,
package.csize,
2021-10-10 19:30:40 +00:00
os.path.join(self.repository.location, subsystem.path),
2021-10-10 12:07:15 +00:00
package.sha256sum,
)
2021-10-10 11:45:02 +00:00
print()
2021-10-10 12:07:15 +00:00
print(f)
2021-10-10 13:01:24 +00:00
tmp = os.path.join(self.repository.location,
2021-10-10 11:45:02 +00:00
self.repository.get_temporary())
os.makedirs(tmp)
# clean temporary directory
shutil.rmtree(tmp)
2021-10-09 17:46:11 +00:00
def __str__(self):
lines = [
2021-10-10 19:30:40 +00:00
str(self.remote),
str(),
str(self.repository),
str(),
2021-10-09 17:46:11 +00:00
f'Temporary: {self.temporary}',
]
return os.linesep.join(lines)