Skip to content

Commit

Permalink
added logging and converted to property
Browse files Browse the repository at this point in the history
  • Loading branch information
luciang committed Mar 27, 2009
1 parent aa1a0f7 commit 4676f23
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bin/db_gentest.py
Expand Up @@ -16,7 +16,7 @@
GRADE_FILENAME = 'NOTA'

if __name__ == "__main__":
root = misc.VmcheckerPaths().dir_checked()
root = misc.VmcheckerPaths().dir_checked

if not os.path.exists(root):
print " %s directory does not exist " % root
Expand Down
18 changes: 10 additions & 8 deletions bin/initialise_course.py
Expand Up @@ -9,17 +9,21 @@
import sqlite3
import misc
import sys
import logging

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("vmchecker.initialise_course")
logger.setLevel(logging.DEBUG)
#logger.basicConfig(level=logger.DEBUG)

def create_storer_paths():
""" Create all paths used by vmchecker on the storer machine"""
storer_paths = misc.VmcheckerPaths().storer_paths()
storer_paths = misc.VmcheckerPaths().storer_paths
for path in storer_paths:
if not(os.path.isdir(path)):
os.mkdir(path)
else:
print("[%s] Skipping existing directory %s" % (
sys.argv[0], path))
logger.info("Skipping existing directory %s" % path)



Expand Down Expand Up @@ -47,21 +51,19 @@ def create_db_tables(db_path):

def create_db():
# check for DB existance
db_file = misc.VmcheckerPaths().db_file()
db_file = misc.VmcheckerPaths().db_file
if None == db_file:
create_db(db_file)
else:
print("[%s] Skipping existing Sqlite3 DB file %s" % (
sys.argv[0], db_file))
logger.info("Skipping existing Sqlite3 DB file %s" % db_file)




def main():
create_storer_paths()
create_db()
print("[%s] storer init done setting up paths and db file." % (
sys.argv[0]))
logger.info(" -- storer init done setting up paths and db file.")

if __name__ == '__main__':
main()
12 changes: 6 additions & 6 deletions bin/misc.py
Expand Up @@ -32,7 +32,7 @@ def config():

def relative_path(*args):
"""Joins the arguments and returns a path relative to root"""
return os.path.join(VmcheckerPaths().root(), os.path.join(*args))
return os.path.join(VmcheckerPaths().root, os.path.join(*args))


def repository(assignment):
Expand Down Expand Up @@ -61,7 +61,7 @@ def db_file():
@return
- absolute path of config file
- None if the path isn't a file"""
path = VmcheckerPaths().db_file()
path = VmcheckerPaths().db_file
if os.path.isfile(path):
return path
else:
Expand All @@ -74,7 +74,7 @@ def __init__(self):
pass

def abs_path(self, relative):
return os.path.join(self.root(), relative)
return os.path.join(self.root, relative)

@property
def root(self):
Expand All @@ -85,13 +85,13 @@ def root(self):
@property
def tester_paths(self):
""" A list of all the paths relevant to the tester machine."""
return [self.dir_queue()]
return [self.dir_queue]

@property
def storer_paths(self):
""" A list of all the paths relevant to the storer machine."""
return [self.dir_unchecked(), self.dir_checked(),
self.dir_backup(), self.dir_tests()]
return [self.dir_unchecked, self.dir_checked,
self.dir_backup, self.dir_tests]

@property
def dir_unchecked(self):
Expand Down
2 changes: 1 addition & 1 deletion bin/submit.py
Expand Up @@ -109,7 +109,7 @@ def submit_assignment(assignment_config):
fd = mkstemp(
suffix='.zip',
prefix='%s_%s_%s_' % (course, assignment, user),
dir=VmcheckerPaths().dir_unchecked())
dir=VmcheckerPaths().dir_unchecked)
print sys.stderr, 'Creating zip package at `%s\'' % fd[1]

# adds the files to
Expand Down
6 changes: 3 additions & 3 deletions bin/update_db.py
Expand Up @@ -11,10 +11,10 @@

GRADE_VALUE_FILE = 'nota'

vmchk_root = misc.VmcheckerPaths().root()
db_path = misc.VmcheckerPaths().db_file()
vmchk_root = misc.VmcheckerPaths().root
db_path = misc.VmcheckerPaths().db_file
cwd = os.getcwd()
checked_root = misc.VmcheckerPaths().dir_checked()
checked_root = misc.VmcheckerPaths().dir_checked

if not cwd.startswith(checked_root):
print "Error: working directory not in the VMCHECKER_ROOT subtree "
Expand Down

0 comments on commit 4676f23

Please sign in to comment.