i have a tkinter interface with a button that should download a specific pdf file which is stored in the project folder. I know ways to download files wit a url but in my case its the file that only exists in my local project directory. How can i implement this?
Related
I am making a console app to download gcp objects using service account GOOGLE_CREDENTIALS, which is stored in json file. When i buddle my project using auto-py-to-exe to make it as an exe file. The json file comes into this folder. I want to hide this file from user. Is there any way to do so??
You can use os.chmod at the end of your setup script to make any file of the build directory read-only. For example:
import os
import stat
os.chmod(path_to_file, stat.S_IREAD)
And also to hide use below :
stat.FILE_ATTRIBUTE_HIDDEN this indicates The file or directory is hidden. It is not included in an ordinary directory listing. Refer this Link how to use file attribute Hidden.
Refer this SO for more information
I am trying to download a file from my Dropbox account, however, on Linux (Raspbian) when I execute the line:
dbx = dropbox.Dropbox(TOKEN)
dbx.files_download_to_file(LOCAL_PATH,r'/file.ppsx')
It is downloaded as a zip. I do not have this problem executing the code on Windows. I'd like to note the file is a .ppsx, a PowerPoint presentation file. I have no problem downloading it manually from Dropbox. My question is, how can I circumvent this problem and download it unzipped?
It seems that Dropbox sent the file not as a zip, but rather changed the name of the file to the directory of where it was installed. I circumvented this problem by using the os.rename module. This solved the problem and allowed me to open the file within the same script.
I have a URL which is a download link http://vis-www.cs.umass.edu/lfw/lfw.tgz
It is a huge file with multiple folders tar into one tgz file.
I want to download the file in chunks and want to trigger some event when one folder gets downloaded.
I am using Python's requests library to download the file, I know how to download the file in the chunks but is there any way to download folder by folder and trigger some event when the file is downloaded?
I am okay if I have to use some Linux utility, I can execute the command using subprocess but is there a way to do it ?
If a user wants to create, for example, a project in PyCharm, you would first pick a folder using File Explorer and then the project would be created in that folder.
How can I do that using Python?
I know there is a module called subprocesswhich can open File Explorer using this command subprocess.Popen("explorer") but that's about all I know.
How can I make the user choose a folder a file will be stored in and then create a file in that location?
you can use this:
from tkinter import filedialog
folder = filedialog.askdirectory(initialdir=os.path.expanduser('~'))
this =os.path.expanduser('~') will open the explorer in the HOME folder
I have been trying to download files from a site that changes the download links after some time. I tried using wget module to download those files. It does work on the direct links to file like(http://example/file.zip) but it doesn't download files from links that are temporary they change and do not seem to be direct links of the files. Those are like (http://example.com/file/) I have to use webbrowser module to open those links so it would download those files (as the webbrowser and download manager do download those files) I want to download those files directly with python 3.
(I have tried downloading with urllib and requests module)