Commit 178be2a7 authored by ale's avatar ale

* upgraded jobserver model to sqlalchemy 0.5

* the incoming agent should upload files to the long-term storage
parent 5264d84f
......@@ -221,7 +221,7 @@ class HTMLPage:
if job.status == model.Job.STATUS_ASSIGNED:
dates.append(job.assigned_at)
date_str = '  -  '.join(map(self.fmt_date, dates))
out.append('<br/><span class="date">%s</span>' % date)
out.append('<br/><span class="date">%s</span>' % date_str)
out.append('</div></div>\n')
return ''.join(out)
def list_nodes(self, nodes):
......@@ -261,13 +261,13 @@ class JSStatusSummary(HTMLPage):
# table of (title, status, sort_field, results_count)
joblists = [
("Currently running jobs", model.Job.STATUS_ASSIGNED,
model.Job.c.assigned_at, None),
model.Job.assigned_at, None),
("Pending jobs", model.Job.STATUS_NEW,
model.Job.c.created_at, None),
model.Job.created_at, None),
("Last completed jobs", model.Job.STATUS_COMPLETE,
model.Job.c.completed_at, 5),
model.Job.completed_at, 5),
("Last errors <a href=\"/status/errors\">(all)</a>",
model.Job.STATUS_ERROR, model.Job.c.completed_at, 5)
model.Job.STATUS_ERROR, model.Job.completed_at, 5)
]
for label, status, sort_field, limit in joblists:
query = model.Job.query.filter_by(status=status)\
......@@ -282,7 +282,7 @@ class JSStatusSummary(HTMLPage):
web.output("<h4>Active nodes</h4>")
web.output('<table class="nodes">')
active_nodes = model.Node.query.filter_by(enabled=True).order_by(
desc(model.Node.c.stamp))
desc(model.Node.stamp))
web.output(self.list_nodes(active_nodes))
self.end_page()
......@@ -292,7 +292,7 @@ class JSErrorSummary(HTMLPage):
def GET(self):
self.start_page("jobserver errors")
error_jobs = model.Job.query.filter_by(status=model.Job.STATUS_ERROR)\
.order_by(desc(model.Job.c.completed_at))
.order_by(desc(model.Job.completed_at))
web.output("<h4>All errors</h4>")
web.output(self.list_jobs(error_jobs))
self.end_page()
......@@ -345,7 +345,7 @@ class JSNodeSummary(HTMLPage):
web.output('</table>')
web.output('<h4>Latest jobs</h4>')
query = model.Job.query.filter_by(assigned_to=node).\
order_by(desc(model.Job.c.assigned_at)).limit(5)
order_by(desc(model.Job.assigned_at)).limit(5)
web.output(self.list_jobs(query))
web.output('<br/><p><a href="/status">Return to jobserver status page</a></p>')
self.end_page()
......
......@@ -62,7 +62,7 @@ class Job(object):
raise Exception("complete() called on job with status=%s" % self.status)
self.status = self.STATUS_COMPLETE
self.completed_at = datetime.now()
Session.update(self)
Session.add(self)
Session.commit()
def error(self, err_msg):
......@@ -73,7 +73,7 @@ class Job(object):
self.completed_at = datetime.now()
self.errors = 'ERROR (node=%s, job=%s):\n\n%s' % (
self.assigned_to.name, self.id, err_msg)
Session.update(self)
Session.add(self)
Session.commit()
def short_error(self):
......@@ -89,7 +89,7 @@ class Job(object):
def log(self, message):
"""Append a log message for this job."""
self.worklogs.append(Worklog(message=message))
Session.update(self)
Session.add(self)
Session.commit()
def worklog(self):
......@@ -105,7 +105,7 @@ class Job(object):
created_at=datetime.now(),
status=cls.STATUS_NEW,
id=gen_id())
Session.save(job)
Session.add(job)
Session.commit()
return job
......@@ -147,7 +147,7 @@ class Job(object):
% (j.id, j.assigned_to.name, j.assigned_to.group_name))
j.status = cls.STATUS_NEW
j.assigned_to = None
session.update(j)
session.add(j)
session.commit()
......
......@@ -25,7 +25,7 @@ class Node(object):
def ping(self):
session = Session()
self.stamp = datetime.now()
session.update(self)
session.add(self)
session.commit()
@classmethod
......@@ -39,7 +39,7 @@ class Node(object):
node = cls(name=name, group_name=group, data=data)
node.stamp = datetime.now()
node.enabled = True
session.save_or_update(node)
session.add(node)
session.commit()
@classmethod
......@@ -47,9 +47,9 @@ class Node(object):
session = Session()
now = datetime.now()
limit = now - timedelta(0, cls.EXPIRATION_TIME)
for n in cls.query.filter(cls.c.stamp < limit):
for n in cls.query.filter(nodes_table.c.stamp < limit):
n.enabled = False
session.update(n)
session.add(n)
session.commit()
......
......@@ -151,7 +151,8 @@ def with_local_copy(remote_server, storage, next):
while retries > 0:
url = parms['links'][random.randrange(0, len(parms['links']))]
if url.startswith('/'):
url = 'http://localhost:5001%s' % url
parms['log']('warning: relative download path: %s' % url)
url = 'http://experimental.ngvision.org%s' % url
try:
parms['log']('downloading file from %s' % url)
outf = storage.open(parms['file_id'], 'w')
......
......@@ -63,8 +63,8 @@ def main(args):
remote_server,
seq(
identify(),
#upload_to_storage(remote_server),
#push_to_dist(dist_storage, remote_server, dist_base_url),
upload_to_storage(remote_server),
push_to_dist(dist_storage, remote_server, dist_base_url),
ignore_parms(screenshots_task),
)
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment