Skip to content

Commit

Permalink
Merge pull request bryanthowell-tableau#81 from bryantbhowell/5.1.1
Browse files Browse the repository at this point in the history
5.1.1-part1
  • Loading branch information
Bryant Howell authored Jan 24, 2020
2 parents 1bd2dfe + 3e82963 commit 205c10b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ You can get all of the values from the previous object, if it has been signed in
Now any actions you take with t2 will be the same session to the Tableau Server as those taken with t1. This can also be very useful for multi-threaded programming, where you may want to clone instances of an object so that they don't interact with one another while doing things on different threads, but still use the same REST API session.

### 1.2 Basics and Querying
NOTE: If you get a "RecursionError: maximum recursion depth exceeded" Exception, it generally means that you are trying a method that does not exist. The most common reason for this with the TableauServerRest objects is when porting code over from TableauRestApiConnection objects. All methods except for lookups live under a sub-object (t.users.method()) in TableauServerRest, so if you put a method directly on the main object, it will try and search for it but error out. This issue can work the other way, if you try and use a sub-object under TableauRestApiConnection when it doesn't exist.

#### 1.2.0 ElementTree.Element XML Responses
As mentioned in the 0 section, tableau_tools returns ElementTree.Element responses for any XML request. To know exactly what is available in any given object coming back from the Tableau REST API, you'll need to either consult the REST API Reference or convert to it something you can write to the console or a text file.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='tableau_tools',
python_requires='>=3.6',
version='5.1.0',
version='5.1.1',
packages=['tableau_tools', 'tableau_tools.tableau_rest_api', 'tableau_tools.tableau_documents',
'tableau_tools.examples', 'tableau_tools.tableau_rest_api.methods'],
url='https://github.com/bryantbhowell/tableau_tools',
Expand Down
16 changes: 12 additions & 4 deletions tableau_documents/tableau_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,23 @@ def save_new_file(self, new_filename_no_extension: str):
os.remove(self.packaged_filename)

temp_directories_to_remove = {}

# Store any directories that already existed, so you don't clean up exiting directory on disk
existing_directories = []
all_in_working_dir = os.listdir()
for l in all_in_working_dir:
if (os.path.isdir(l)):
existing_directories.append(l)
# Now actually go through all the other files, extract them, put into the new ZIP file, then clean up
if len(self.other_files) > 0:
file_obj = open(self.orig_filename, 'rb')
o_zf = zipfile.ZipFile(file_obj)

for filename in self.other_files:
self.log('Looking into additional files: {}'.format(filename))

lowest_level = filename.split('/')
# Only delete out if it didn't exist prior to saving out of the original ZIPfile
if lowest_level[0] not in existing_directories:
temp_directories_to_remove[lowest_level[0]] = True
if self.file_replacement_map and filename in self.file_replacement_map:
new_zf.write(self.file_replacement_map[filename], "/" + filename)
# Delete from the data_file_replacement_map to reduce down to end
Expand All @@ -434,8 +443,7 @@ def save_new_file(self, new_filename_no_extension: str):
new_zf.write(filename)
os.remove(filename)
self.log('Removed file {}'.format(filename))
lowest_level = filename.split('/')
temp_directories_to_remove[lowest_level[0]] = True

file_obj.close()

# Loop through remaining files in data_file_replacement_map to just add
Expand Down

0 comments on commit 205c10b

Please sign in to comment.