Skip to content

Commit

Permalink
Fix landscape bot complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
artikz authored and stefano-maggiolo committed Jul 9, 2015
1 parent 7eacd78 commit 09a92be
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
22 changes: 12 additions & 10 deletions cmscontrib/AddContest.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def do_import(self):
elif self.update_tasks:
contest = old_contest
else:
logger.critical("Contest \"%s\" already exists in database."
% contest.name)
logger.critical(
"Contest \"%s\" already exists in database.",
contest.name)
return

# Check needed tasks
Expand All @@ -122,19 +123,20 @@ def do_import(self):
taskname)
return
elif self.update_tasks:
task_loader = self.loader.get_task_loader(taskname);
task_loader = self.loader.get_task_loader(taskname)
if task_loader.task_has_changed():
new_task = task_loader.get_task()
if new_task:
self._update_object(task, new_task)
else:
logger.critical("Could not reimport task \"%s\"."
% taskname)
logger.critical("Could not reimport task \"%s\".",
taskname)
return

if task.contest is not None and task.contest.name != contest.name:
if task.contest is not None \
and task.contest.name != contest.name:
logger.critical("Task \"%s\" is already tied to a "
"contest." % taskname)
"contest.", taskname)
return
else:
# We should tie this task to the contest
Expand All @@ -148,8 +150,8 @@ def do_import(self):
if user is None:
# FIXME: it would be nice to automatically try to
# import.
logger.critical("User \"%s\" not found in database."
% username)
logger.critical("User \"%s\" not found in database.",
username)
return
# We should tie this user to a new contest
# FIXME: there is no way for the loader to specify
Expand All @@ -170,7 +172,7 @@ def do_import(self):

# Final commit
session.commit()
logger.info("Import finished (new contest id: %s)." % contest.id)
logger.info("Import finished (new contest id: %s).", contest.id)


def main():
Expand Down
10 changes: 5 additions & 5 deletions cmscontrib/AddTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ def do_import(self):
with SessionGen() as session:
# Check whether the task already exists
old_task = session.query(Task) \
.filter(Task.name == task.name) \
.first()
.filter(Task.name == task.name) \
.first()
if old_task is not None:
if self.update:
if self.loader.task_has_changed():
self._update_object(old_task, task)
task = old_task
else:
logger.critical("Task \"%s\" already exists in database."
% task.name)
logger.critical("Task \"%s\" already exists in database.",
task.name)
return
else:
session.add(task)
session.commit()
task_id = task.id

logger.info("Import finished (task id: %s)." % task_id)
logger.info("Import finished (task id: %s).", task_id)


def main():
Expand Down
3 changes: 2 additions & 1 deletion cmscontrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
import io
import os

from cms.db import Contest, User, Task, Submission, Base
from cms.db import Contest, Task, Submission, Base


def sha1sum(path):
"""Calculates the SHA1 sum of a file, given by its path.
Expand Down
1 change: 0 additions & 1 deletion cmscontrib/loaders/italy_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def detect(path):
os.path.exists(os.path.join(os.path.dirname(path), "contest.yaml"))

def get_task_loader(self, taskname):
taskpath = os.path.join(self.path, taskname)
return YamlLoader(self.path, self.file_cacher)

def get_contest(self):
Expand Down

0 comments on commit 09a92be

Please sign in to comment.