def update_login_at(self, login_at): if login_at is None: return if isinstance(login_at, basestring): login_at = odbc2dt(login_at) if self.login_at is None or login_at > self.login_at: self.login_at = login_at
def __init__(self, login_at=None, admin_level=0, licensing_role_id=License.UNLICENSED, publisher=False): self.login_at = login_at if not login_at is None: if isinstance(login_at, basestring): self.login_at = odbc2dt(login_at) else: self.login_at = login_at self.admin_level = admin_level self.licensing_role_id = licensing_role_id self.publisher = publisher
def __init__(self, schema, row): self.schema = schema self.data = OrderedDict() i = 0 for column in self.schema: ctype = self.schema[column] value = row[i] if ctype == 'DateTime': if value and value.endswith('Z'): # HACK # convert to true iso8601 value = value.replace(' ', 'T') self.data[column] = odbc2dt(value) else: self.data[column] = value i += 1
def load_users(self, agent): stmt = \ """ SELECT system_user_id, login_at, system_users.admin_level, seat_licensing_role_id as licensing_role_id FROM system_users INNER JOIN users on system_users.id = users.system_user_id """ data = agent.odbc.execute(stmt) if 'error' in data or not '' in data: return {} cache = {} for row in data['']: sysid = int(row[0]) login_at = odbc2dt(row[1]) if row[2] is None: admin_level = 0 else: admin_level = int(row[2]) licensing_role_id = License.UNLICENSED if not row[3] is None: licensing_role_id = int(row[3]) # publisher_tristate is deprecated in Tableau 10.5 publisher = False if sysid in cache: obj = cache[sysid] obj.update_login_at(login_at) if admin_level > obj.admin_level: obj.admin_level = admin_level if publisher: obj.publisher = True obj.update_licensing_role(licensing_role_id) else: obj = TableauUserEntry(login_at=login_at, admin_level=admin_level, licensing_role_id=licensing_role_id, publisher=publisher) cache[sysid] = obj return cache
def load_users(self, agent): stmt = \ 'SELECT system_user_id, login_at, admin_level,' +\ ' licensing_role_id, publisher_tristate ' +\ 'FROM users' data = agent.odbc.execute(stmt) if 'error' in data or not '' in data: return {} cache = {} for row in data['']: sysid = int(row[0]) login_at = odbc2dt(row[1]) if row[2] is None: admin_level = 0 else: admin_level = int(row[2]) licensing_role_id = License.UNLICENSED if not row[3] is None: licensing_role_id = int(row[3]) if row[4] is None: publisher = False elif row[4] != Publisher.DENY: publisher = True else: publisher = False if sysid in cache: obj = cache[sysid] obj.update_login_at(login_at) if admin_level > obj.admin_level: obj.admin_level = admin_level if publisher: obj.publisher = True obj.update_licensing_role(licensing_role_id) else: obj = TableauUserEntry(login_at=login_at, admin_level=admin_level, licensing_role_id=licensing_role_id, publisher=publisher) cache[sysid] = obj return cache