Skip to content

Commit

Permalink
Changes to Process file in System workflow (#3016)
Browse files Browse the repository at this point in the history
* DownloadUrl Validation

Signed-off-by: Divya Madala <divyaasm@amazon.com>

DownloadUrl Verification

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Validate DownloadUrl's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Verify Download Url's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Verify Download Url's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Test

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Verify Download Url's

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Add Validation WorkFlow

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Add Validation Framework

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Changes to Validation Workflow

Signed-off-by: Divya Madala <divyaasm@amazon.com>

Changes to Validation Workflow

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Changes updated

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Changes updtaed to Validation workflow

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Changes Updated

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Validation workflow

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Changes to Process

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Changes to Process

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* changes

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* changes

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* changes

Signed-off-by: Divya Madala <divyaasm@amazon.com>

* Fix to process

Signed-off-by: Divya Madala <divyaasm@amazon.com>
Signed-off-by: Rishabh Singh <sngri@amazon.com>

Signed-off-by: Divya Madala <divyaasm@amazon.com>
Signed-off-by: Rishabh Singh <sngri@amazon.com>
  • Loading branch information
Divyaasm authored Jan 24, 2023
1 parent e2bcc63 commit d00dcf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/system/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import logging
import os
import subprocess
import tempfile
from typing import Any
Expand All @@ -24,8 +25,8 @@ def start(self, command: str, cwd: str) -> None:
if self.started:
raise ProcessStartedError(self.pid)

self.stdout = tempfile.NamedTemporaryFile(mode="r+")
self.stderr = tempfile.NamedTemporaryFile(mode="r+")
self.stdout = tempfile.NamedTemporaryFile(mode="r+", delete=False)
self.stderr = tempfile.NamedTemporaryFile(mode="r+", delete=False)

self.process = subprocess.Popen(
command,
Expand Down Expand Up @@ -54,13 +55,15 @@ def terminate(self) -> int:
logging.info(f"Process killed with exit code {self.process.returncode}")

if self.stdout:
self.__stdout_data__ = self.stdout.read()
self.__stdout_data__ = open(self.stdout.name, 'r').read()
self.stdout.close()
os.remove(self.stdout.name)
self.stdout = None

if self.stderr:
self.__stderr_data__ = self.stderr.read()
self.__stderr_data__ = open(self.stderr.name, 'r').read()
self.stderr.close()
os.remove(self.stderr.name)
self.stderr = None

self.return_code = self.process.returncode
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_system/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test(self) -> None:
def test_file_open_mode(self, mock_tempfile: MagicMock) -> None:
process_handler = Process()
process_handler.start("./tests/tests_system/data/wait_for_input.sh", ".")
mock_tempfile.assert_has_calls([call(mode="r+"), call(mode="r+")])
mock_tempfile.assert_has_calls([call(delete=False, mode='r+'), call(delete=False, mode='r+')])

def test_start_twice(self) -> None:
process_handler = Process()
Expand Down

0 comments on commit d00dcf8

Please sign in to comment.