Skip to content

Commit

Permalink
Let cmsMake ignores the statement if it's missing
Browse files Browse the repository at this point in the history
  • Loading branch information
veluca93 authored and stefano-maggiolo committed Aug 5, 2015
1 parent 2e3c7f9 commit 4f11113
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
9 changes: 4 additions & 5 deletions cmscontrib/loaders/italy_yaml.py
Expand Up @@ -344,7 +344,7 @@ def get_user(self):

return User(**args)

def get_task(self, get_statement):
def get_task(self, get_statement=True):
"""See docstring in class Loader.
"""
Expand Down Expand Up @@ -384,11 +384,10 @@ def get_task(self, get_statement):
logger.warning("Short name equals long name (title). "
"Please check.")

primary_language = load(conf, None, "primary_language")
if primary_language is None:
primary_language = 'it'

if get_statement:
primary_language = load(conf, None, "primary_language")
if primary_language is None:
primary_language = 'it'
paths = [os.path.join(self.path, "statement", "statement.pdf"),
os.path.join(self.path, "testo", "testo.pdf")]
for path in paths:
Expand Down
13 changes: 5 additions & 8 deletions cmstaskenv/Test.py
Expand Up @@ -30,7 +30,7 @@
import sys
import logging

import cmscontrib.YamlLoader
import cmscontrib.loaders
from cms.db import Executable
from cms.db.filecacher import FileCacher
from cms.grading import format_status_text
Expand Down Expand Up @@ -100,20 +100,17 @@ def test_testcases(base_dir, solution, language, assume=None):
if file_cacher is None:
file_cacher = FileCacher(null=True)

cmscontrib.YamlLoader.logger = NullLogger()
cmscontrib.loaders.italy_yaml.logger = NullLogger()
# Load the task
# TODO - This implies copying a lot of data to the FileCacher,
# which is annoying if you have to do it continuously; it would be
# better to use a persistent cache (although local, possibly
# filesystem-based instead of database-based) and somehow detect
# when the task has already been loaded
if task is None:
loader = cmscontrib.YamlLoader.YamlLoader(
os.path.realpath(os.path.join(base_dir, "..")),
file_cacher)
# Normally we should import the contest before, but YamlLoader
# accepts get_task() even without previous get_contest() calls
task = loader.get_task(os.path.split(os.path.realpath(base_dir))[1])
loader = cmscontrib.loaders.italy_yaml.YamlLoader(base_dir,
file_cacher)
task = loader.get_task(get_statement=False)

# Prepare the EvaluationJob
dataset = task.active_dataset
Expand Down
16 changes: 2 additions & 14 deletions cmstaskenv/cmsMake.py
Expand Up @@ -207,8 +207,7 @@ def build_sols_list(base_dir, task_type, in_out_files, yaml_conf):
STUB_BASENAME + '.%s' % (lang)))
srcs.append(src)

test_deps = \
[exe_EVAL, os.path.join(TEXT_DIRNAME, TEXT_PDF)] + in_out_files
test_deps = [exe_EVAL] + in_out_files
if task_type == ['Batch', 'Comp'] or \
task_type == ['Batch', 'GradComp']:
test_deps.append('cor/correttore')
Expand Down Expand Up @@ -325,22 +324,11 @@ def make_pdf(assume=None):
'-interaction', 'batchmode', text_tex],
env={'TEXINPUTS': '.:%s:%s/file:' % (TEXT_DIRNAME, TEXT_DIRNAME)})

def make_dummy_pdf(assume=None):
try:
open(text_pdf, 'r')
except IOError:
logger.warning(
"%s does not exist, creating an empty file..." % text_pdf
)
open(text_pdf, 'w')

actions = []
if os.path.exists(text_tex):
actions.append(([text_tex], [text_pdf, text_aux, text_log],
make_pdf, 'compile to PDF'))
else:
actions.append(([TEXT_DIRNAME], [text_pdf], make_dummy_pdf,
"create empty PDF file"))

return actions


Expand Down

0 comments on commit 4f11113

Please sign in to comment.