コード例 #1
0
ファイル: apperian.py プロジェクト: sroche0/apperian-pyapi
    def set_default_region(self):
        """
        Allows you to change the default region this module uses without having to manually edit endpoints.json
        If you have never run this function the default region will be North America
        """

        print """
        You are about to change the default region this module uses for all future sessions.
        Make a selection from one of the below regions:
        """
        ENDPOINTS['default'] = display_options(ENDPOINTS, 'region')
        self.region = ENDPOINTS['default']
        Ease.auth(self, self.username, self.password)

        package_dir, package = os.path.split(__file__)
        data_path = os.path.join(package_dir, 'data', 'endpoints.json')
        with open(data_path, 'wb') as f:
            f.write(json.dumps(ENDPOINTS, indent=4, separators=(',', ': ')))
コード例 #2
0
ファイル: apperian.py プロジェクト: sroche0/apperian-pyapi
    def set_region(self, region):
        """
        Change the region you access for this session and authenticates you to the new environment.
        If 'list' is provided as the value for region you will see a list of options to manually choose from.

        :param region: Optional. Provide alternate region string. Use region='list' to manually select one
        """

        if self.php and self.py:
            self.region = {
                'PHP Web Services': 'https://{}/ease.interface.php'.format(self.php),
                'Python Web Services': 'https://{}'.format(self.py),
                'File Uploader': 'https://{}'.format(self.php.replace('easesvc', 'fupload'))
            }
        else:
            key = ENDPOINTS.get(region.lower())
            if key:
                self.region = key
            else:
                if region != 'list':
                    print "%s is not a valid format. Please make a selection from below:" % region
                self.region = display_options(ENDPOINTS, 'region')

        return Ease.auth(self)