Пример #1
0
 def testPrepareFilesStrategyZipShouldUnpackTheZipFileAssociatedWithTheDeliveryToTheGivenPath(
         self):
     strategy = PrepareFilesStrategyZip()
     strategy.zip = TestPrepareFilesStrategy.ZIP_FILE_PATH
     strategy.prepare_files(TestPrepareFilesStrategy.UNZIP_DESTINATION_PATH)
     self.assertTrue(
         os.path.exists(TestPrepareFilesStrategy.UNZIP_DESTINATION_PATH +
                        TestPrepareFilesStrategy.ZIPPED_FILE_NAME))
Пример #2
0
class SetupEnviroment():

    def __init__(self):
        self.prepare_files_strategy = PrepareFilesStrategyZip()
        self.log = LoggerManager().get_new_logger("setup enviroment")
    
    def run(self, automatic_correction, working_dir):
        self.log.debug("setting up enviroment...")
        self.log.debug("cleaning up working directory...")
        shutil.rmtree(working_dir, ignore_errors=True)
        self.log.debug("preparing delivery files...")
        self.prepare_files_strategy.zip = automatic_correction.delivery
        os.mkdir(working_dir)
        self.prepare_files_strategy.prepare_files(working_dir)
        shutil.copy(automatic_correction.script, working_dir + "/" + os.path.basename(automatic_correction.script))
        # We must ensure the script is runnable
        process = subprocess.Popen(["chmod", "a+x", working_dir + "/" + os.path.basename(automatic_correction.script)])
        process.wait()
        self.log.debug("enviroment set.")
Пример #3
0
class SetupEnviroment():
    def __init__(self):
        self.prepare_files_strategy = PrepareFilesStrategyZip()
        self.log = LoggerManager().get_new_logger("setup enviroment")

    def run(self, automatic_correction, working_dir):
        self.log.debug("setting up enviroment...")
        self.log.debug("cleaning up working directory...")
        shutil.rmtree(working_dir, ignore_errors=True)
        self.log.debug("preparing delivery files...")
        self.prepare_files_strategy.zip = automatic_correction.delivery
        os.mkdir(working_dir)
        self.prepare_files_strategy.prepare_files(working_dir)
        shutil.copy(
            automatic_correction.script,
            working_dir + "/" + os.path.basename(automatic_correction.script))
        # We must ensure the script is runnable
        process = subprocess.Popen([
            "chmod", "a+x",
            working_dir + "/" + os.path.basename(automatic_correction.script)
        ])
        process.wait()
        self.log.debug("enviroment set.")
Пример #4
0
 def __init__(self):
     self.prepare_files_strategy = PrepareFilesStrategyZip()
     self.log = LoggerManager().get_new_logger("setup enviroment")
Пример #5
0
 def __init__(self):
     self.prepare_files_strategy = PrepareFilesStrategyZip()
     self.log = LoggerManager().get_new_logger("setup enviroment")
Пример #6
0
 def testPrepareFilesStrategyZipShouldRiseIllegalStateExceptionIfCalledWithoutSettingTheSourceFile(
         self):
     strategy = PrepareFilesStrategyZip()
     with self.assertRaises(IllegalStateException):
         strategy.prepare_files(
             TestPrepareFilesStrategy.UNZIP_DESTINATION_PATH)