QualiSystems / devguide_source

This repository hosts the source code of the CloudShell developer guide.
https://devguide.quali.com
2 stars 8 forks source link

Page has syntax errors #102

Closed graboskyc closed 6 years ago

graboskyc commented 6 years ago

https://qualisystems.github.io/devguide/orchestration/8.2.0/script-commands-customization.html

Original:

            from cloudshell.workflow.orchestration.sandbox import Sandbox
            import cloudshell.helpers.scripts.cloudshell_dev_helpers as dev_helpers

            def print_parameters_values(Sandbox):
                """
                :param Sandbox sandbox:
                :return:
                """
                print sandbox.get_user_param('first_param')
                print sandbox.get_user_param('second_param')

            def change_reservation_status_to_online(Sandbox):
                """
                :param Sandbox sandbox:
                :return:
                """
                sandbox.automation_api.SetReservationLiveStatus(sandbox.id, "Online")

            def main():
                dev_helpers.attach_to_cloudshell()
                sandbox = Sandbox()
                print_parameters_values(sandbox)
                change_reservation_status_to_online(sandbox)

            if __name__ == "__main__":
                main()

Has bugs in that "Sandbox" should not be capitalized as inputs and "Online" is not a valid sandbox live status.

Proposed fixes:

            from cloudshell.workflow.orchestration.sandbox import Sandbox
            import cloudshell.helpers.scripts.cloudshell_dev_helpers as dev_helpers

            def print_parameters_values(sandbox):
                """
                :param Sandbox sandbox:
                :return:
                """
                print sandbox.get_user_param('first_param')
                print sandbox.get_user_param('second_param')

            def change_reservation_status_to_online(sandbox):
                """
                :param Sandbox sandbox:
                :return:
                """
                sandbox.automation_api.SetReservationLiveStatus(sandbox.id, "Downloading")

            def main():
                dev_helpers.attach_to_cloudshell()
                sandbox = Sandbox()
                print_parameters_values(sandbox)
                change_reservation_status_to_online(sandbox)

            if __name__ == "__main__":
                main()
TomerAdmon commented 6 years ago

I agree...

Thanks @graboskyc !! 👍

graboskyc commented 6 years ago

@TomerAdmon hi, the latter is not just a matter of style. the variable is referenced in the function using lowercase "sandbox" but the argument variable is "Sandbox" with upper case, meaning the function will try global scope and fail. So either need to update the signatures or the code in the functions.