def check_submission( self, student ): stud_repo = repo.get_repo( student, self.pull ) if stud_repo == None: return ( self.EMPTY, None ) state = self.COMPLETE first = self.first_full_commit( stud_repo ) sub_dir = self.dir if first == None: #either a required file is missing, or the dir is mis-named dir_matches = [] first = repo.find_first_commit( stud_repo, '(?i)' + self.dir, matches = dir_matches, tabs = self.r_tabs ) if first == None: return ( self.MISSING, None ) else: state = self.MALFORMED sub_dir = dir_matches[0] first_date = repo.commit_datetime( first ) submissions = [] def add_subm( commit ): if len(submissions) == 0 or \ submissions[len(submissions)-1].commit != commit: submissions.append( Submission( self, commit, len(submissions) == 0, dir = sub_dir ) ) for dd in [self.due_date, self.drop_dead_date, None]: if dd == None or first_date < dd: add_subm( repo.find_last_commit( stud_repo, sub_dir, dd, tabs = self.r_tabs ) ) return (state, submissions)
def initialize(): global global_db, local_db, search_dbs, compress_by_default, db_access, \ git_bin, debug if configuration.check('git_bin'): git_bin = configuration.git_bin if git_bin.startswith("@executable_path/"): non_expand_path = git_bin git_bin = get_executable_path(git_bin[len("@executable_path/"):]) if git_bin is not None: configuration.git_bin = non_expand_path if git_bin is None: git_bin = 'git' configuration.git_bin = git_bin if configuration.check('compress_by_default'): compress_by_default = configuration.compress_by_default if configuration.check('debug'): debug = configuration.debug if configuration.check('global_db'): global_db = configuration.global_db if configuration.check('local_db'): local_db = configuration.local_db if not os.path.exists(local_db): raise RuntimeError('local_db "%s" does not exist' % local_db) else: local_db = os.path.join(current_dot_vistrails(), 'persistent_files') if not os.path.exists(local_db): try: os.mkdir(local_db) except OSError: raise RuntimeError('local_db "%s" does not exist' % local_db) local_repo = repo.get_repo(local_db) repo.set_current_repo(local_repo) debug_print('creating DatabaseAccess') db_path = os.path.join(local_db, '.files.db') db_access = DatabaseAccessSingleton(db_path) debug_print('done', db_access) search_dbs = [ local_db, ] if configuration.check('search_dbs'): try: check_paths = literal_eval(configuration.search_dbs) except Exception: print "*** persistence error: cannot parse search_dbs ***" else: for path in check_paths: if os.path.exists(path): search_dbs.append(path) else: print '*** persistence warning: cannot find path "%s"' % path
def initialize(): global global_db, local_db, search_dbs, compress_by_default, db_access, \ git_bin, debug if configuration.check('git_bin'): git_bin = configuration.git_bin if git_bin.startswith("@executable_path/"): non_expand_path = git_bin git_bin = get_executable_path(git_bin[len("@executable_path/"):]) if git_bin is not None: configuration.git_bin = non_expand_path if git_bin is None: git_bin = 'git' configuration.git_bin = git_bin if configuration.check('compress_by_default'): compress_by_default = configuration.compress_by_default if configuration.check('debug'): debug = configuration.debug if configuration.check('global_db'): global_db = configuration.global_db if configuration.check('local_db'): local_db = configuration.local_db if not os.path.exists(local_db): raise RuntimeError('local_db "%s" does not exist' % local_db) else: local_db = os.path.join(current_dot_vistrails(), 'persistent_files') if not os.path.exists(local_db): try: os.mkdir(local_db) except OSError: raise RuntimeError('local_db "%s" does not exist' % local_db) local_repo = repo.get_repo(local_db) repo.set_current_repo(local_repo) debug_print('creating DatabaseAccess') db_path = os.path.join(local_db, '.files.db') db_access = DatabaseAccessSingleton(db_path) debug_print('done', db_access) search_dbs = [local_db,] if configuration.check('search_dbs'): try: check_paths = literal_eval(configuration.search_dbs) except Exception: print "*** persistence error: cannot parse search_dbs ***" else: for path in check_paths: if os.path.exists(path): search_dbs.append(path) else: print '*** persistence warning: cannot find path "%s"' % path