Skip to content

Commit

Permalink
Updated logging and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinGrilli committed Mar 1, 2024
1 parent 0527ca6 commit d4701d3
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
long_description=readme,
long_description_content_type='text/markdown',
name="tableau_utilities",
version="2.1.12",
version="2.1.13",
packages=[
'tableau_utilities',
'tableau_utilities.general',
Expand Down
14 changes: 8 additions & 6 deletions tableau_utilities/tableau_file/tableau_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,24 @@ def save(self):
dupe_temp_path = os.path.join(temp_folder, f'__tmp_{self.file_basename}')
shutil.move(self.file_path, temp_path)
# Unzip the zipped files
logging.info('Unzipping files from {}'.format(temp_path))
extracted_files = list()
with ZipFile(temp_path) as z:
for f in z.filelist:
ext = f.filename.split('.')[-1]
if ext in ['tds', 'twb']:
xml_path = path
logging.info('Extracting file {}'.format(f.filename))
path = z.extract(member=f, path=temp_folder)
extracted_files.append(path)
if ext in ['tds', 'twb']:
xml_path = path
# Update XML file
logging.info('Extracting updating XML {}'.format(xml_path))
# Overwrite XML file with new XML
logging.info('Overwriting XML file {}'.format(os.path.basename(xml_path)))
self._tree.write(xml_path, encoding="utf-8", xml_declaration=True)
# Repack the unzipped file
logging.info('Zipping files into {}'.format(temp_path))
# Repack the unzipped files
with ZipFile(temp_path, 'w') as z:
for file in extracted_files:
logging.info('Archiving {}'.format(file))
logging.info('Archiving {}'.format(os.path.basename(file)))
arcname = file.split(temp_folder)[-1]
z.write(file, arcname=arcname)
# Move file back to the original folder and remove any unpacked contents
Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


class Base:
""" Base functionality inherited by TableauServer class, and Core TableauServer classes """
def __init__(self, parent):
self.session: Session = parent.session
self.user: str = parent.user
Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


class Create(Base):
""" Core Create functionality of the TableauServer class """
def __init__(self, parent):
super().__init__(parent)

Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class Download(Base):
""" Core Download functionality of the TableauServer class """
def __init__(self, parent):
super().__init__(parent)

Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class Get(Base):
""" Core Get functionality of the TableauServer class """
def __init__(self, parent):
super().__init__(parent)

Expand Down
6 changes: 5 additions & 1 deletion tableau_utilities/tableau_server/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class Publish(Base):
""" Core Publish functionality of the TableauServer class """
def __init__(self, parent):
super().__init__(parent)

Expand Down Expand Up @@ -100,8 +101,11 @@ def __upload_in_chunks(self, file_path, chunk_size_mb=5):
('request_payload', '', None, 'text/xml'),
('tableau_file', chunk, file_name, 'application/octet-stream')
])
# Log progress every so often
current += chunk_size_mb
logging.info('({} of {} mb) Uploading {}'.format(current if current < total else total, total, file_path))
if current == chunk_size_mb or current % 500 == 0 or current >= total:
logging.info('({} of {} mb) Uploading {}'.format(
current if current < total else total, total, file_path))
self._put(
f'{self.url}/fileUploads/{upload_session_id}',
data=post_body, headers={'Content-Type': content_type}
Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class Refresh(Base):
""" Core Refresh functionality of the TableauServer class """
def __init__(self, parent):
super().__init__(parent)

Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/static.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
""" Static functionality of the TableauServer and Core classes """
import requests
from tableau_utilities.general.funcs import flatten_dict

Expand Down
1 change: 1 addition & 0 deletions tableau_utilities/tableau_server/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class Update(Base):
""" Core Update functionality of the TableauServer class """
def __init__(self, parent):
super().__init__(parent)

Expand Down

0 comments on commit d4701d3

Please sign in to comment.