summaryrefslogtreecommitdiff
path: root/src/backend/download.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-11-04 01:04:41 +0000
committerV3n3RiX <venerix@koprulu.sector>2022-11-04 01:04:41 +0000
commit2e9af066c27ff6ef1b3308a0fab887e8a35ff135 (patch)
tree4a7a62e0dd2a9a4d46ec7d05c928873f38ed38e2 /src/backend/download.py
parent1dc3bbe378ae39b10765c9e0f2a0ef995b4a287c (diff)
backend : use pickle to store dependency lists across modules, split out download as separate module (remove lots of duplicated code)
Diffstat (limited to 'src/backend/download.py')
-rw-r--r--src/backend/download.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/backend/download.py b/src/backend/download.py
new file mode 100644
index 0000000..c48b9d2
--- /dev/null
+++ b/src/backend/download.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+
+import os
+import pickle
+import shutil
+import wget
+import sisyphus.getenv
+import sisyphus.getfs
+
+def package(pkgname):
+ binhostURL = sisyphus.getenv.binhostURL()
+ areBinaries,areSources,needsConfig = pickle.load(open(os.path.join(sisyphus.getfs.portageMetadataDir, "sisyphus_solvedeps_pkg.pickle"), "rb"))
+
+ for index, binary in enumerate([package + '.tbz2' for package in areBinaries], start=1):
+ print(">>> Downloading binary ({}".format(index) + " " + "of" + " " + str(len(areBinaries)) + ")" + " " + binary)
+ wget.download(binhostURL + binary)
+ print("")
+
+ if os.path.isdir(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0])):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0]), os.path.basename(binary.rstrip().split("/")[1])))
+ else:
+ os.makedirs(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0]))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0]), os.path.basename(binary.rstrip().split("/")[1])))
+
+ if os.path.exists(binary.rstrip().split("/")[1]):
+ os.remove(binary.rstrip().split("/")[1])
+
+
+def world():
+ binhostURL = sisyphus.getenv.binhostURL()
+ areBinaries,areSources,needsConfig = pickle.load(open(os.path.join(sisyphus.getfs.portageMetadataDir, "sisyphus_solvedeps_world.pickle"), "rb"))
+
+ for index, binary in enumerate([package + '.tbz2' for package in areBinaries], start=1):
+ print(">>> Downloading binary ({}".format(index) + " " + "of" + " " + str(len(areBinaries)) + ")" + " " + binary)
+ wget.download(binhostURL + binary)
+ print("")
+
+ if os.path.isdir(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0])):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0]), os.path.basename(binary.rstrip().split("/")[1])))
+ else:
+ os.makedirs(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0]))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.getfs.portageCacheDir, binary.rstrip().split("/")[0]), os.path.basename(binary.rstrip().split("/")[1])))
+
+ if os.path.exists(binary.rstrip().split("/")[1]):
+ os.remove(binary.rstrip().split("/")[1])