How come Pyatuogui locateCenterOnScreen function find the png I want it to look for? - pyautogui

When i'm using pyautogui to be able to load an application without having to use a keyboard and mouse. The application is opening, and I want to be able to find the location of the ADF4350 option and click it. The errors read "Failed to read ADF4350.png because file is missing, has improper permissions, or is an unsupported or invalid format." The picture is in my saved pictures folder. So far I have
import time
import pyautogui as auto
import os
#opens ADF Software
os.startfile("C:\Program Files (x86)\Analog Devices\ADF435x\ADF435x.exe")
#finds and click on ADF4350
time.sleep(2)
ADF4350_location = auto.locateCenterOnScreen("ADF4350.png")
auto.click(ADF_location)

Related

when i convert pygame file to .exe file pyinstaller says can't open script

I made a simple flappy bird game. I wanna convert it to .exe file, and I did it with pyinstaller but when I try to open the .exe file in the dist folder it says can't run script
I then copied my assets folder and pasted it into the dist folder, then too its not working.
How do I make it work?
If you are converting a .pyw file, then PyInstaller will only show the game window when you will run it.
If you want to convert a .py file, it will also show the Command Prompt.
If you are getting an error in the form of a message box, that means that an error has stopped your code. Because you converted a .pyw file, the error will not be shown in the Command Prompt. A message box will appear instead.
To see what was the error in a more explicit way, you can:
1. Convert your file from .py to .exe to see the error in the Command Prompt instead of in a message box.
Then, you can record your screen and see what was the error.
2. Show the message box by yourself
Before converting your file, edit it like that:
from tkinter.messagebox import showerror
try:
# your ENTIRE code here
except Exception as error:
showerror('Error detected', error)
This way the error will be shown in a Tkinter message box like that:
Common errors:
You forgot to put an image in the .exe directory
pygame.font.SysFont does not work: use pygame.font.Font instead and use a .ttf file (more information here)
exit() is not recognised, use sys.exit() instead (and import sys of course)

Goolge Colab file upload not uploading the csv file

Ran the following code in Colab:
uploaded = files.upload()
Clicked "Choose Files" and selected the csv I want to upload.
But the file is not being uploaded. It worked once before but not again. All videos I watch about how to upload csv's locally, once the file is selected, Colab uploads the file immediately.
Colab is not doing that in my case. It's just sitting stagnant like this:
stagnant colab
This is a Colab bug --
https://github.com/googlecolab/colabtools/issues/437
The team reports they are working on a service change to correct the problem today. (21 Feb, 2019)
Well even i had the same probem
you can also go for other option
1. In left pane of google colab there is a tab called Files Click on that.
2. click on the upload files.
Thats it!!!! Pretty Simple Enough!!!!
for more details :https://www.youtube.com/watch?v=0rygVrmHidg
Upload the file from the local machine using the following command:
from google.colab import files
import pandas as pd
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
After that read the csv/text file using the pandas:
dataFrame= pd.read_csv('filename.csv')
I have same problem. I use this method. Upload the file from the google drive using the following command:
from google.colab import drive
drive.mount('/content/drive')
data = pd.read_csv('/content/drive/Myfiles/datafiles/mydata.csv', delimiter=",")

How to import a .json file to Firebase Database?

I tried a few times via the web UI, but first the file wasn’t shown to me in the explorer and when i finally got around that and uploaded my .json there was one entry:
error: "Auth token is expired“
i just want to import that .json file, how does one do that?
The Auth Token probably expired because you were on the page too long before you uploaded it. Keep trying and it will work, given that the .json is correctly formatted.

MS Access VBA Data import for non-std file extensions

I am struggling to find the code I need to import a file into an access table.
It is a straight forward text file import however, the source file comes from a third party system and therefore the file extension is not the usual .txt file extension.
Instead the file is presented as ".ZZ;1"
This means that in order to import into access, I have to manually change the file extension before performing the import.
I wonder if there was a way to import the file (using VBA) with its given extension?
Or perhaps there is a piece of code which will allow me to change the file extension to something that access can read before I run my import script.
Any help or direction would be appreciated.
You can save yourself some grief by renaming the file to a standard extension (.txt or .csv) before importing it.
To rename: use the Name Statement
e.g.
strNewName = Replace(strPathFile, ".ZZ;1", ".txt")
Name strPathFile As strNewName
or if you don't want to change the original file, use the FileCopy Function, or FileSystem.CopyFile

How to use a download link to download a file in Python

Basically I am trying to write a script which will grab certain files on a webpage and download it to specific folders.
I am able to complete this with most of the webpages using Python, Selenium, and FirefoxPreferences.
However, when I try to grab off of this specific webpage, due to credential rights, I can't parse the html.
Here is the question. I am able to grab the download link for the file, and I can open a browser and have the open/save widget pop up. I can't however click or actually down the file any further. I have already set the Firefox Preferences to not show this widget, to download automatically, and to a specific file. This is ignored for some reason, and I am still left staring at the open browser, with the save/open widget.
How do I use the download link of a file to download to specific folder using Python... Selenium... any other related CS tricks. I don't want to build a bot to click the save for me. Too "hacky" and this is a company project.
Thanks!
you can try urllib
urllib.urlretrieve(<url>,<filename_with_path>)
import urllib
testfile = urllib.URLopener()
testfile.retrieve("http://randomsite.com/file.gz", "file.gz")
The good way to download a file with python.
Refer Here