I have a program (written in Python3.6, transformed into an .exe for Windows using cx_Freeze) that uses a lock-file to mark whether a user-login is currently in use, to allow the use of the same login across multiple computers while avoiding possible database corruptions.
The file is created right after the user login is confirmed (and deleted when the user logs out):
lockfile = os.path.join(user_dir, ".locked")
with open(lockfile, "w") as _:
os.utime(lockfile)
On my Windows7 Professional machine, this works fine. It also works fine on my local Windows10 test machine.
Now, I have a client on a remote location who is trying to use the program. And apparently, they consistently get a Permission Error: [Errno 13] Permission denied: '<user_dir>\.locked'. (Their path seems valid, and the program has no problem creating the user_dir, or writing a config.ini file to it, so writing privileges on the directory should not be the issue.)
Do some Windows versions maybe have trouble with files starting with a dot? Could using an underscore etc. instead help?
The client uses Windows10 (Enterprise) Version 1809 (Build 17763.379).
(It's hard to debug from here, and as I have to recompile the installer after every change, it would be nice to have an idea if this even makes sense... Any other thoughts about potential sources of the problem are welcome, as well!)
Apparently, it really was the starting dot colliding with some (but not all) Windows versions. I created a new version where the file is named "_locked" and it works fine now.
According to this article, creating filenames starting with dots is only added to Windows 10 1903:
https://www.ghacks.net/2019/02/25/windows-10-1903-support-for-filenames-and-folders-with-beginning-dot-character/
Had similar experience with Windows server 2019 where it was at least impossible to add .files via the file explorer. Workaround was to create the files via PowerShell, though I guess that doesn't really help here. :|
Related
I am currently learning to code with python in vscode but recently I have been having problems with file seemingly deleting themselves after attempted execution (image 1). I have tried Ctrl+z and I have tried recovering them but neither have worked. The files are not in my recycling bin either. If I try to create a new file of the same name in the same folder it shows me a error message (image 2) of "unable to resolve non-existing files"
When I execute my code the file saves but then becomes deleted:
This message appears if I try to undo the delete:
Have you tried to restart vscode? It is recommended that you could try the following aspects:
Check if there is any effect caused by the related expansion. For example, LaTeX Workshop extension has the function of cleaning generated files.
Check your setting.json Files,clear the contents of the user setting.json file and the vs code will return to the default value.
If it still doesn't work, you could consider installing vscode again.
Try running the Python file through a command prompt or terminal using the command python <foo_file_name>. Doing this will either confirm or deny the theory that #jasonharper made in the comments.
If you can run the script that way then we know that #jasonharper was correct and somehow your execute button/command was tampered with.
I had a similar issue using a different programming language. Building generated a file that got deleted automatically.
In my case the Windows 10 default antivirus was the cause. Turned off real-time scanning, tried again and then my files weren't deleted.
Adding an exception for the folder fixed it.
I had the Same problem with a PHP file, and turns out it wasn´t VS CODE. It was my antivirus that was moving the file to quarentine!!
Been trying to get this working all day, and i just can't figure out why its not working.
Trying to implement a simple trigger to run when the user submitted a file.
example in the .tmp file:
hello_trigger change-submit //testDepot/... "python F:/triggers/hello_trigger.py"
when i try to submit a file i get this:
Submit validation failed -- fix problems then use 'p4 submit -c 10199'.
'hello_trigger' validation failed: python: can't open file 'F:/triggers/hello_trigger.py': [Errno 2] No such file or directory
File exists and can be read, so its not a python issue.. same error with a .txt or .bat file.
From what i can gather the problem seems to be coming from the depot line in the trigger.
//testDepot/... fails
//depot/... doesnt fail, but the script is never fired off.
Any suggestions are greatly appreciated.
also testDepot is a stream not sure if that matters.
python: can't open file 'F:/triggers/hello_trigger.py': [Errno 2] No such file or directory
seems pretty clear that the file doesn't exist, at least from the point of view of this trigger command. Some things to double check:
This is running on the server machine, i.e. the place where the p4d service is running. If you have the script on your client machine the Python executable on the server isn't going to be able to find it!
Similarly, this is being run by whatever user is running p4d (on Windows this is usually the SYSTEM user, which may have limited permissions). Does that user have permission to read this path?
Could it be that your version of Python on Windows doesn't know how to handle paths with Unix-style forward slashes? (Many tools will normalize these for you but you shouldn't depend on it!) Try using a valid Windows path, i.e. F:\triggers\hello_trigger.py.
I am remote debugging python on a raspberry pi from a windows 10 PC running Eclipse. I am able to write and execute python scripts remotely. SSH is working fine and I am able to start a debugging session without any problem. However, when attempting to debug I keep getting the error
I am attempting to set the remote path in the file simpleTest.py below. This has worked previously. However, for some reason the old settings appear to be getting confused with the attempt to set the remote path.
import pydevd
from pydevd_file_utils import setup_client_server_paths
MY_PATHS_FROM_ECLIPSE_TO_PYTHON = [ ('C:\\Users\\baff6\\workspace\\RemoteSystemsTempFiles\\192.168.1.20\\home\\pi\\', ''), ]
setup_client_server_paths(MY_PATHS_FROM_ECLIPSE_TO_PYTHON)
pydevd.settrace('192.168.1.10', port=5678)
a=1
print( a )
Previously I was remotely debugging a file called mpsTest2 on a different raspberry pi. However, I am no longer working on this file even though Eclipse seems to be trying to find this file in the folder that contains the file that I am working on (in this case simpleTest2.py).
I have no idea where the references to this other file are but I presume they exist in some configuration setting in Eclipse. However, I have looked everywhere and cannot find anything.
Any help in tracking down these settings would be much appreciated assuming I have not missed something very basic in the setup procedure I am following.
Best wishes, John
I probably should have done this first but eventually found that uninstalling PyDev from Eclipse and reinstalling solved the problem. This removed the old references and I was able to remotely debug without any problems. I assume it is possible to achieve this end result without having to perform the uninstall/install but am not sure how to do this.
I have a short script written in python that saves a simple .txt to the same directory the .py file is in. Problem is: It only does so on one of my two computers.
My code doesn't include a hard-coded path to write to. On my laptop, I can put the makemeanote.py in any folder and it will create the note right there. On my desktop pc, all the notes end up in System32. PATH is set exactly the same way on both machines, and both use Windows\py.exe as the executable.
Somewhat interestingly, I only get an admin-screen on the desktop pc, asking if I want to allow changes to my system by "Built: Release_master_v3.8.2_"etc., whereas on my laptop it simply runs and does its job.
No amount of un- and reinstalling has changed anything, even when I thought I had eradicated any trace of python on my hard drive. Both PCs use current Win10/64 installations.
What is happening there?
A clarification: It's not about fixing the bug, it's about understanding the inconsistent behaviour! I know I could just hard-code any directory, but that takes away the beauty, don't you think?
I finally found the cause of the weird behavior:
For some reason, the py.exe in my WINDOWS folder was set to always be run as admin. As soon as I unchecked that option, the User Account Control (UAC) check disappeared and my file finally behaved as I had expected.
I'm trying to run python (version 2.7.2) on my computer (windows vista 32bit). It's always worked until now when Idle just does not respond to any commands.
Any commands entered (even very simple ones) have no output/do not get computed! See image:
Python works fine when I run it using command line though!
I've tried re-installing it a few times but it just doesn't help! Also tried running it from C:\Python27\Lib\idlelib\idle.py and I get the following message before the same unresponsive IDLE pops up again! See image:
Any help would be greatly appreciated.
Thanks
Try
print 1+2
You need to do something with the result.
A few suggestions:
IDLE starts a subprocess and connects to it over TCP port 8833. Is this port being blocked by a firewall on your computer?
Are there any files whose name clash with built-in Python modules? This page mentions problems with files called string.py.
Is the file config-keys.def under C:\Python27\Lib\idlelib missing or does it have its permissions set so that nobody can read it? I found that if I removed this file or restricted the permissions on it, IDLE became unresponsive as you described. If I then replaced it or reset the permissions, IDLE started working again. (Other config-*.def files in this folder might also need to be checked.)
This looks like the bug described here: http://bugs.python.org/issue14409
Your config file for key bindings is corrupt. Try renaming your ~/.idlerc folder to something else and restart IDLE.