Skip to content

Commit

Permalink
add @Property to VmcheckerPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
luciang committed Mar 27, 2009
1 parent 8eda330 commit 4ed4472
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bin/misc.py
Expand Up @@ -68,61 +68,71 @@ def db_file():
return None


class VmcheckerPaths:
class VmcheckerPaths(object):
""" All paths related to vmchecker. """
def __init__(self):
pass

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

@property
def root(self):
assert 'VMCHECKER_ROOT' in os.environ, (
'VMCHECKER_ROOT environment variable not defined')
return os.path.abspath(os.environ['VMCHECKER_ROOT'])

@property
def tester_paths(self):
""" A list of all the paths relevant to the tester machine."""
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()]

@property
def dir_unchecked(self):
""" The absolute path of the unchecked homeworks
are kept.
This path is valid on the storer machine."""
return self.abs_path("unchecked")

@property
def dir_checked(self):
""" The absolute path of the checked homeworks
are kept.
This path is valid on the storer machine."""
return self.abs_path("checked")

@property
def dir_tests(self):
""" The absolute path of the test archives for the
homeworks are kept.
This path is valid on the storer machine."""
return self.abs_path("tests")

@property
def dir_queue(self):
""" The absolute path of the task queue directory.
This path is valid on the tester machine."""
return self.abs_path("queue")

@property
def dir_backup(self):
""" The absolute path of the directory where backups
of tasks are kept.
This path is valid on the storer machine."""
return self.abs_path("back")

@property
def db_file(self):
""" The absolute path of the database file """
return self.abs_path("vmchecker.db")

@property
def config_file(self):
"""Returns absolute path for config file 'VMCHECKER_INI'"""
VMCHECKER_INI = 'vmchecker.ini'
Expand Down

0 comments on commit 4ed4472

Please sign in to comment.