Пример #1
0
    def testFn_ReadString(self):
        """Test the wdl built-in functional equivalent of 'read_string()'."""
        some_str = 'some string'
        path = self._write_temp_file('read_string', content=some_str)
        self.assertEqual(some_str, read_string(path))

        # with preceding newlines. Cromwell strips from the front and the end.
        path = self._write_temp_file('read_string',
                                     content='\n\n\n' + some_str)
        self.assertEqual(some_str, read_string(path))

        # with trailing newlines
        path = self._write_temp_file('read_string', content=some_str + '\n\n')
        self.assertEqual(some_str, read_string(path))
Пример #2
0
    def run(self, fileStore):
        fileStore.logToMaster("hostTask")
        tempDir = fileStore.getLocalTempDir()

        try:
            os.makedirs(os.path.join(tempDir, 'execution'))
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

        i = self.id_i

        try:
            # Intended to deal with "optional" inputs that may not exist
            # TODO: handle this better
            command0 = r'''
        		hostname	
        		sleep 30
        	'''
        except:
            command0 = ''

        cmd = command0
        cmd = textwrap.dedent(cmd.strip("\n"))

        this_process = subprocess.Popen(cmd,
                                        shell=True,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)
        stdout, stderr = this_process.communicate()

        taskID = 'i'
        result = (read_string((stdout)))
        rvDict = {"taskID": taskID, "result": result}
        return rvDict