I need to use python to configure the file's access rights (I don't know exactly what it's called attached a screenshot). I have an application installer and it creates a folder in the system, this folder needs to be protected from the user, that is, to make it so that he could not edit, view and delete it. I've read a lot of articles, tried a lot of options, but unfortunately everything is even. os.chmod was mentioned a lot, but all the result I got from it was setting up a "read-only" file. How can I prevent the user from interacting with the folder and its files so that he could not remove the lock? But at the same time we should be able to interact with files using python scripts?
Related
I am facing a strange problem, which is that my when I write a file or create a folder from within my Python program, it creates those files and folders with full permissions, while my default user permissions are not like that.
So, my question is, is there a way I can set the permissions from within my Python program, so that it creates all files and folders with some specific permissions.
I am currently looking for a way to script a scraper that can fetch information from the HTML or webstore from the extension itself.
I want to be able to go to say for example "LastPass", be able to identify the extension ID (which looks like it is contained in a nonscne field) and download the extension permissions without installing the extension. I don't see a field containing the permissions on the web store itself.
We have a locked environment at my work place and we have to use a non work device just to be able to download an extension to tell what the permission levels are. FireFox has these permissions displayed on the store itself. I know the JSON file itself contains the permissions, but is there a way for someone who doesn't own the extension itself to go the web store and script a way to grab from maybe the HTML file somewhere?
I am a little lost on this, I am assuming Python might work best for this but I am not even sure where to started.
I'm writing a python script which copies files from a server, performs a few operations on them, and delete the files locally after processing.
The script is not supposed to modify the files on the server in any way.
However, since bugs may occur, I would like to make sure that I'm not modifying\deleting the original server files.
Is there a way to prevent a python script from having writing permissions to a specific folder? I work on Windows OS.
That is unrelated to Python, but to the filesystem security provided by the OS. The key is that permissions are not given to programs but to the user under which they run.
Windows provides the command runas that allows to run a command (whatever the language is uses) under a different user. There is even a /savecred option that allows not to provide the password on each activation but instead save in in the current user's profile.
So if you setup a dedicated user to run the scrip, give it only read permissions on the server folder and run the scrip under that user, then even a bug in the script could not tamper that folder.
BTW, if the script is runned as a scheduled task, you can directly say what user should be used and give its password at config time.
I have previously written a script using python that monitors a windows directory and uploads any new files to a remote server offsite. The intent is to run it at all times and allow users to dump their files there to sync with the cloud directory.
When a file added is large enough that it is not transferred to the local drive all at once, Watchdog "sees" it as it is partially uploaded and tries to upload the partial file, which fails. How can I ensure that these files are "complete" before they are uploaded? Again, I am on Windows, and cannot use anything but Windows to complete this task, or I would have used inotify. Is it even possible to check the "state" of a file in this way on Windows?
It looks like there is no easy way to do this. I think you can put in place something that checks the stats on the directory when it triggers and only actions after a given amount of time that the folder size hasn't changed:
https://github.com/gorakhargosh/watchdog/issues/184
As a side note, I would check out Apache Nifi. I have used it with a lot of success and it was pretty easy to get up and running
https://nifi.apache.org/
I'm building an app with Pyside. Part of what the app does is download some xml files from a website and store them for later use. For example, every time the program is started it checks for these directories and, if they cannot be found, downloads the xml files, creates new directories, and stores the files in them. I'm wondering if there is some compelling reason not to allow the program to create new directories (permissions, security, etc.) and, if so, what other options exist?
EDIT: To be clear, I'll need to read and write to these directories and possibly create new ones as new files appear on the webpage.
Almost all programs need to write to config and/or cache directories. The only thing you need to worry about is making sure you use the appropriate platform-specific locations for doing this. Do not use an arbitrary, application-specific directory.
In Qt4, the QDesktopServices class can be used to determine the correct storage locations, or in Qt5, there's the QStandardPaths class.
Yes, it is normal for programs to store files in config / cache / log folders.
Use the python package appdirs to find the correct folders to use for your program.