Using Python on a Raspian (Raspberry pi) system I can successfully play and listen to a .mp3 file using the os.system() call with mpg123 and a valid URL.
How can I use Python to save the .mp3 file to disk instead of listen to it?
I can save it manually by right-clicking on the web page's Play button and selecting "Save video as...", but I don't know how to do that in a program.
I checked the manual page for mp3123 here:
http://linux.die.net/man/1/mpg123
According to that page, you can specify an output file using the -O option or --outfile.
P.S. os.system() is a simple way to get started. If you ever start getting frustrated by limitations of os.system(), such as not being able to capture the output or the error output, I suggest you use the subprocess module. It's more complicated, but once you are used to it, it's easy to use... and it gives you full control over how your program executes.
Related
I am trying to access the current audio output level of my browser to know whether it is making noise.
I want to read some eventlog files with python over wmi. actually I can read event logs like System, Application, Security, InternetExplorer, PowerShell. But I cant access the eventlog file for the remotedesktop.
Currently Python script:
python_script
The function check_vnc_services works. My problem is, that I cant open the eventlog for remotedesktop. I also tried it with C# and C++. I cant access it:
eventlog file that I will open
Also the WMI Code Generator didn't show me such microsoft files:
enter image description here
I hope that someone can told me how I can access this rpd event log file. Suddenly I think that I maybe using a wrong WMI?
I have a Raspberry Pi running Linux. My plan is that I can plug in a USB in the robot and have and it will run the python files. the reason I chose this method is that it allows for easy editing and debugging of the scripts.
Is there a way to execute my files when the USB is inserted?
Try to use os.path.exists to detect whether the pendrive is there in an infinite loop and when detected execute code on pendrive using os.system and break out of loop .
Check this link out: https://ubuntuforums.org/showthread.php?t=1648939
Looks like you should consider writing a script that navigates to the directory of the file and runs "python yourscript.py". The details on getting the script to autorun are there.
With Selenium Webdriver, I have to upload some files on a website but since the pop-up window for browsing the file location is handled by the operating system and not the browser, I cannot automate that part with Selenium.
So I want to know which framework or module I need to use to work with system windows of Windows OS. Can tkInter or wxPython be used for this?
My script will be used on Windows 7, 8 & 10.
Actually, you can upload files without interacting with upload prompt pop-ups.
To be able to handle file upload with selenium you should send path to file to appropriate input field without clicking on "Upload" button. Try following:
path_to_file = 'C:\\Files\\path\\to\\file' # use your specific path instead
driver.find_element_by_xpath('//input[#type="file"]').send_keys(path_to_file)
P.S. Let me know if this code doesn't work as you expect
You can call autoit3 framework from Python even to open the File Open dialog and fill in the values and press OK or do whatever with the windows. Autoit3 has a dll that can be loaded and called using ctypes. That's what I did in one or 2 projects.
If I understand your question correctly, wxpython or tk won't help you. They can be used to make the windowed UI, not to control other programs.
I'm using Python and I want to open Notepad++ with a specific .xml file. I am able to do that with the following code:
os.system('start notepad++.exe m1.xml')
What I want to do after this is use a plug in on Notepad called 'pretty print xml' that's under the plug-ins menu, but I have no idea how to access it with just code. I was wondering if anyone knows a way to access this item without installing plug ins for Python; I don't want to have to install a plug in for Python, I want to be able to use Python to control the Notepad++ application.
Basically, via code, I want to:
Open the document [done]
Open a menu in notepad
Click a specific button in that menu
Save the document