Exemple #1
0
    def check_all(self, zipcontents):
        try: 
            zipfile = io.BytesIO(zipcontents)
            zip_data = iocollect.extract_zip(zipfile) # contents of output zipfile produced by `python zipout.py` as a dict
        except:
            logging.error("Could not process zip file")
            return None

        # check if references has subdirectories
        try:
            ref_subdirs = iocollect.getdirs(os.path.abspath(self.ref_dir))
        except:
            logging.error("Internal Error: Could not find references.")
            return None

        if len(ref_subdirs) > 0:
            for subdir in ref_subdirs:
                try:
                    files = iocollect.getfiles(os.path.abspath(os.path.join(self.ref_dir, subdir)))
                except:
                    logging.error("Internal Error: Could not find references.")
                    return None
                self.check_path(subdir, files, zip_data)
        else:
            try:
                files = iocollect.getfiles(os.path.abspath(self.ref_dir))
            except:
                logging.error("Internal Error: Could not find references.")
                return None
            self.check_path(None, files, zip_data)

        if len(self.perf.keys()) == 0:
            return None

        return self.perf
    def check_all(self, zipcontents):
        zipfile = io.BytesIO(zipcontents)
        zip_data = iocollect.extract_zip(zipfile) # contents of output zipfile produced by `python zipout.py` as a dict

        # check if references has subdirectories
        ref_subdirs = iocollect.getdirs(os.path.abspath(self.ref_dir))
        if len(ref_subdirs) > 0:
            for subdir in ref_subdirs:
                files = iocollect.getfiles(os.path.abspath(os.path.join(self.ref_dir, subdir)))
                self.check_path(subdir, files, zip_data)
        else:
            files = iocollect.getfiles(os.path.abspath(self.ref_dir))
            self.check_path(None, files, zip_data)
        return self.perf
Exemple #3
0
    def check_all(self, zipcontents):
        zipfile = io.BytesIO(zipcontents)
        zip_data = iocollect.extract_zip(zipfile) # contents of output zipfile produced by `python zipout.py` as a dict

        # check if references has subdirectories
        ref_subdirs = iocollect.getdirs(os.path.abspath(self.ref_dir))
        if len(ref_subdirs) > 0:
            for subdir in ref_subdirs:
                files = iocollect.getfiles(os.path.abspath(os.path.join(self.ref_dir, subdir)))
                self.check_path(subdir, files, zip_data)
        else:
            files = iocollect.getfiles(os.path.abspath(self.ref_dir))
            self.check_path(None, files, zip_data)
        return self.perf
    def run_all(self):
        # check that a compiled binary exists to run on the input files
        argv = os.path.abspath(os.path.join(self.answer_dir, self.run_program))
        if not (os.path.isfile(argv)):
            logging.error("answer program missing: {}".format(argv))
            raise ValueError("Compile your source file to create an executable {}".format(argv))

        # check if input directory has subdirectories
        testcase_subdirs = iocollect.getdirs(os.path.abspath(self.input_dir))

        if len(testcase_subdirs) > 0:
            for subdir in testcase_subdirs:
                files = iocollect.getfiles(os.path.abspath(os.path.join(self.testcase_dir, subdir)))
                self.run_path(subdir, files)
        else:
            files = iocollect.getfiles(os.path.abspath(self.input_dir))
            self.run_path(None, files)

        return True
    def run_all(self):
        # check that a compiled binary exists to run on the testcases
        argv = os.path.abspath(os.path.join(self.answer_dir, self.run_program))
        if not (os.path.isfile(argv) and os.access(argv, os.X_OK)):
            logging.error("executable missing: {0}".format(argv))
            print >>sys.stderr, "Compile your source file to create an executable {0}".format(argv)
            sys.exit(1)

        # check if testcases has subdirectories
        testcase_subdirs = iocollect.getdirs(os.path.abspath(self.testcase_dir))

        if len(testcase_subdirs) > 0:
            for subdir in testcase_subdirs:
                files = iocollect.getfiles(os.path.abspath(os.path.join(self.testcase_dir, subdir)))
                self.run_path(subdir, files)
        else:
            files = iocollect.getfiles(os.path.abspath(self.testcase_dir))
            self.run_path(None, files)

        return True
Exemple #6
0
    def run_all(self):
        # check that a compiled binary exists to run on the testcases
        argv = os.path.abspath(os.path.join(self.answer_dir, self.run_program))
        if not (os.path.isfile(argv) and os.access(argv, os.X_OK)):
            logging.error("executable missing: {}".format(argv))
            print >>sys.stderr, "Compile your source file to create an executable {}".format(argv)
            sys.exit(1)

        # check if testcases has subdirectories
        testcase_subdirs = iocollect.getdirs(os.path.abspath(self.testcase_dir))

        if len(testcase_subdirs) > 0:
            for subdir in testcase_subdirs:
                files = iocollect.getfiles(os.path.abspath(os.path.join(self.testcase_dir, subdir)))
                self.run_path(subdir, files)
        else:
            files = iocollect.getfiles(os.path.abspath(self.testcase_dir))
            self.run_path(None, files)

        return True
Exemple #7
0
                         help="answer directory containing your source files")
    optparser.add_option("-s",
                         "--srcfile",
                         dest="src_file",
                         default='zhsegment.py',
                         help="name of source file for homework")
    optparser.add_option("-n",
                         "--notebook",
                         dest="notebook_file",
                         default='zhsegment.ipynb',
                         help="name of iPython notebook for homework")
    optparser.add_option(
        "-z",
        "--zipfile",
        dest="zipfile",
        default='source',
        help="zip file you should upload to Coursys (courses.cs.sfu.ca)")
    (opts, _) = optparser.parse_args()

    answer_files = iocollect.getfiles(opts.answer_dir)
    if opts.src_file not in answer_files:
        raise ValueError(
            "Error: missing answer file {}. Did you name your answer program correctly?"
            .format(opts.src_file))
    if opts.notebook_file not in answer_files:
        raise ValueError(
            "Error: missing notebook file {}. Did you name your iPython notebook correctly?"
            .format(opts.notebook_file))
    outputs_zipfile = shutil.make_archive(opts.zipfile, 'zip', opts.answer_dir)
    print("{0} created".format(outputs_zipfile), file=sys.stderr)