@@ -429,6 +429,30 @@ def __init__(self, sg):
429429 self .no_ssl_validation = False
430430 self .localized = False
431431
432+ def set_server_params (self , base_url ):
433+ """
434+ Set the different server related fields based on the passed in URL.
435+
436+ This will impact the following attributes:
437+
438+ - scheme: http or https
439+ - api_path: usually /api3/json
440+ - server: usually something.shotgunstudio.com
441+
442+ :param str base_url: The server URL.
443+
444+ :raises ValueError: Raised if protocol is not http or https.
445+ """
446+ self .scheme , self .server , api_base , _ , _ = \
447+ urllib .parse .urlsplit (base_url )
448+ if self .scheme not in ("http" , "https" ):
449+ raise ValueError (
450+ "base_url must use http or https got '%s'" % base_url
451+ )
452+ self .api_path = urllib .parse .urljoin (urllib .parse .urljoin (
453+ api_base or "/" , self .api_ver + "/" ), "json"
454+ )
455+
432456 @property
433457 def records_per_page (self ):
434458 """
@@ -646,17 +670,14 @@ def __init__(self,
646670 self .__ca_certs = os .environ .get ("SHOTGUN_API_CACERTS" )
647671
648672 self .base_url = (base_url or "" ).lower ()
649- self .config .scheme , self .config .server , api_base , _ , _ = \
650- urllib .parse .urlsplit (self .base_url )
651- if self .config .scheme not in ("http" , "https" ):
652- raise ValueError ("base_url must use http or https got '%s'" %
653- self .base_url )
654- self .config .api_path = urllib .parse .urljoin (urllib .parse .urljoin (
655- api_base or "/" , self .config .api_ver + "/" ), "json" )
673+ self .config .set_server_params (self .base_url )
656674
657675 # if the service contains user information strip it out
658676 # copied from the xmlrpclib which turned the user:password into
659677 # and auth header
678+ # Do NOT urlsplit(self.base_url) here, as it contains the lower case version
679+ # of the base_url argument. Doing so would base64-encode the lowercase
680+ # version of the credentials.
660681 auth , self .config .server = urllib .parse .splituser (urllib .parse .urlsplit (base_url ).netloc )
661682 if auth :
662683 auth = base64 .encodestring (six .ensure_binary (urllib .parse .unquote (auth ))).decode ("utf-8" )
@@ -2054,7 +2075,7 @@ def schema_field_update(self, entity_type, field_name, properties, project_entit
20542075 :param properties: Dictionary with key/value pairs where the key is the property to be
20552076 updated and the value is the new value.
20562077 :param dict project_entity: Optional Project entity specifying which project to modify the
2057- ``visible`` property for. If the ``visible`` is present in ``properties`` and
2078+ ``visible`` property for. If ``visible`` is present in ``properties`` and
20582079 ``project_entity`` is not set, an exception will be raised. Example:
20592080 ``{'type': 'Project', 'id': 3}``
20602081 :returns: ``True`` if the field was updated.
0 commit comments