I have recently discovered you can use R within Tableau, to return bool, int, long etc. This happens by the following:
install.packages("Rserve")
library(Rserve)
Rserve()
// Should say "Starting RServe..."
Then in Tableau:
// For Tableau under 'Help' > 'Settings and Performance' > 'Manage R Connections'
// Server: 127.0.0.1 and Port:6311
// Make sure that 'RStudio' with 'RServer' is installed and running prior to Tableau connection
However I would like to do the same thing with Python, so Python can be used as a script in Tableau (not using Tableau's api in Python) - anyone know if this is possible? The snippet above was taken from here
There isn't a Script() call for languages other than R as of Tableau 8.2.
You could try using R as a middleman to invoke Python functions via the rPython or RSPython packages. No idea how performant it would be, but might be worth the hassle if you have a significant Python library that isn't available in R.
As of Tableau-10.1, there is a new package/library introduced which is TabPy which will act similar to Rserver for 'R' integration with Tableau.
Worth checking this article : https://www.tableau.com/about/blog/2017/1/building-advanced-analytics-applications-tabpy-64916
Related
I am attempting to make a small mafia style game, and I am using replit. Would there be a way to use a php server (or an html server) as a database that I can connect to from a python project?
HTML nor PHP are databases. The "LAMP" stack uses PHP with MySQL / MariaDB for its database, which might be what you're referring to... However, the "P" there could also be Python ¯\_(ツ)_/¯
What you need in Python is a Data Persistence layer, which could just be a simple CSV / JSON file; however pickle module is easier to work with native Python types.
sqlite module can be used if you want the data to be more portable to other frameworks/languages.
And the final option is to actually run your own database server externally and expose it over a remote TCP / HTTP API connection (I don't think Repl.it supports running Docker containers).
If you have access to the actual machine, you can run something like SQLite on the machine. You are running dangerously close to needing more security and what not though.
Security is important, but if you just want to "play around" running something like SQLite should answer your initial pass.
In other words, can the ansible "expect" module be used over a raw SSH connection?
I'm trying automate some simple embedded devices that do not have a full Python or even shell. The ansible raw module works fine for simple commands, but I'd like to drive things in an expect-like manner.
Can this be done?
The expect module is written in python, so no, that won't work.
Ansible does have a model for interacting with devices like network switches that similarly don't run python; you can read about that in the How Network Automation Is Different. I don't think that will offer any sort of immediate solution to your problem, but it suggests a way of pursuing things if it was really important to integrate with Ansible.
It would probably be simpler to just use the actual expect program instead of Ansible.
With Ansible 2.7 and up, you can use the cli_command module. It's kind of like 'expect' and it does not need python on the target.
https://docs.ansible.com/ansible/latest/modules/cli_command_module.html
- name: multiple prompt, multiple answer (mandatory check for all prompts)
cli_command:
command: "copy sftp sftp://user#host//user/test.img"
check_all: True
prompt:
- "Confirm download operation"
- "Password"
- "Do you want to change that to the standby image"
answer:
- 'y'
- <password>
- 'y'
I just started trying to connect to my broker through the FIX protocol.
The broker gave me:
an IP:port address to connect to
a "sendercompid"
a "targetcompid"
a password
I would like, as a first test, simply send a logon message to the broker and hopefully receive a message back from it. I would have thought this should be possible with a simple, small python script?
(ie im not interested in installing a fully fledge python engine / or use wrapper for c++ language such as quickfix)
edit:
to be more precise:
I found on SO example of doing (or trying) such thing in PHP, for instance:
$fp = fsockopen($host, $port, $errno, $errstr, 3.0);
if ($fp)
{
$request = "8=FIX.4.49=11235=A49=SENDER56=RECEIVER34=152=20130921-18:52:4898=0108=30141=Y553=user554=pass10=124";
echo $request;
fwrite($fp, "GET / HTTP/1.0\r\n" .
"Host: $host\r\n".
"Connection: close\r\n".
"Content-Length: " . strlen($request) . "\r\n" .
"\r\n" .
$request);
stream_set_timeout($fp, 2, 0);
$response = '';
while (!feof($fp))
{
$response .= fread($fp, 1024);
}
print "Response: ".$response . "<BR>\n";
fclose($fp);
}
Do you know which library i can use to simply communicate (ie send/retrieve) message to the FIX server in the same fashion in python?
Well, there's no standard python library for that.
You mentioned quickfix, what is a big project that seems maintained, and has documentation.
Looking for other third-party libraries, there is a smaller one, yet only for python2.6 or 2.7, named fixlib and currently hosted on github (the PyPI and bitbucket versions seem to be abandoned; the github version has been active 6 months ago). Major inconvenient: there is no documentation.
Looking at the code of these two libraries shows they are not exactly "small", so if you don't want to use any of them, as you will certainly have to rewrite similar code from scratch, you'd better forget about a "simple and small python script".
If you want to do a test in FIX protocol over a FIX connection you can try using the FIXRobot. FIXRobot allows to easily write the tests in python.
I'd like to interface with an opentsdb data store with Python. I only see a java client library for it. How would I go about this?
Unless you want a standalone client (in which case the Twisted Python OpenTSDB Client looks great), the easiest way is to run tcollector, and simply drop your Python script under /usr/local/tcollector/collector/0 – your script is expected to never return and print one data point per line in that format: metric timestamp value tag1=value1 tag2=value2 ....
tcollector takes care of connecting to OpenTSDB, pushing your data points out, etc. So you can focus on collecting the data you want to collect and write your data collection script in Python or any other scripting language you may like.
You can use Python request module and OpenTSDB HTTP API, too.
Give that library a try.
Twisted Python OpenTSDB Client
http://code.google.com/p/totsdb/source/browse/tostdb.py
Particularly, I'm working with python and vmware vsphere to make virtual machine creation/power on and stuff like that automated. I know how to print attributes of virtual machines, however, I still can't call any methods because I don't know how.
this is code snippet I'm having trouble with:
for vm in virtual_machines:
print "VM: "+vm['name']+" ("+vm['runtime.powerState']+") ",
if hasattr(vm['guest'],'ipAddress'):
print vm['guest'].ipAddress,
if vm['runtime.powerState'] == 'poweredOn':
print 'RAM: '+str(vm['summary.quickStats'].distributedMemoryEntitlement)+'MB, CPU: '+str(vm['summary.quickStats'].distributedCpuEntitlement)+'MHz',
if vm['name'] == 'VIRT_VZ_114':
# This is the trouble maker, it says types mismatch "suds.TypeNotFound: Type not found: 'guest'"
client.service.PowerOnVM_Task(mo_VirtualMachine,vm)
print
How do I call methods correctly?
Have you looked at psphere at all?
It's a python project to provide native bindings for the vSphere Web Services SDK.
You may be able to get your problems solved quicker with a dedicated library, rather than struggle with suds, SOAP and WDSL issues. It actually uses suds under the hood, but provides you with a pythonic API instead.