@@ -71,11 +71,10 @@ async def list_drives(self):
7171 drives = [GCSDrive (self ._config .access_key_id , self ._config .secret_access_key )] # verfiy credentials needed
7272
7373 else :
74- response = {
75- "message" : "Listing drives not supported for given provider." ,
76- "code" : 501
77- }
78- return response
74+ raise tornado .web .HTTPError (
75+ status_code = httpx .codes .NOT_IMPLEMENTED ,
76+ reason = "Listing drives not supported for given provider." ,
77+ )
7978
8079 results = []
8180 for drive in drives :
@@ -91,17 +90,15 @@ async def list_drives(self):
9190 "provider" : self ._config .provider
9291 }
9392 )
94- response = {
95- "data" : data ,
96- "code" : 200
97- }
9893 else :
99- response = {"code" : 400 , "message" : "No credentials specified. Please set them in your user jupyter_server_config file." }
10094 raise tornado .web .HTTPError (
10195 status_code = httpx .codes .BAD_REQUEST ,
10296 reason = "No credentials specified. Please set them in your user jupyter_server_config file." ,
10397 )
10498
99+ response = {
100+ "data" : data
101+ }
105102 return response
106103
107104 async def mount_drive (self , drive_name , provider , region ):
@@ -125,51 +122,36 @@ async def mount_drive(self, drive_name, provider, region):
125122
126123 self ._content_managers [drive_name ] = store
127124
128- response = {
129- "code" : 201 ,
130- "message" : "Drive succesfully mounted."
131- }
132125 else :
133- response = {
134- "code" : 409 ,
135- "message" : "Drive already mounted."
136- }
126+ raise tornado . web . HTTPError (
127+ status_code = httpx . codes . CONFLICT ,
128+ reason = "Drive already mounted."
129+ )
137130
138131 except Exception as e :
139- response = {
140- "code" : 400 ,
141- "message" : f"The following error occured when mouting the drive: { e } "
142- }
143132 raise tornado .web .HTTPError (
144133 status_code = httpx .codes .BAD_REQUEST ,
145134 reason = f"The following error occured when mouting the drive: { e } "
146135 )
147136
148- return response
137+ return
149138
150- async def unmount_drive (self , drive_name : str , ** kwargs ):
139+ async def unmount_drive (self , drive_name : str ):
151140 """Unmount a drive.
152141
153142 Args:
154143 drive_name: name of drive to unmount
155144 """
156145 if drive_name in self ._content_managers :
157146 self ._content_managers .pop (drive_name , None )
158- response = {
159- "code" : 204 ,
160- "message" : "Drive successfully unmounted."
161- }
162147
163148 else :
164- response = {
165- "code" : 404 ,
166- "message" : "Drive is not mounted or doesn't exist." }
167149 raise tornado .web .HTTPError (
168- status_code = httpx .codes .BAD_REQUEST ,
150+ status_code = httpx .codes .NOT_FOUND ,
169151 reason = "Drive is not mounted or doesn't exist." ,
170152 )
171153
172- return response
154+ return
173155
174156 async def get_contents (self , drive_name , path , ** kwargs ):
175157 """Get contents of a file or directory.
0 commit comments