Tableau Server API Python (Tableau_Tools) - python

I am trying to do some basic api integration with Tableau server.
I was trying the Tableau_tools library (https://github.com/bryanthowell-tableau/tableau_tools).
I am unable to get simple create AD group or add user working. Is there something I am doing wrong?
I am able to view users/groups.
This is my code:
t = TableauServerRest37(cfg["server"], pat_name=cfg['personal_access_token_name'], pat_secret=cfg['personal_access_token_secret'], site_content_url=cfg["site_url"])
t.signin()
t.enable_logging(logger)
list_of_groups = t.groups.query_groups_json()
list_of_users = t.users.query_users_json()
#Add Users
users_to_add = ['user_1', 'user_2', 'user_3']
for user in users_to_add:
t.users.add_user(username=user, fullname=user, site_role='Publisher')
t.groups.create_group_from_ad_group( group, domain, default_site_role="ExplorerCanPublish", sync_as_background=True)
I am getting the following Error for Users:
Traceback (most recent call last):
File ".\Tableau_tools_api.py", line 117, in <module>
main()
File ".\Tableau_tools_api.py", line 82, in main
t.users.add_user(username=user, fullname=user, site_role='Publisher')
File "C:\Users\ABCD\AppData\Roaming\Python\Python37\site-packages\tableau_tools\tableau_rest_api\methods\user.py", line 164, in add_user
update_if_exists=update_if_exists, auth_setting=auth_setting)
File "C:\Users\ABCD\AppData\Roaming\Python\Python37\site-packages\tableau_tools\tableau_rest_api\methods\user.py", line 89, in add_user_by_username
if site_role not in self.rest.site_roles:
AttributeError: 'TableauServerRest37' object has no attribute 'site_roles'
I am getting the following Error for Groups:
Traceback (most recent call last):
File ".\Tableau_tools_api.py", line 117, in <module>
main()
File ".\Tableau_tools_api.py", line 88, in main
t.groups.create_group_from_ad_group( group, domain, default_site_role="ExplorerCanPublish", sync_as_background=True)
File "C:\Users\ABCD\AppData\Roaming\Python\Python37\site-packages\tableau_tools\tableau_rest_api\methods\group.py", line 74, in create_group_from_ad_group
if default_site_role not in self.rest._site_roles:
AttributeError: 'TableauServerRest37' object has no attribute '_site_roles'
I was wondering if anyone has gotten this to work for api version 3.7?

Related

Problems with let otree devserver run

I have a Python Code to conduct an experiment. To ensure that the Code is working smoothly I wanted to run a trial round via 'otree devserver', but I always get an AttributeError message and I am stuck here. Can anyone help me out?
I have downloaded the Code from GitHub and downloaded all required packages. I am using macOS, otree-5.10.2 and django-4.1.7. Here is my full traceback / error message:
Traceback (most recent call last): File
"/Users/.otreevenv/bin/otree", line 8, in
sys.exit(execute_from_command_line()) File "/Users/.otreevenv/lib/python3.10/site-packages/otree/main.py", line
108, in execute_from_command_line
setup() File "/Users/.otreevenv/lib/python3.10/site-packages/otree/main.py", line
132, in setup
from otree import settings File "/Users/.otreevenv/lib/python3.10/site-packages/otree/settings.py",
line 50, in
OTREE_APPS = get_OTREE_APPS(settings.SESSION_CONFIGS) File "/Users/.otreevenv/lib/python3.10/site-packages/django/conf/__init__.py",
line 94, in __getattr__
val = getattr(_wrapped, name) File "/Users/.otreevenv/lib/python3.10/site-packages/django/conf/__init__.py",
line 270, in __getattr__
return getattr(self.default_settings, name) AttributeError: module 'django.conf.global_settings' has no attribute 'SESSION_CONFIGS'. Did
you mean: 'SESSION_ENGINE'?

I run python code for encryption from github. A lot of errors prevent me for executing it correctly

I am trying to use this python code here, without success:
https://github.com/debajyotiguha11/PyCrypto
I run the script, but I get these errors:
Do you want to (E)ncrypt or (D)ecrypt? *Case Sensitive*
E
Enter the password:
abcd
Traceback (most recent call last):
File "pycrypto3.py", line 84, in <module>
encrypt(SHA256.new(password).digest(), str(Tfiles))
File "/usr/local/lib/python3.7/dist-packages/Crypto/Hash/SHA256.py", line 88, in new
return SHA256Hash().new(data)
File "/usr/local/lib/python3.7/dist-packages/Crypto/Hash/SHA256.py", line 75, in new
return SHA256Hash(data)
File "/usr/local/lib/python3.7/dist-packages/Crypto/Hash/SHA256.py", line 72, in __init__
HashAlgo.__init__(self, hashFactory, data)
File "/usr/local/lib/python3.7/dist-packages/Crypto/Hash/hashalgo.py", line 51, in __init__
self.update(data)
File "/usr/local/lib/python3.7/dist-packages/Crypto/Hash/hashalgo.py", line 69, in update
return self._hash.update(data)
TypeError: Unicode-objects must be encoded before hashing
How do I fix this?

TypeError when using remote_create using Facebook Python Business SDK

I am currently getting this error (along with most recent calls) when trying to run the remote_create method in the Facebook Python Business SDK:
Traceback (most recent call last):
File "ad_creator.py", line 41, in <module>
campaign.remote_create()
File "/usr/local/lib/python3.6/site-packages/facebook_business/adobjects/abstractcrudobject.py", line 296, in remote_create
response = request.execute()
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 667, in execute
api_version=self._api_version,
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 329, in call
if fb_response.is_failure():
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 117, in is_failure
return not self.is_success()
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 102, in is_success
return json_body['success']
TypeError: string indices must be integers
It appears the error is being thrown from the api.py file in the API:
https://github.com/facebook/facebook-python-business-sdk/blob/master/facebook_business/api.py
My code (after creating a Facebook session), is the following:
if __name__ == '__main__':
FacebookAdsApi.set_default_api(api)
account = AdAccount(config['act_id'])
print('**** Creating ad...')
campaign = Campaign(parent_id=account)
campaign.update({
Campaign.Field.name: 'My First Campaign',
Campaign.Field.objective: 'REACH',
})
campaign.remote_create()
print(campaign)
Please help me figure out what's causing the TypeError.

AttributeError: '_GzipStreamFile' object has no attribute '_checkReadable

I am trying to setup commonsearch and i am the point where backend imports alexa1m data to rocksdb, but it die with error( error below ).
Traceback (most recent call last):
File "urlserver/import.py", line 21, in <module>
ds.import_dump()
File "./urlserver/datasources/__init__.py", line 62, in import_dump
for i, row in self.iter_dump():
File "./urlserver/datasources/__init__.py", line 102, in iter_dump
f = self.open_dump()
File "./urlserver/datasources/__init__.py", line 144, in open_dump
return GzipStreamFile(f)
File "/cosr/back/venv/src/gzipstream/gzipstream/gzipstreamfile.py", line 62, in __init__
super(GzipStreamFile, self).__init__(self._gzipstream)
File "/usr/lib64/python2.6/io.py", line 921, in __init__
raw._checkReadable()
AttributeError: '_GzipStreamFile' object has no attribute '_checkReadable'
have been fighting with this without progress for 2 days now.. if somebody could givme somekind of insight or advice i would be more than happy!
Found the solution, it was problem in the data parsed to the tool, not the tool itself.

Creating a track object with track_from_file method in pyechonest

I am new to python. I am trying to use track_from_file method in pyechonest to create a track object. This is the code I wrote:
from pyechonest import config
from pyechonest.track import track_from_file
config.ECHO_NEST_API_KEY = "KRZG4XOVUQRKI45DP"
f = open("ShayneWard-NoPromises.mp3")
t = track_from_file(f, 'mp3')
But this is not working. I got an EchoNestIOError. This is the full error Traceback that i got.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 243, in track_from_file
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 331, in track_from_md5
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 209, in _profile
File "build/bdist.linux-x86_64/egg/pyechonest/util.py", line 257, in callm pyechonest.util.
EchoNestIOError: Echo Nest Unknown Error
Can anyone tell me what have I done wrong?
I finally figured it out. It seems that the upload does not take place through the proxy server of my university network which uses NAT.

Categories