-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source Code and Solution Download (#76)
* added fetch app source code logic * added solutions logic
- Loading branch information
1 parent
48f8346
commit 3e4c9cf
Showing
21 changed files
with
1,315 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
python-dateutil==2.8.2 | ||
python-dateutil==2.9.0.post0 | ||
requests==2.31.0 | ||
unittest-xml-reporting==3.2.0 | ||
xunitparser==1.3.4 | ||
toposort==1.10 | ||
python-dotenv==1.0.0 | ||
python-dotenv==1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class InvalidOutSystemsPackage(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Python Modules | ||
import os | ||
|
||
# Custom Modules | ||
# Exceptions | ||
from outsystems.exceptions.invalid_parameters import InvalidParametersError | ||
from outsystems.exceptions.environment_not_found import EnvironmentNotFoundError | ||
from outsystems.exceptions.not_enough_permissions import NotEnoughPermissionsError | ||
from outsystems.exceptions.server_error import ServerError | ||
# Functions | ||
from outsystems.lifetime.lifetime_base import send_download_request | ||
|
||
# Variables | ||
from outsystems.vars.lifetime_vars import DOWNLOAD_SUCCESS_CODE, DOWNLOAD_INVALID_KEY_CODE, \ | ||
DOWNLOAD_NO_PERMISSION_CODE, DOWNLOAD_NOT_FOUND, DOWNLOAD_FAILED_CODE | ||
|
||
|
||
# Downloads a binary file from a LifeTime download link | ||
def download_package(file_path: str, auth_token: str, pkg_url: str): | ||
# Sends the request | ||
response = send_download_request(pkg_url, auth_token) | ||
status_code = int(response["http_status"]) | ||
|
||
if status_code == DOWNLOAD_SUCCESS_CODE: | ||
# Remove the spaces in the filename | ||
file_path = file_path.replace(" ", "_") | ||
# Makes sure that, if a directory is in the filename, that directory exists | ||
os.makedirs(os.path.dirname(file_path), exist_ok=True) | ||
with open(file_path, "wb") as f: | ||
f.write(response["response"]) | ||
elif status_code == DOWNLOAD_INVALID_KEY_CODE: | ||
raise InvalidParametersError("The required type <Type> is invalid for given keys (EnvironmentKey; ApplicationKey). Details: {}".format( | ||
response["response"])) | ||
elif status_code == DOWNLOAD_NO_PERMISSION_CODE: | ||
raise NotEnoughPermissionsError("User doesn't have permissions for the given keys (EnvironmentKey; ApplicationKey). Details: {}".format( | ||
response["response"])) | ||
elif status_code == DOWNLOAD_NOT_FOUND: | ||
raise EnvironmentNotFoundError("No environment or application found. Please check that the EnvironmentKey and ApplicationKey exist. Details: {}".format( | ||
response["response"])) | ||
elif status_code == DOWNLOAD_FAILED_CODE: | ||
raise ServerError("Failed to start the operation to package. Details: {}".format( | ||
response["response"])) | ||
else: | ||
raise NotImplementedError( | ||
"There was an error. Response from server: {}".format(response)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.