return mirror
- def get_random(self, limit=None):
- query = "SELECT id FROM mirrors WHERE status = 'enabled' ORDER BY RAND()"
- args = []
-
- if limit:
- query += " LIMIT %s"
- args.append(limit)
-
- mirrors = []
- for mirror in self.db.query(query, *args):
- mirror = Mirror(self.pakfire, mirror.id)
- mirrors.append(mirror)
-
- return mirrors
-
def get_by_id(self, id):
return self._get_mirror("SELECT * FROM mirrors WHERE id = %s", id)
mirrors = []
# Walk through all mirrors
- for mirror in self.get_all():
- if not mirror.enabled:
- continue
-
+ for mirror in self:
if mirror.country_code == country_code:
mirrors.append(mirror)
hostname = property(lambda self: self.data.hostname, set_hostname)
+ def set_deleted(self, deleted):
+ self._set_attribute("deleted", deleted)
+
+ deleted = property(lambda s: s.data.deleted, set_deleted)
+
@property
def path(self):
return self.data.path
return self.make_url()
def make_url(self, path=""):
- url = "http://%s%s" % (self.hostname, self.path)
+ url = "%s://%s%s" % (
+ "https" if self.supports_https else "http",
+ self.hostname,
+ self.path
+ )
if path.startswith("/"):
path = path[1:]
return urlparse.urljoin(url, path)
+ def set_supports_https(self, supports_https):
+ self._set_attribute("supports_https", supports_https)
+
+ supports_https = property(lambda s: s.data.supports_https, set_supports_https)
+
def set_owner(self, owner):
self._set_attribute("owner", owner)