Controlling Kodi from Browser - python

I am currently building a media website using node js. I would like to be able to control Kodi, which is installed of the server computer, remotely from the website browser.How would I go about doing this? My first idea was
to simply see if I could somehow pipe the entire Kodi GUI into the
browser such that the full program stays on the server
and just the GUI is piped to the browser, sending commands back to
the server;
however, I could find little documentation on how to do that.
Second, I thought of making a script (eg Python) that would be able to control Kodi and just interface node js with the Python script, but again,
I could find little documentation on that.
Any help would be much appreciated.
Thank You!

Can't you just go to settings -> services -> control and then the 'remote control via http' settings? I use this to login to my local ip e.g. 192.168.1.150:8080 (you can set the port on this page) from my browser and I can do anything from there

Related

Handling remote (RDP) mouse clicking via Python

I am using pyautogui to automate some mouse clicking in a script that I created.
This script needs to perform one click to log into a program, nothing else (besides other non-clicking stuff). The idea is that the script will run on a remote Win10 PC via a task scheduler every day at, lets say, at 11PM.
My script works perfectly when run on my own PC but I am running into issues with how to handle the remote RDP resolution to correctly identify the mouse position to click. Furthermore, the script will run on a remote PC that might not have "active user" logged in and I am not even sure if this mouse clicking approach will work. How to identify correctly the "resolution" of the remote PC?
Could you help me?
Thanks.
Pyautogui can be used to interact with remote system the same way a human can by opening the RDP or VNC window identifying elements inside of it and then directly interacting with them. This works but you're now expecting two systems to be in sufficiently consistent state for the automation to work. This does have the advantage that you don't need to know the resolution of the remote system just what the interactable elements look like when rendered through the RDP client on your system.

Using IIS to show Bokeh dashboard

I am new to Internet Information Services for Windows. I have a Bokeh dashboard ready and I can serve it using the terminal and the command
bokeh serve app_myapp/ --port 5200 --allow-websocket-origin=my_IP_address
In IIS, I have set up the Host Name (xx.yyy.com) and the Port (80), and the Physical Address is C:\inetpub\wwwroot\some_blank_htm_file
Currently xx.yyy.com shows my blank file, but I don't know how to connect serving my bokeh dashboard with IIS settings.
I would greatly appreciate any help.
Do you mean you want to show the bokeh dashboard when you use xx.yyy.com address?
In my opinion, the most easily way is using the IIS url rewrite to achieve your requirement.
You could install it from this url.
Then you could redirect all the request to the port 5200 by using below config setting.
<rewrite>
<rules>
<rule name="Reverse Proxy to webmail" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:5200/{R:1}" />
</rule>
</rules>
</rewrite>
More detials about how to use reverse proxy, you could refer to this article.
The goal is to use IIS as a reverse proxy. IIS is not a reverse proxy by default, so we have to add some modules and then start the configuration. These are all the steps I took:
Install the URL Rewrite package from the Downloads section on the IIS website.
Install the ARR (application request routing) module from the Downloads section on the IIS website.
In IIS, under sites, add a new website and set the Host Name to your FQDN. Also, Choose a Site Name and a Physical Path (I think it doesn't matter what.) and click OK.
In the left pane, double-click on the website you created. In the modules, double-click on URL Rewrite, then click on Add Rule(s), choose Reverse Proxy and click OK. Then in the new window type 127.0.0.1:my_bokeh_port and hit OK.
From the left pane, double-click on the main tree node with your server name on it, and from the modules, double-click on Application Request Routing Cache. In the right pane, choose Enable proxy, and set HTTP version to Pass through.
Use this guide to set Server Farms. Honestly, I'm not really sure if this step is necessary, but since I had done it before some of the former steps I just mentioned, I thought it might be.
Close and restart IIS.
Now, if you go to your website in your browser, you will probably see your address (for example x.y.'com') change to x.y.'com'/app_myapp. If you can also see your dashboard, then that's all. If not, however, it means that your firewall is blocking the WebSocket connection. You can use this guide to allow a TCP connection to your Bokeh port.
Hopefully, now you can refresh and see your dashboard.

Is it possible to use python to establish a putty ssh session and send some input?

Fist of all, due to Company Policy, Paramiko, or installing anything that requires administrative access to local machine it right out; otherwise I would have just done that.
All I have to work with is python with standard libraries & putty.
I am attempting to automate some tedious work that involves logging into a network device (usually Cisco, occasionally Alcatel-Lucent, or Juniper), running some show commands, and saving the data. (I am planning on using some other scripts to pull data from this file, parse it, and do other things, but that should be irrelevant to the task of retrieving the data.) I know this can be done with telnet, however I need to do this via ssh.
My thought is to use putty's logging ability to record output from a session to a file. I would like to use Python to establish a putty session, send scripted log-in and show commands, and then close the session. Before I set out on this crusade, does anyone know of any way to do this? The closest answers I have found to this all suggest to use Paramiko, or other python ssh library; I am looking for a way to do this given the constraints I am under.
The end-result would ideal be able to be used as a function, so that I can iterate through hundreds of devices from a list of ip addresses.
Thank you for your time and consideration.
If you can't use paramiko, and Putty is all you get so the correct tool is actually not Putty - it's his little brother Plink - you can download it here
Plink is the command line tool for Putty and you can your python script to call it using os.system("plink.exe [options] username#server.com [command])
See MAN Page here
Hope it will help,
Liron

Writing a proxyfier application with python

I'm new to coding in Python and what motivates me to start coding is the idea of writing a piece of software that will connect to a proxy server via SSH and then once connected will route all network traffic of the system trough it, seamlessly to the user.
I am actually using the paramiko module to connect to the server and it works fine, but now I would like to know if there is some way to make the system change its socks proxy configuration so I can route the traffic to the proxy, on a way the user doesn't need to do anything. Is there any existing module that will help on this task ?
Thank you.
You can see the existing project sshuttle, it transfers all traffic over ssh.

Remote website trigger a local action

I have large video files (~100GB) that are local on my machine. I have a non-local website where I enter information about the video file. In addition, I need to get the checksum of the video file (and I do not want to manually trigger the script locally and copy and paste the value). To get a checksum of the video file, I have a script I can run as $ checksum.py <video file>.
How would I trigger the local script through the web interface? In other words, I want to be able to enter the PATH of the video file and click Submit on the web app, and it will locally trigger the script, and (after the checksum has finished), insert that value into the web app/database. What would be the best way to do this?
You cannot trigger anything unless your local script is continuously listening for some kind of data feed (like a fixed URL serving an XML/JSON feed of paths) which is, IMHO, over-complicating your system.
You could also use a Java applet ran locally instead of a remote website, but you'll have to sign it to be able to read local files, and it might not be what you're looking for.
Think of it: it's all about security. Would you like any web server to trigger scripts in your local machine? I certainly wouldn't.
IMHO the best solution is to trigger the script manually which will send the data to your web server.
In general browsers run in a sandbox that has very limited access to the OS. In particular you can't run shell scripts from a browser. As I see it you have two options:
Adapt your checksum.py script to send the checksum info directly to your website using the urllib2 calls, or pipe the results to a "curl" command. (No browser involved.)
Rewrite checksum.py as JavaScript using the FileReader class. This will probably be convoluted, slow, and won't work in Internet Explorer.

Categories

Resources