Skip to content

Commit

Permalink
v.4.3.11
Browse files Browse the repository at this point in the history
Minor updates. NotSignedInException now actually raises when received from the Server
  • Loading branch information
Bryant Howell committed Feb 9, 2018
1 parent d906570 commit db9b107
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='tableau_tools',
version='4.3.10',
version='4.3.11',
packages=['tableau_tools', 'tableau_tools.tableau_rest_api', 'tableau_tools.tableau_documents', 'tableau_tools.examples'],
url='https://github.com/bryantbhowell/tableau_tools',
license='',
Expand Down
4 changes: 2 additions & 2 deletions tableau_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self):
self.luid_pattern = r"[0-9a-fA-F]*-[0-9a-fA-F]*-[0-9a-fA-F]*-[0-9a-fA-F]*-[0-9a-fA-F]*"

# Defaults, will get updated with each update. Overwritten by set_tableau_server_version
self.version = u"10.3"
self.api_version = u"2.6"
self.version = u"10.5"
self.api_version = u"2.8"
self.tableau_namespace = u'http://tableau.com/api'
self.ns_map = {'t': 'http://tableau.com/api'}
self.ns_prefix = '{' + self.ns_map['t'] + '}'
Expand Down
28 changes: 23 additions & 5 deletions tableau_documents/tableau_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def port(self):
@port.setter
def port(self, new_port):
if self.xml_obj.get(u"port") is not None:
self.xml_obj.attrib[u"port"] = new_port
self.xml_obj.attrib[u"port"] = unicode(new_port)
else:
self.xml_obj.set(u'port', new_port)
self.xml_obj.set(u'port', unicode(new_port))

@property
def connection_type(self):
Expand All @@ -102,13 +102,31 @@ def is_windows_auth(self):
else:
return False

@property
def filename(self):
if self.xml_obj.get(u'filename') is None:
raise NoResultsException(u'Connection type {} does not have filename attribute'.format(
self.connection_type))
else:
return self.xml_obj.get(u'filename')

@filename.setter
def filename(self, filename):
if self.xml_obj.get(u'filename') is not None:
self.xml_obj.attrib[u'filename'] = filename
else:
self.xml_obj.set(u'filename', filename)

@property
def sslmode(self):
return self.xml_obj.get(u'sslmode')

@sslmode.setter
def sslmode(self, value=u'require'):
self.xml_obj.attrib[u"sslmode"] = value
if self.xml_obj.get(u'sslmode') is not None:
self.xml_obj.attrib[u"sslmode"] = value
else:
self.xml_obj.set(u'sslmode', value)

@property
def authentication(self):
Expand All @@ -119,7 +137,7 @@ def authentication(self, auth_type):
if self.xml_obj.get(u"authentication") is not None:
self.xml_obj.attrib[u"authentication"] = auth_type
else:
self.xml_obj.set(u"authentication")
self.xml_obj.set(u"authentication", auth_type)

@property
def service(self):
Expand All @@ -130,5 +148,5 @@ def service(self, service):
if self.xml_obj.get(u"service") is not None:
self.xml_obj.attrib[u"service"] = service
else:
self.xml_obj.set(u"service")
self.xml_obj.set(u"service", service)

2 changes: 1 addition & 1 deletion tableau_documents/tableau_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def generate_cols_map_section(self):
m.set(u"key", u"[{}]".format(key))
m.set(u"value", self.column_mapping[key])
c.append(m)
self.ds_xml.append(c)
self.xml.append(c)

@staticmethod
def generate_aliases_tag():
Expand Down
5 changes: 5 additions & 0 deletions tableau_rest_api/rest_xml_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import requests
import sys


# Handles all of the actual HTTP calling
class RestXmlRequest(TableauBase):
def __init__(self, url, token=None, logger=None, ns_map_url='http://tableau.com/api',
Expand Down Expand Up @@ -254,6 +255,9 @@ def __make_request(self, page_number=1):
else:
detail_luid = False
self.log(u'Tableau REST API error code is: {}'.format(error_code))
# If you are not signed in
if error_code == u'401000':
raise NotSignedInException(u'You must sign in first')
# Everything that is not 400 can potentially be recovered from
if status_code in [401, 402, 403, 404, 405, 409]:
# If 'not exists' for a delete, recover and log
Expand All @@ -262,6 +266,7 @@ def __make_request(self, page_number=1):
if status_code == 409:
self.log(u'HTTP 409 error, most likely an already exists')
raise RecoverableHTTPException(status_code, error_code, detail_luid)

raise
except:
raise
Expand Down
3 changes: 3 additions & 0 deletions tableau_rest_api/tableau_rest_api_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,12 @@ def signin(self):
api.http_verb = 'post'
self.log(u'Login payload is\n {}'.format(etree.tostring(tsr)))


api.request_from_api(0)
# self.log(api.get_raw_response())
xml = api.get_response()


credentials_element = xml.findall(u'.//t:credentials', self.ns_map)
self.token = credentials_element[0].get("token")
self.log(u"Token is " + self.token)
Expand Down
2 changes: 1 addition & 1 deletion tableau_rest_api/tableau_rest_api_connection_28.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def add_datasource_to_schedule(self, ds_name_or_luid, schedule_name_or_luid, pro
tsr = etree.Element(u'tsRequest')
t = etree.Element(u'task')
er = etree.Element(u'extractRefresh')
d = etree.Element(u'dataasource')
d = etree.Element(u'datasource')
d.set(u'id', ds_luid)
er.append(d)
t.append(er)
Expand Down

0 comments on commit db9b107

Please sign in to comment.