Cannot get Perforce Triggers to work properly - python

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.

Related

Why do my files in vscode keep being deleted after trying to execute them?

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!!

Windows file starting with dot raises PermissionError?

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. :|

Python prgram won't buil d after renaming it

I've setup Geany a long time ago to compile my Python program on my Windows machine which it then sends to my Pi via scp. It still works fine - but if I take the same file and rename it, it refuses to do it.
I get "scp: /home/pi/scripts/APC2.py: Permission denied" from the Compiler in the MEssage window
And really don't want all my programs called the same thing.
I basically can't remember how I did the setup and can't find it anywhere on the internet.
Any help will be greatly appreciated
I found the link again:
http://www.python-exemplary.com/index_en.php?inhalt_links=navigation_en.inc.php&inhalt_mitte=raspi/en/installation.inc.php
Also my permissions for the new file were incorrect as Geany sends the file to /home/pi/scripts and I log in as root and not the pi user.

Made OSX .sh file into .app, refuses to execute

To preface, I've read other threads on the topic, but all their solutions don't work for me.
I have a small .sh file that just runs python3 foo.py. I used a script to turn this file into a .app file, but when I try to open it, I can see the app begin to appear in the dock and then disappear. However, when I open the file inside of the Unix executable itself in Terminal, all is well.
I have tried:
Changing the shebang in the .sh file to both #!/usr/bin and #!/urs/bin/env
Creating an empty .plist file
Making sure every file has execute permissions
Oddly enough, running open appname.app gives the following:
LSOpenURLsWithRole() failed with error -10810 for the file /Users/blah/blah/Lofi.app.
Thanks in advance
When you say you've read other threads on the topic, and the solutions don't work, does that mean you tried every thing in the comments under the sh-to-app script? There are a couple of specific fixes enumerated there.
What OS are using? Looks like higher OS needs you to register the app with the OS.
Check permissions of your personal shell script
Does it open in Terminal with open APP.app? I think you're saying it does. You can look at the last comment under the the sh-to-app script for possibly helpful instructions.
Not so much an answer, more of a workaround. I ended up taking the APP.app/Contents/MacOS/APP executable and creating an application in Automator that simply runs the file, and saving that process as an application in the Applications folder.

Permission error 13 Python 3.5.2

I have a problem opening a file with Python script in windows 10.
What I do is next:
I open my script as administrator in which create a new directory in the route:
C:\ProgramData\New_folder
Inside that folder I create a txt file:
C:\ProgramData\New_folder\log.txt
After that the program put some text in the log.txt and finish.
Now I have to open the script normally not as admin and when the program start it launch an permission error 13 in the following line of code.
dirLog = 'C:\ProgramData\New_folder\log.txt'
output = open(dirLog, "a")
I really don't know what is happening here because I check the file created and it has read and write permissions.
it's of vital importance open the script as admin just the first time, the rest just normally.
This might be caused because of the level of permission that the folder is set at. There is a possible fix for this, but it could cause security issues in the future as far as permissions for that folder go. If you can afford to change the permission level of the folder, try this: navigate to ProgramData, right click on the folder, click 'Properties', then hit the 'Security' tab at the top, then check the permissions for users. If the read permission is set off, turn it on. Otherwise, try enabling the write permission.

Categories

Resources