@@ -137,7 +137,7 @@ def __init__(self, host, meta):
137
137
self .ensure_json_supported ()
138
138
139
139
140
- def _ensure_support (self , feature ):
140
+ def _ensure_support (self , feature , raise_hell = True ):
141
141
"""Checks the server version supports a given feature, raises an
142
142
exception if it does not.
143
143
@@ -147,10 +147,11 @@ def _ensure_support(self, feature):
147
147
"""
148
148
149
149
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
+ )
154
155
return False
155
156
else :
156
157
return True
@@ -163,19 +164,23 @@ def ensure_json_supported(self):
163
164
'label' : 'JSON API'
164
165
})
165
166
166
- def ensure_include_archived_projects (self ):
167
+ def ensure_include_archived_projects (self , value = True ):
167
168
"""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
168
171
return self ._ensure_support ({
169
172
'version' : (5 , 3 , 14 ),
170
173
'label' : 'include_archived_projects parameter'
171
- })
174
+ }, ( value == False ) )
172
175
173
- def ensure_include_template_projects (self ):
176
+ def ensure_include_template_projects (self , value = False ):
174
177
"""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
175
180
return self ._ensure_support ({
176
181
'version' : (6 , 0 , 0 ),
177
182
'label' : 'include_template_projects parameter'
178
- })
183
+ }, ( value == True ) )
179
184
180
185
181
186
def __str__ (self ):
@@ -665,19 +670,11 @@ def _construct_flag_parameters(self,
665
670
include_archived_projects ,
666
671
include_template_projects ):
667
672
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
674
675
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
681
678
682
679
return params
683
680
@@ -1644,6 +1641,7 @@ def _call_rpc(self, method, params, include_auth_params=True, first=False):
1644
1641
1645
1642
"""
1646
1643
1644
+ log_time = datetime .datetime .now ()
1647
1645
LOG .debug ("Starting rpc call to %s with params %s" % (
1648
1646
method , params ))
1649
1647
@@ -1658,7 +1656,10 @@ def _call_rpc(self, method, params, include_auth_params=True, first=False):
1658
1656
}
1659
1657
http_status , resp_headers , body = self ._make_call ("POST" ,
1660
1658
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
+
1662
1663
try :
1663
1664
self ._parse_http_status (http_status )
1664
1665
except ProtocolError , e :
0 commit comments