self._db = psycopg2.connect(**self._db_args)
self._db.autocommit = True
+ # Initialize the timezone setting.
+ self.execute("SET TIMEZONE TO 'UTC'")
+
def query(self, query, *parameters, **kwparameters):
"""
Returns a row list for the given query and parameters.
except ValueError:
timestamp = 0
- timestamp = datetime.datetime.fromtimestamp(timestamp)
+ timestamp = datetime.datetime.utcfromtimestamp(timestamp)
self.db.execute("UPDATE mirrors SET last_update = %s WHERE id = %s",
timestamp, self.id)
@property
def development(self):
- return self._info.get("development", False)
+ return self._info.get("mirrorlist_devel", False)
@property
def mirrorlist(self):
if not file:
return
- release = Release(file.releases)
- file = File(release, file.id)
+ release = Release(self.backend, file.releases)
+ file = File(self.backend, release, file.id)
return file
peer6["peer id"] = row.id
if peer4:
- peer6["peer id"] = row.id
+ peer4["peer id"] = row.id
if peer6:
peers.append(peer6)
Remove all peers that have timed out.
"""
self.db.execute("DELETE FROM tracker \
- WHERE last_update < NOW() - INTERVAL '%ss'", self.interval)
+ WHERE last_update < NOW() - INTERVAL '%ss'", self.interval + 600)
def update_peer(self, peer_id, info_hash, address6=None, port6=None,
address4=None, port4=None, downloaded=None, uploaded=None, left_data=None):
}
}
- for info_hash in info_hashes:
- ret["files"][info_hash] = {
- "complete" : self.complete(info_hash),
- "incomplete" : self.incomplete(info_hash),
- "downloaded" : 0,
- }
+ if info_hashes:
+ for info_hash in info_hashes:
+ ret["files"][info_hash] = {
+ "complete" : self.complete(info_hash),
+ "incomplete" : self.incomplete(info_hash),
+ "downloaded" : 0,
+ }
return ret
item = tornado.database.Row({
"title" : n.title,
"author" : n.author,
- "published" : n.date,
+ "published" : n.published,
"url" : "http://www.ipfire.org/news/%s" % n.slug,
"markup" : n.text,
})
from handlers_base import *
class StasyBaseHandler(BaseHandler):
- @property
- def stasy(self):
- return backend.Stasy()
-
def format_size(self, s):
units = ("K", "M", "G", "T")
unit = 0
if addr.is_private:
continue
- profile.geoip = self.geoip.get_all(remote_ip)
+ location = self.geoip.get_location(remote_ip)
+ if location:
+ profile.geoip = {
+ "country_code" : location.country,
+ }
+ else:
+ profile.geoip = None
+
break
# Move previous profiles to archive and keep only the latest one
# Get the external IP address of the client.
addr = self.get_remote_ip()
+ if addr.startswith("172.28.1."):
+ addr = "178.63.73.246"
+
if not ":" in addr:
return addr, default_port