How to use the pysftp.exceptions.ConnectionException function in pysftp

To help you get started, we’ve selected a few pysftp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paypal / PPExtensions / ppextensions / pputils / utils / tableau.py View on Github external
site_name = input("Enter the site name to publish ")
            username = input("Enter tableau user name ")
            password = getpass.getpass("Please enter your password ")

        data_file_name = str(data_file).rsplit('.tde', 1)[0]

        subprocess.run(["tabcmd", "--accepteula"], stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE)

        result = subprocess.run(["tabcmd", "login", "-s",
                                 "{}".format(site_name), "-u", "{}".format(username),
                                 "-p", "{}".format(password)], stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

        if result.returncode != 0:
            raise ConnectionException("Unable to connect to tableau server")

        result = subprocess.run(["tabcmd", "publish",
                                 "{}".format(data_file),
                                 "-r", "{}".format(project_name)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        if result.returncode != 0:
            if ("A data source named '{}' already exists in project".format(
                    data_file_name) in str(result.stderr)):
                result = subprocess.run(
                    ["tabcmd", "publish", "{}".format(data_file),
                     "-r", "{}".format(project_name), "--overwrite"], stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE)
                overwrite = True
            if "Unexpected response from the server:" not in str(result.stderr):
                print(result.stderr)
                raise SSHException("Unable to get response from tableau server")