8000 Changes to alter cgi dependency to email.Messages · LehmD/server-client-python@2cc5171 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cc5171

Browse files
committed
Changes to alter cgi dependency to email.Messages
1 parent 1d3a642 commit 2cc5171

File tree

2 files changed

+10
-6
lines changed
Collapse file tree

2 files changed

+10
-6
lines changed

tableauserverclient/server/endpoint/flows_endpoint.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import cgi
1+
from email.message import Message
22
import copy
33
import io
44
import logging
@@ -120,14 +120,16 @@ def download(self, flow_id: str, filepath: Optional[PathOrFileW] = None) -> Path
120120
url = "{0}/{1}/content".format(self.baseurl, flow_id)
121121

122122
with closing(self.get_request(url, parameters={"stream": True})) as server_response:
123-
_, params = cgi.parse_header(server_response.headers["Content-Disposition"])
123+
m = Message()
124+
m['Content-Disposition'] = server_response.headers["Content-Disposition"]
125+
params = m.get_filename()
124126
if isinstance(filepath, io_types_w):
125127
for chunk in server_response.iter_content(1024): # 1KB
126128
filepath.write(chunk)
127129
return_path = filepath
128130
else:
129131
params = fix_filename(params)
130-
filename = to_filename(os.path.basename(params["filename"]))
132+
filename = to_filename(os.path.basename(params))
131133
download_path = make_download_path(filepath, filename)
132134
with open(download_path, "wb") as f:
133135
for chunk in server_response.iter_content(1024): # 1KB

tableauserverclient/server/endpoint/workbooks_endpoint.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import cgi
1+
from email.message import Message
22
import copy
33
import io
44
import logging
@@ -483,14 +483,16 @@ def download_revision(
483483
url += "?includeExtract=False"
484484

485485
with closing(self.get_request(url, parameters={"stream": True})) as server_response:
486-
_, params = cgi.parse_header(server_response.headers["Content-Disposition"])
486+
m = Message()
487+
m['Content-Disposition'] = server_response.headers["Content-Disposition"]
488+
params = m.get_filename()
487489
if isinstance(filepath, io_types_w):
488490
for chunk in server_response.iter_content(1024): # 1KB
489491
filepath.write(chunk)
490492
return_path = filepath
491493
else:
492494
params = fix_filename(params)
493-
filename = to_filename(os.path.basename(params["filename"]))
495+
filename = to_filename(os.path.basename(params))
494496
download_path = make_download_path(filepath, filename)
495497
with open(download_path, "wb") as f:
496498
for chunk in server_response.iter_content(1024): # 1KB

0 commit comments

Comments
 (0)
0