@@ -107,7 +107,7 @@ def detail_upload(
107107 headers = {}
108108 if group :
109109 headers ["groupName" ] = group
110- response = self .session .get (f"{ self .api } /uploads/{ upload_id } " , headers = headers )
110+ response = self .session .get (f"{ self .api } /uploads/{ upload_id } " , headers = headers ) # type: ignore
111111
112112 if response .status_code == 200 :
113113 logger .debug (f"Got details for upload { upload_id } " )
@@ -119,7 +119,7 @@ def detail_upload(
119119
120120 elif response .status_code == 503 :
121121 if not wait_time :
122- wait_time = response .headers ["Retry-After" ]
122+ wait_time = int ( response .headers ["Retry-After" ])
123123 logger .debug (
124124 f"Retry GET upload { upload_id } after { wait_time } seconds: { response .json ()['message' ]} "
125125 )
@@ -249,23 +249,23 @@ def upload_file(
249249 }
250250
251251 headers = {}
252- if "v1" in self .api :
252+ if "v1" in self .api : # type: ignore
253253 headers = {
254254 k : str (v ).lower () if isinstance (v , bool ) else v for k , v in data .items ()
255255 } # Needed for API v1.x
256256 headers ["groupName" ] = group
257- endpoint = f"{ self .api } /uploads"
257+ endpoint = f"{ self .api } /uploads" # type: ignore
258258 else :
259259 if group :
260- endpoint = f"{ self .api } /uploads?groupName={ group } "
260+ endpoint = f"{ self .api } /uploads?groupName={ group } " # type: ignore
261261 else :
262- endpoint = f"{ self .api } /uploads"
262+ endpoint = f"{ self .api } /uploads" # type: ignore
263263
264264 if file :
265265 data ["uploadType" ] = headers ["uploadType" ] = "file"
266266 with open (file , "rb" ) as fp :
267267 files = {"fileInput" : fp }
268- response = self .session .post (
268+ response = self .session .post ( # type: ignore
269269 endpoint , files = files , headers = headers , data = data
270270 )
271271 elif vcs or url or server :
@@ -279,7 +279,7 @@ def upload_file(
279279 data ["location" ] = server # type: ignore
280280 data ["uploadType" ] = headers ["uploadType" ] = "server"
281281 headers ["Content-Type" ] = "application/json"
282- response = self .session .post (
282+ response = self .session .post ( # type: ignore
283283 endpoint ,
284284 data = json .dumps (data ),
285285 headers = headers ,
@@ -301,7 +301,7 @@ def upload_file(
301301
302302 if response .status_code == 201 :
303303 try :
304- upload = self .detail_upload (
304+ upload = self .detail_upload ( # type: ignore
305305 response .json ()["message" ], group , wait_time
306306 )
307307 logger .info (
@@ -339,8 +339,9 @@ def upload_summary(self, upload: Upload, group=None):
339339 headers = {}
340340 if group :
341341 headers ["groupName" ] = group
342- response = self .session .get (
343- f"{ self .api } /uploads/{ upload .id } /summary" , headers = headers
342+ response = self .session .get ( # type: ignore
343+ f"{ self .api } /uploads/{ upload .id } /summary" , # type: ignore
344+ headers = headers , # type: ignore
344345 )
345346
346347 if response .status_code == 200 :
@@ -406,8 +407,10 @@ def upload_licenses(
406407 headers ["groupName" ] = group
407408 params ["groupName" ] = group # type: ignore
408409
409- response = self .session .get (
410- f"{ self .api } /uploads/{ upload .id } /licenses" , params = params , headers = headers
410+ response = self .session .get ( # type: ignore
411+ f"{ self .api } /uploads/{ upload .id } /licenses" , # type: ignore
412+ params = params ,
413+ headers = headers , # type: ignore
411414 )
412415
413416 if response .status_code == 200 :
@@ -451,7 +454,7 @@ def upload_copyrights(
451454 :raises FossologyApiError: if the REST call failed
452455 :raises AuthorizationError: if the REST call is not authorized
453456 """
454- response = self .session .get (f"{ self .api } /uploads/{ upload .id } /copyrights" )
457+ response = self .session .get (f"{ self .api } /uploads/{ upload .id } /copyrights" ) # type: ignore
455458
456459 if response .status_code == 200 :
457460 all_copyrights = []
@@ -491,8 +494,10 @@ def delete_upload(self, upload, group=None):
491494 headers = {}
492495 if group :
493496 headers ["groupName" ] = group
494- response = self .session .delete (
495- f"{ self .api } /uploads/{ upload .id } " , headers = headers , timeout = 5
497+ response = self .session .delete ( # type: ignore
498+ f"{ self .api } /uploads/{ upload .id } " , # type: ignore
499+ headers = headers ,
500+ timeout = 5 , # type: ignore
496501 )
497502
498503 if response .status_code == 202 :
@@ -560,7 +565,7 @@ def list_uploads(
560565 assignee = assignee ,
561566 since = since ,
562567 group = group ,
563- limit = page_size ,
568+ limit = str ( page_size ) ,
564569 )
565570 uploads_list = list ()
566571 if all_pages :
@@ -571,8 +576,10 @@ def list_uploads(
571576 while page <= x_total_pages :
572577 headers ["page" ] = str (page )
573578 params ["page" ] = str (page )
574- response = self .session .get (
575- f"{ self .api } /uploads" , headers = headers , params = params
579+ response = self .session .get ( # type: ignore
580+ f"{ self .api } /uploads" , # type: ignore
581+ headers = headers ,
582+ params = params , # type: ignore
576583 )
577584 if response .status_code == 200 :
578585 for upload in response .json ():
@@ -628,8 +635,8 @@ def update_upload(
628635 params ["assignee" ] = assignee .id # type: ignore
629636 if group :
630637 headers ["groupName" ] = group
631- response = self .session .patch (
632- f"{ self .api } /uploads/{ upload .id } " ,
638+ response = self .session .patch ( # type: ignore
639+ f"{ self .api } /uploads/{ upload .id } " , # type: ignore
633640 headers = headers ,
634641 params = params ,
635642 data = comment ,
@@ -661,8 +668,10 @@ def move_upload(self, upload: Upload, folder: Folder, action: str):
661668 :raises AuthorizationError: if the REST call is not authorized
662669 """
663670 params = {"folderId" : str (folder .id ), "action" : action }
664- response = self .session .put (
665- f"{ self .api } /uploads/{ upload .id } " , headers = params , params = params
671+ response = self .session .put ( # type: ignore
672+ f"{ self .api } /uploads/{ upload .id } " , # type: ignore
673+ headers = params ,
674+ params = params , # type: ignore
666675 )
667676
668677 if response .status_code == 202 :
@@ -680,7 +689,7 @@ def move_upload(self, upload: Upload, folder: Folder, action: str):
680689 )
681690 raise FossologyApiError (description , response )
682691
683- def download_upload (self , upload : Upload ) -> Tuple [str , str ]:
692+ def download_upload (self , upload : Upload ) -> Tuple [bytes , str ]:
684693 """Download an upload by its id
685694
686695 API Endpoint: GET /uploads/{id}/download
@@ -692,7 +701,7 @@ def download_upload(self, upload: Upload) -> Tuple[str, str]:
692701 :raises FossologyApiError: if the REST call failed
693702 :raises AuthorizationError: if the REST call is not authorized
694703 """
695- response = self .session .get (f"{ self .api } /uploads/{ upload .id } /download" )
704+ response = self .session .get (f"{ self .api } /uploads/{ upload .id } /download" ) # type: ignore
696705
697706 if response .status_code == 200 :
698707 content = response .headers ["Content-Disposition" ]
@@ -743,8 +752,9 @@ def change_upload_permissions(
743752 if public_permission
744753 else "none" ,
745754 }
746- response : requests .Response = self .session .put (
747- f"{ self .api } /uploads/{ upload .id } /permissions" , json = data
755+ response : requests .Response = self .session .put ( # type: ignore
756+ f"{ self .api } /uploads/{ upload .id } /permissions" , # type: ignore
757+ json = data , # type: ignore
748758 )
749759
750760 if response .status_code == 202 :
@@ -789,7 +799,7 @@ def upload_permissions(
789799 :raises FossologyApiError: if the REST call failed
790800 :raises AuthorizationError: if the REST call is not authorized
791801 """
792- response = self .session .get (f"{ self .api } /uploads/{ upload .id } /perm-groups" )
802+ response = self .session .get (f"{ self .api } /uploads/{ upload .id } /perm-groups" ) # type: ignore
793803 if response .status_code == 200 :
794804 return UploadPermGroups .from_json (response .json ())
795805
0 commit comments