pyreposync 0.2.7__py3-none-any.whl → 0.2.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyreposync/downloader.py CHANGED
@@ -71,13 +71,11 @@ class Downloader(object):
71
71
 
72
72
  with open(destination, "rb") as dest:
73
73
  hasher.update(dest.read())
74
- self.log.debug(f"expected hash: {hasher.hexdigest()}")
75
- self.log.debug(f"actual hash: {checksum}")
76
74
  if hasher.hexdigest() == checksum:
77
- self.log.debug(f"download valid: {destination}")
75
+ self.log.debug(f"download valid: {destination}, expected hash: {hasher.hexdigest()}, actual hash: {checksum}")
78
76
  else:
79
- self.log.error(f"download invalid: {destination}")
80
- raise OSRepoSyncHashError(f"download invalid: {destination}")
77
+ self.log.error(f"download invalid: {destination} expected hash: {hasher.hexdigest()}, actual hash: {checksum}")
78
+ raise OSRepoSyncHashError(f"download invalid: {destination} expected hash: {hasher.hexdigest()}, actual hash: {checksum}")
81
79
 
82
80
  def get(
83
81
  self,
@@ -88,11 +86,11 @@ class Downloader(object):
88
86
  replace=False,
89
87
  not_found_ok=False,
90
88
  ):
91
- self.log.info(f"downloading: {url}")
92
89
  if not replace:
93
90
  if os.path.isfile(destination):
94
- self.log.info("already there, not downloading")
91
+ self.log.debug(f"{url} already there, not downloading")
95
92
  return
93
+ self.log.info(f"{url} downloading")
96
94
  retries = 10
97
95
  while retries >= 0:
98
96
  try:
@@ -107,7 +105,7 @@ class Downloader(object):
107
105
  pass
108
106
  else:
109
107
  raise
110
- self.log.info(f"done downloading: {url}")
108
+ self.log.info(f"{url} download done")
111
109
  return
112
110
  except requests.exceptions.ConnectionError:
113
111
  self.log.error("could not fetch resource, retry in 10 seconds")
@@ -119,8 +117,8 @@ class Downloader(object):
119
117
  time.sleep(10)
120
118
  except OSRepoSyncDownLoadError:
121
119
  break
122
- self.log.error(f"could not download: {url}")
123
- raise OSRepoSyncDownLoadError(f"could not download: {url}")
120
+ self.log.error(f"{url} could not download")
121
+ raise OSRepoSyncDownLoadError(f"{url} could not download")
124
122
 
125
123
  def create_dir(self, destination):
126
124
  if not os.path.isdir(os.path.dirname(destination)):
pyreposync/sync_deb822.py CHANGED
@@ -1,8 +1,11 @@
1
1
  from shutil import copyfile
2
+ import threading
2
3
 
3
4
  import gzip
5
+ import lzma
4
6
  import os
5
7
 
8
+ from pyreposync import OSRepoSyncException
6
9
  from pyreposync.sync_generic import SyncGeneric
7
10
 
8
11
 
@@ -55,15 +58,34 @@ class SyncDeb822(SyncGeneric):
55
58
  return self._components
56
59
 
57
60
  def _snap(self):
61
+ jobs = []
58
62
  for suite in self.suites:
59
- self.snap_suites(suite=suite)
63
+ job = threading.Thread(
64
+ name=f"{threading.current_thread().name}_{suite}",
65
+ target=self.snap_suites,
66
+ kwargs={"suite": suite},
67
+ )
68
+ job.start()
69
+ jobs.append(job)
70
+ for job in jobs:
71
+ job.join()
60
72
 
61
73
  def snap_suites(self, suite):
62
74
  self.log.info(f"creating snapshot for suite {suite}")
63
75
  self.snap_release(suite=suite)
64
76
  self.snap_release_files(suite=suite)
65
- for arch in self.binary_archs:
66
- self.snap_package_binary_files(suite=suite, arch=arch)
77
+ jobs = []
78
+ for component in self.components:
79
+ for arch in self.binary_archs:
80
+ job = threading.Thread(
81
+ name=f"{threading.current_thread().name}_{component}_{arch}",
82
+ target=self.snap_package_binary_files,
83
+ kwargs={"suite": suite, "component": component, "arch": arch},
84
+ )
85
+ job.start()
86
+ jobs.append(job)
87
+ for job in jobs:
88
+ job.join()
67
89
  self.log.info(f"creating snapshot for suite {suite}, done")
68
90
 
69
91
  def snap_release(self, suite):
@@ -99,11 +121,11 @@ class SyncDeb822(SyncGeneric):
99
121
  pass
100
122
  self.log.info(f"creating snapshot for suite {suite} release files, done")
101
123
 
102
- def snap_package_binary_files(self, suite, arch):
124
+ def snap_package_binary_files(self, suite, component, arch):
103
125
  self.log.info(
104
- f"creating snapshot for suite {suite} arch {arch} package binary files"
126
+ f"creating snapshot for suite {suite} component {component} arch {arch} package binary files"
105
127
  )
106
- packages = self.binary_files_sha256(suite=suite, component="main", arch=arch)
128
+ packages = self.binary_files_sha256(suite=suite, component=component, arch=arch)
107
129
  src_path = f"{self.destination}/sync/{self.reponame}"
108
130
  dst_path = f"{self.destination}/snap/{self.reponame}/{self.date}"
109
131
  for filename, sha256_dict in packages.items():
@@ -120,16 +142,35 @@ class SyncDeb822(SyncGeneric):
120
142
 
121
143
  def sync(self):
122
144
  self.log.info("starting thread")
145
+ jobs = []
123
146
  for suite in self.suites:
124
- self.sync_suites(suite=suite)
147
+ job = threading.Thread(
148
+ name=f"{threading.current_thread().name}_{suite}",
149
+ target=self.sync_suites,
150
+ kwargs={"suite": suite},
151
+ )
152
+ job.start()
153
+ jobs.append(job)
154
+ for job in jobs:
155
+ job.join()
125
156
  self.log.info("shutdown thread complete")
126
157
 
127
158
  def sync_suites(self, suite):
128
159
  self.log.info(f"syncing suite {suite}")
129
160
  self.sync_release(suite=suite)
130
161
  self.sync_release_files(suite=suite)
131
- for arch in self.binary_archs:
132
- self.sync_package_binary_files(suite=suite, arch=arch)
162
+ jobs = []
163
+ for component in self.components:
164
+ for arch in self.binary_archs:
165
+ job = threading.Thread(
166
+ name=f"{threading.current_thread().name}_{component}_{arch}",
167
+ target=self.sync_package_binary_files,
168
+ kwargs={"suite": suite, "component": component, "arch": arch},
169
+ )
170
+ job.start()
171
+ jobs.append(job)
172
+ for job in jobs:
173
+ job.join()
133
174
  self.log.info(f"syncing suite {suite}, done")
134
175
 
135
176
  def sync_release(self, suite):
@@ -146,9 +187,9 @@ class SyncDeb822(SyncGeneric):
146
187
  )
147
188
  self.log.info(f"syncing suite {suite} release files, done")
148
189
 
149
- def sync_package_binary_files(self, suite, arch):
190
+ def sync_package_binary_files(self, suite, component, arch):
150
191
  self.log.info(f"syncing suite {suite} arch {arch} package binary files")
151
- packages = self.binary_files_sha256(suite=suite, component="main", arch=arch)
192
+ packages = self.binary_files_sha256(suite=suite, component=component, arch=arch)
152
193
  base_path = f"{self.destination}/sync/{self.reponame}"
153
194
  base_url = f"{self.base_url}"
154
195
  for filename, sha256_dict in packages.items():
@@ -162,12 +203,26 @@ class SyncDeb822(SyncGeneric):
162
203
  self.log.info(f"syncing suite {suite} arch {arch} package binary files, done")
163
204
 
164
205
  def binary_files_sha256(self, suite, component, arch):
165
- packages_gz_file = f"{self.destination}/sync/{self.reponame}/dists/{suite}/{component}/binary-{arch}/Packages.gz"
206
+ packages_file = f"{self.destination}/sync/{self.reponame}/dists/{suite}/{component}/binary-{arch}/Packages."
207
+ if os.path.isfile(f"{packages_file}gz"):
208
+ comp = gzip
209
+ packages_file += "gz"
210
+ elif os.path.isfile(f"{packages_file}xz"):
211
+ comp = lzma
212
+ packages_file += "xz"
213
+ else:
214
+ self.log.error(
215
+ f"no Packages.gz or Packages.xz file found for suite {suite}, component {component}, arch {arch}"
216
+ )
217
+ raise OSRepoSyncException(
218
+ f"no Packages.gz or Packages.xz file found for suite {suite}, component {component}, arch {arch}"
219
+ )
220
+
166
221
  packages = dict()
167
222
  sha256 = None
168
223
  filename = None
169
224
  size = None
170
- with gzip.open(packages_gz_file, "rb") as source:
225
+ with comp.open(packages_file, "rb") as source:
171
226
  for line in source:
172
227
  line = line.decode("utf-8")
173
228
  if line.startswith("SHA256: "):
pyreposync/sync_rpm.py CHANGED
@@ -252,14 +252,15 @@ class SyncRPM(SyncGeneric):
252
252
  def snap_treeinfo(self):
253
253
  self.log.info("copy treeinfo")
254
254
  try:
255
- dst = f"{self.destination}/snap/{self.reponame}/{self.destination}/{self.treeinfo}"
255
+ dst = f"{self.destination}/snap/{self.reponame}/{self.date}/{self.treeinfo}"
256
256
  src = f"{self.destination}/sync/{self.reponame}/{self.treeinfo}"
257
257
  copyfile(src, dst)
258
258
  except (OSError, FileNotFoundError) as err:
259
259
  self.log.error(f"could not copy {self.treeinfo}: {err}")
260
+ self.log.error(dst)
260
261
  for location, hash_algo, hash_sum in self.treeinfo_files():
261
262
  dst = (
262
- f"{self.destination}/snap/{self.reponame}/{self.destination}/{location}"
263
+ f"{self.destination}/snap/{self.reponame}/{self.date}/{location}"
263
264
  )
264
265
  src = f"{self.destination}/sync/{self.reponame}/{location}"
265
266
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyreposync
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: rpm and deb822 repository sync tool
5
5
  Project-URL: Source, https://github.com/schlitzered/pyreposync
6
6
  Author-email: "Stephan.Schultchen" <sschultchen@gmail.com>
@@ -0,0 +1,11 @@
1
+ pyreposync/__init__.py,sha256=fHirsBBkEk806RJwVKQZHgujQZRk13YnokX-8rp_QJE,17117
2
+ pyreposync/downloader.py,sha256=rEv9lOg2X1VwCtADO63-yceZAZCeSJOBIGbyRsEnKQU,5275
3
+ pyreposync/exceptions.py,sha256=IlnvhNaffQQ6geOgrjCciNFVbFpNcycH4ijSuMTbrGA,169
4
+ pyreposync/sync_deb822.py,sha256=7Cuzg-1pC8WDiFTxw-qH26VsfzOEY9IxfZztGfLkdKg,10513
5
+ pyreposync/sync_generic.py,sha256=qe-ERp8O2kCnhOuToSZWhdQzGY7aYb7G7nUxuKD3lxY,5880
6
+ pyreposync/sync_rpm.py,sha256=bl1mVX8LZt5AF33o-oVsmaNwzC9teLN-quQMkQrwyUk,11781
7
+ pyreposync-0.2.8.dist-info/METADATA,sha256=4ZJYmZtU02e0YaE1-awb39qUPIwAqKwl2fdhiyGfimY,1591
8
+ pyreposync-0.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ pyreposync-0.2.8.dist-info/entry_points.txt,sha256=9LsBDWOF3O6_3ONP3Lc-4v1MTt5ay0Xv-TMcFbOIt2s,47
10
+ pyreposync-0.2.8.dist-info/licenses/LICENSE.txt,sha256=lwnJoIo7uwc0h6y6gC_RYqJkvjplViV3Ad6u7pQM4Bw,1084
11
+ pyreposync-0.2.8.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- pyreposync/__init__.py,sha256=fHirsBBkEk806RJwVKQZHgujQZRk13YnokX-8rp_QJE,17117
2
- pyreposync/downloader.py,sha256=cRUtbQ4PYbGDczZl5PsBtTQFhqagnX9IQvbwSCd0OBc,5212
3
- pyreposync/exceptions.py,sha256=IlnvhNaffQQ6geOgrjCciNFVbFpNcycH4ijSuMTbrGA,169
4
- pyreposync/sync_deb822.py,sha256=Ynwok1fiZktO3P_0lYWfBOHgaJOFpzfVNkhgKL5Y56s,8517
5
- pyreposync/sync_generic.py,sha256=qe-ERp8O2kCnhOuToSZWhdQzGY7aYb7G7nUxuKD3lxY,5880
6
- pyreposync/sync_rpm.py,sha256=FXWEJd2YelMsZeTOnjcNjkN2D_ECtX9HEp73GpiLeK4,11763
7
- pyreposync-0.2.7.dist-info/METADATA,sha256=t_2vG9j5arm-bG1SyZ0DDqADLwQKEiqS66EZ-q1VnJE,1591
8
- pyreposync-0.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- pyreposync-0.2.7.dist-info/entry_points.txt,sha256=9LsBDWOF3O6_3ONP3Lc-4v1MTt5ay0Xv-TMcFbOIt2s,47
10
- pyreposync-0.2.7.dist-info/licenses/LICENSE.txt,sha256=lwnJoIo7uwc0h6y6gC_RYqJkvjplViV3Ad6u7pQM4Bw,1084
11
- pyreposync-0.2.7.dist-info/RECORD,,