Refreshing WinDir whilst using MicroPython - python

I'm new to both Python and MicroPython, but i'm getting the hang of this interesting approach at embedded programming!
After creating a new file with the PyBoard, I was wondering whether there is a clever way to refresh the
Windows Directory of the representation of the PyBoard flashDir, and then seeing the change in the windows directory.
Currently, i have to turn off and reload the PyBoard to see the change in a windows directory.
I am aware that i am able to see the file using os.listdir() in a REPL.

Related

How to get file to open with python app I made

For the past month I've been writing a desktop application for MacOS using Python. It requires opening files and saving compressed data to them. This application creates files using a my own made up extension, so the files are not usable for for other applications. I have almost everything figured out. However, I want to make it so that I can right click on a file with the extension and open it with my python application. I tried using sys.argv to get any arguments for the path of the file to open, but that doesn't work. I know there has to be a way. Preferably there's a builtin variable that is easy to use, but I haven't found anything that helps.
Any help would be useful.
Thanks.

IDLE freezing/unresponsive when saving new file

I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3
My problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new/'Untitled.py' file, the save folder will pop open, and I can name the new file/navigate folders, but once I hit "Save", the program freezes with the save folder still open, except now the Save/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.
What's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.
To be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up.
I had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.
Please help!
I've also had this problem, and what I did was change the location of where the file would save. I suggest trying this to help.
I'd suggest reinstalling python idle (your programs will be saved). If this doesn't work then maybe it has something to do with your security on the mac.
I had the same problem, and as Aadi suggested, I was able to fix it by changing the location of where the file was saved. Possibly, this relates to very long paths, at least in Windows 10.
The path that didn't work was 114 characters long. The path that did work was 93 characters long. The paths are the same up to character 80 and use underscore (_) but no unusual characters.
You don't have to make/save python files in IDLE. You can open any text editor, type the code, and save as name.py. Then you can open that in IDLE. I would use that for now.
I also came across with same issue, this is only issue of currupt file,please delete recent python IDLE file that you have created,this will definately work

Can you stop PyCharm from automatically closing script files when you click out of the program?

I am having a problem with PyCharm (Community Edition) in that, when I open a .py file in the program, I can happily read and write in the file as usual, however when I click out of PyCharm (to look my emails for example) and then click back into it to carry on with my code, the file automatically closes and the project tree structure collapses (so I have to re-open it every time).
So far I have tried changing the tab limit to a high number, but this doesn't seem to help (and it shouldn't be related, since this happens when I open just one file).
I had the same issue before. I'm assuming you're connected to a network shared folder via UNC path (e.g. \\foo\bar\)?
If so, it is not currently supported. You'll need to map your network folder and give it a Drive letter. Then load up your project using the mapped drive, and it'll work like a charm.
If that's not the scenario though, please give us more information.

Block file writing in external drives

I am working on a project for my company and I have reached a dead end.
I am trying to find a way to be able to decide whether to allow or block file writing to an external drive based on the content written.
The project is creating a basic DLP system.
I have tried using pydbg to debug Windows explorer, this worked partially but was very unstable and it doesn't work globally (ex. file write with cmd).
The solution can be in any language (Python preferred).
Any kind of help would be great!

Python script into a standalone single file executable that can auto-update?

I wrote a program in Python 2.7 for my office. Using PyInstaller with the --onefile flag, I've compiled it into a single EXE file to distribute to my co-workers. What I'm trying to figure out now is how to supply updates automatically but still keep the program as a single file.
My current method is to have the program alert the user of a new version and give instructions where to obtain the updated file. This works, but I want to find some method of updating without the user's involvement.
I am aware of Esky, which can create auto-updating Python programs, but as far as I can tell, it requires the program to exist as multiple files.
Any suggestions on how I make a standalone, single file EXE python program that can auto-update?
you can download your new executable to a temp folder
use __file__ to know the current location of the executable
show a message that you need to restart
use sys.execcv or subrocess alternative to replace the current running process with a small script something like
"sleep(1) & copy {tempfile} {filename}".format(tmp_file,__file__)
(simple batch commands that overwrite the old exe with the new exe)
When your application has alerted user of a new version and user has said they want it, download the new exe, start the new exe, and shut down current exe. The new exe should remove any old exes it sees around. The different versions need to be named differently.

Categories

Resources