I have written a Python program, this must change the contents of a file for a function.
This also works so far, but I have now converted this with Auto-py-to-exe into a folder, and also the required file is inserted.
When I open this exe file, everything works!
The problem occurs when I use InstallForge to convert the file to an installer file, transfer the file to another PC, restart the PC, open the software, and then try to use the function that describes a file. The software then crashes and the file is not saved.
If I run the software as admin, it doesn't get the error, so that means yes, to be able to rewrite files in the folder, you need admin permission. But it's just inconvenient to always be able to open the app by right clicking and then using "run as administrator".
Is there any way to simplify this? Can i use InstallForge to set special permissions to the files?
I have try, to search about it in the internet, but i havn't found anything about that.
Related
Context:
We have some Excel files with embedded VBA used only for refreshing them (the data source for each one of these Excel files is a SQL query therefore on refresh, the data gets pulled). After refresh, the file gets saved. All of these files are already saved in the One Drive folder.
When you open an Excel file that is stored in the OneDrive folder along with a specific ceremony (you have to first open Excel application, then go to open, then through Excel application open each file separately from the OneDrive folder), the AutoSave gets activated on Excel file. I hear that this is only available in O365.
Problem:
The problem is that on system restarts, planned & unplanned, we have to repeat this.
Granted this is not an efficient system to begin with and you can question the method itself, I was wondering if there is a way to open the files on system restart automatically with AutoSave enabled.
So far:
Please let me know if you need more information.
Currently I have tried Python and batch command, both open the file but do not enable the autosave which makes it pointless since the files should get save to OneDrive. It is worth mentioning that I used gpedit.msc in Run (Windows) to run the batch file on system restart and I have used the path for the shortcut of .bat file. The reason is that I wanted to test and see if running the .bat in Administrative mode would fix this and the only way that you can run a .bat file in admin mode is to create a shortcut and then set the default run-mode of that file to Admin mode.
For Python I used this script:
import os os.chdir('C:\\Users\\USER\\FOLDER) os.system('FILE.xlsx')
For .bat file I used this
#echo off set params=%* start excel "C:\Users\USER\FOLDER\FILE.xlsx" /e/%params%
I have tried using .bat to run Python to open the files as well and that also failed.
Many thanks in advance,
I have created python desktop software. Now I want to market that as a product. But my problem is, anyone can decompile my exe file and they will get the actual code.
So is there any way to encrypt my code and convert it to exe before deployment. I have tried different ways.
But nothing is working. Is there any way to do that?.Thanks in advance
This link has most of the info you need.
But since links are discouraged here:
There is py2exe, which compiles your code into an .exe file, but afaik it's not difficult to reverse-engineer the code from the exe file.
You can of course make your code more difficult to understand. Rename your classes, functions to be non-sensical (e.g. rename print(s) to delete(s) or to a()) people will have a difficult time then.
You can also avoid all of that by using SaaS (Software as a Service), where you can host your code online on a server and get paid by people using it.
Or consider open-sourcing it :)
You can install pyinstaller per pip install pyinstaller (make sure to also add it to your environment variables) and then open shell in the folder where your file is (shift+right-click somewhere where no file is and "open PowerShell here") and the do "pyinstaller --onefile YOUR_FILE".
If there will be created a dist folder, take out the exe file and delete the build folder and the .spec I think it is.
And there you go with your standalone exe File.
I need to locally store some basic data the user inputs into my exe. The program was compiled using pyinstaller and was previously making use of the os open method of saving data to txt files. It is my understanding that macOS(my OS although cross-compatibility with Windows would be great) locks executables so that they may not make any file changes. The program currently does save the data, but when the executable is run again the old data is no longer accessible.
It seems obvious that apps store things locally all the time, how can data be persisted specifically within the python/pyinstaller combination?
Apologies if this is a simple question, it definitely seems simple but I can't find documentation for this anywhere.
You can use
os.path.expanduser('~user')
to get the user home directory in a cross-platform manner, see How to find the real user home directory using python?
Your application should have write permissions in the user home directory, so then you can let it create and modify a data file there following How to store Python application data.
I am trying to create a google drive like backup program using python that backs up to a Linux box that will further backup to an off site place tbd. I have ran into a few interesting coding and computer challenges in doing this.
The one I am working on right now has to do with "locked" files. So what do I mean by this? In windows 7 if you create a .txt file you can open it in notepad(any program) and at the same time you can open it in a python program. If you make a change in the .txt file and save the change but BEFORE closing it you can still open and see the changes in pythn. Now change the file to a .docx windows file and open it with word 2007. While opened in word you cannot access it with in python until the user closes it.
Now if you look at google drive, the desktop install not the web only variety, you can open a .docx file and change it. Once you save it but BEFORE closing google drive has already synched the file.
Google drive must have some sort of lower level access to the file than the simple python file.open() command.
So here is the question. Does anyone know of a way to access files in python in such a way as to keep me from having to wait for the user to close the file.
Edit 1:
Let me further explain. Once I have created an sqlite database that has all the files and directories I will then use the win32file.ReadDirectoryChangesW() function to monitor for changes. My problem stems from the fact that when setting up the application of first install/run it must catalog all files and files that are open in windows office are locked and cannot be cataloged. Is there a way around this?
Many backup tools use snapshots. Then, they'll copy the locked file directly from the snapshot rather than coping it directly from the filesystem. If you're on Windows you should check Windows VSS, see the Microsoft documentation for more details. Otherwise, if the filesystem you're on supports snapshots check its documentation as well.
Third party tools
You can use the subprocess Python module to run third-party tools which will take snapshots for you.
Microsoft VSS
In case you want to do it by yourself you might need modules from the Win32 API such as win32com module.
There is also on Github a project that seems to do the job: pyshadowcopy
Filesystem Snapshot
Depending on the filesystem features, you might find python modules or tools allowing you to take a snapshot.
https://drive.google.com/file/d/0BwR0ium7uufRWnhXWWNFcVJ3S2c/edit?usp=sharing
The files that are blank and say "Credit Card Balance" and "mine" are the files which I created by opening up a new document in IDLE and creating a file. The ones with the little pictures and say ps2_newton are programs which I downloaded off of the internet. I can't open my files which I created like they are regular programs and have to open them under notepad to see the code. Why is this? How can I change my files to look and act like the ones I downloaded?
The files you downloaded have an extension of ".py", which tells Windows to open them with the Python launcher, while the ones you created have no extension, or an extension of ".txt", which tells Windows to open them in Notepad.
Since ".py" and ".txt" are both "known extensions", and you have Explorer configured to hide known extensions (which I believe is the default in all versions of Windows), it doesn't show them to you. However, you can see the difference in the icons.
You can configure Explorer to show all extensions, but this site is not the place to ask about that—try SuperUser.
Meanwhile, when you save your scripts, make sure you save them with a .py extension (or, if they're Tkinter or other GUI apps, with a .pyw extension).
I had the same problem. But I just deleted all of the é's and á's etc. And it worked! So try that IF it is an .py file. Otherwise I understand if it does not work becouse it isn't a python file. You change that by doing this: Save as. Just simply type .py after the file name.
PS Sorry for my bad english...