@@ -137,7 +137,7 @@ def __init__(self, host, meta):
137137 self .ensure_json_supported ()
138138
139139
140- def _ensure_support (self , feature ):
140+ def _ensure_support (self , feature , raise_hell = True ):
141141 """Checks the server version supports a given feature, raises an
142142 exception if it does not.
143143
@@ -147,10 +147,11 @@ def _ensure_support(self, feature):
147147 """
148148
149149 if not self .version or self .version < feature ['version' ]:
150- raise ShotgunError (
151- "%s requires server version %s or higher, " \
152- "server is %s" % (feature ['label' ], _version_str (feature ['version' ]), _version_str (self .version ))
153- )
150+ if raise_hell :
151+ raise ShotgunError (
152+ "%s requires server version %s or higher, " \
153+ "server is %s" % (feature ['label' ], _version_str (feature ['version' ]), _version_str (self .version ))
154+ )
154155 return False
155156 else :
156157 return True
@@ -163,19 +164,23 @@ def ensure_json_supported(self):
163164 'label' : 'JSON API'
164165 })
165166
166- def ensure_include_archived_projects (self ):
167+ def ensure_include_archived_projects (self , value = True ):
167168 """Wrapper for ensure_support"""
169+ # This defaults to True on the server
170+ # So we only need to raise a version error if it's False
168171 return self ._ensure_support ({
169172 'version' : (5 , 3 , 14 ),
170173 'label' : 'include_archived_projects parameter'
171- })
174+ }, ( value == False ) )
172175
173- def ensure_include_template_projects (self ):
176+ def ensure_include_template_projects (self , value = False ):
174177 """Wrapper for ensure_support"""
178+ # This defaults to False on the server
179+ # So we only need to raise a version error if it's True
175180 return self ._ensure_support ({
176181 'version' : (6 , 0 , 0 ),
177182 'label' : 'include_template_projects parameter'
178- })
183+ }, ( value == True ) )
179184
180185
181186 def __str__ (self ):
@@ -665,19 +670,11 @@ def _construct_flag_parameters(self,
665670 include_archived_projects ,
666671 include_template_projects ):
667672
668- if not include_archived_projects :
669- # This defaults to True on the server (no argument is sent)
670- # So we only need to check the server version if it's False
671- self .server_caps .ensure_include_archived_projects ()
672- # Only pass it if it's False
673- params ["include_archived_projects" ] = False
673+ if self .server_caps .ensure_include_archived_projects (include_archived_projects ):
674+ params ["include_archived_projects" ] = include_archived_projects
674675
675- if include_template_projects :
676- # This defaults to False on the server (no argument is sent)
677- # So we only need to check the server version if it's True
678- self .server_caps .ensure_include_template_projects ()
679- # Only pass it if it's True
680- params ["include_template_projects" ] = True
676+ if self .server_caps .ensure_include_template_projects (include_template_projects ):
677+ params ["include_template_projects" ] = include_template_projects
681678
682679 return params
683680
@@ -1644,6 +1641,7 @@ def _call_rpc(self, method, params, include_auth_params=True, first=False):
16441641
16451642 """
16461643
1644+ log_time = datetime .datetime .now ()
16471645 LOG .debug ("Starting rpc call to %s with params %s" % (
16481646 method , params ))
16491647
@@ -1658,7 +1656,10 @@ def _call_rpc(self, method, params, include_auth_params=True, first=False):
16581656 }
16591657 http_status , resp_headers , body = self ._make_call ("POST" ,
16601658 self .config .api_path , encoded_payload , req_headers )
1661- LOG .debug ("Completed rpc call to %s" % (method ))
1659+
1660+ log_time = datetime .datetime .now () - log_time
1661+ LOG .debug ("Completed rpc call to %s in %s" % (method , str (log_time )))
1662+
16621663 try :
16631664 self ._parse_http_status (http_status )
16641665 except ProtocolError , e :
0 commit comments