Off hand, i can see a flaw with the line above; 2 things worth mentioning:nzbget_fan wrote: info Wed Mar 01 2017 09:16:31 DirWatch: 2017-03-01 09:16:31,229 - 4196 - WARNING - Source directory C:\Windows\system32\* was not found.
This part of the script is working as it should, you can see within the logs that it detected that NZB-Files should be moved here:nzbget_fan wrote: My nzbget root-directory (where nzbget.exe is located) is "F:\!Downloads\Anwendungen\Netzwerk Tools\nzbget".
Code: Select all
info Wed Mar 01 2017 09:16:31 DirWatch: 2017-03-01 09:16:31,165 - 4196 - INFO - Target directory set to: F:\!Downloads\Anwendungen\Netzwerk Tools\nzbget\downloads\nzb
The script runs now.The search path in the script options didn't contain any system paths. My next problem was that another script which took the passwords from filenames didn't run anymore when the ShellOverride option was set. I'm avoiding the problem with the two python versions by running the script as a windows task.Try option ShellOverride in nzbget to associate .py-files with python 2.x.
2017-03-01 21:25:52,030 - 15756 - INFO - Target directory set to: F:\!Downloads\Anwendungen\Netzwerk Tools\nzbget\downloads\nzb
2017-03-01 21:25:53,246 - 15756 - INFO - Loaded NZB-File: Test_{{PW}}.nzb.zip, category='Movies'
2017-03-01 21:25:53,246 - 15756 - WARNING - Failed to remove NZB-File D:\Test\Test_{{PW}}.nzb.zip after loading it into NZBGet
Yeah... he's pretty awesome; I'm glad you're closer to a working solutionnzbget_fan wrote:Thank you very much for your support.
This hint from hugbug helped me.
After i process the NZB-File, i attempt to delete it (for this very reason because I'd hate to process it a second time and get stuck in a loop. But maybe i need to re-think this process a bit better? Maybe I should try renaming it to something else... (anything at all). I'd do this just to see if i have write permissions on the directory (where the NZB-Filee sits)... Only if these permissions are present would i preform the file handling.... make sense?nzbget_fan wrote:But there's another "bug" which I underestimated. I accidentally ignored this behaviour in my first test:
Either it is run as nzbget oder standalone-script it doesn't move/delete the original zip-file. So every time I run the script it imports the old an new files into nzbget (cause the old files are still in the source directroy). From command line I'm running it by starting cmd.exe with admin rights and executing "py dirwatch.py ...." from there. I tried it even with several source folders and also reinstalled the latest Python 2.x-Version 2.7.13 for windows.
Code: Select all
2017-03-01 21:25:52,030 - 15756 - INFO - Target directory set to: F:\!Downloads\Anwendungen\Netzwerk Tools\nzbget\downloads\nzb 2017-03-01 21:25:53,246 - 15756 - INFO - Loaded NZB-File: Test_{{PW}}.nzb.zip, category='Movies' 2017-03-01 21:25:53,246 - 15756 - WARNING - Failed to remove NZB-File D:\Test\Test_{{PW}}.nzb.zip after loading it into NZBGet
Unfortunately I'm not good in programming . So I have no opinion about how solving file handling the best way. I'm even not sure if it is a problem with the script or Python. I''m sure that my windows user (admin) has all rights in the source directory. So when I start your script from windows command line I get the error mentioned above, that it was unable to remove the Zip-File. After running your script I did a DOSAfter i process the NZB-File, i attempt to delete it (for this very reason because I'd hate to process it a second time and get stuck in a loop. But maybe i need to re-think this process a bit better? Maybe I should try renaming it to something else... (anything at all). I'd do this just to see if i have write permissions on the directory (where the NZB-Filee sits)... Only if these permissions are present would i preform the file handling.... make sense?
Thoughts?
In the meantime, you can definitely fix this problem by making sure the same user that NZBGet runs as has write permissions to the directory the NZB-Files are found in.
I'll have a look at this tonight if i can; otherwise worst case tommorow night.
Code: Select all
del *.*
Code: Select all
warning Thu Mar 02 2017 21:05:24 DirWatch: Failed to remove NZB-File D:\Test\Testfile_{{pw}}.nzb.zip after loading it into NZBGet
Code: Select all
D:\Test
Thank you for your feedback! Anything you have to share helps regardless of your programming experience!nzbget_fan wrote: When I was just reading my text again I recognized that it was a zip-file containing the nzb-file that couldn't be deleted. So I just extracted the nzb file to the foldermanually and tested it again. Now it was able to delete the remaining nzb-file in the folder. So I guess it might be a problem with the unzip-process which locks the zip-file and makes it undeleteable this way.Code: Select all
D:\Test
I hope this information helps you.
Hey, good job so far The script has almost stopped now from processing the same file over and over again. But it lets the processed file remain in the directory with a .dw ending and an additional copy with the ending .dw.dw. I would prefer a complete cleaning of the directory as I get a error message in my nzgbet protocol every minute / with each script cylcle that the prep of the remaining .dw file has failed.So... I did quite a few (moderate) code changes. I may or may not have solved your problem, but I certainly eliminated the issue you got into where you were processing the same file over and over again. Grab the latest master copy (shortcut) and give'r another shot! Please let me know your feedback!
Code: Select all
DirWatch: Could not prep FILE: NZB-File D:\Test\Testfile_{{pw}}.nzb.zip.dw (NZB-File D:\Test\Testfile_{{pw}}.nzb.zip.dw.dw)
Done! I added an option to handle .dw files if they're detected when the script starts (but it's a configurable option from the Settings, or -c (for --auto-clean) from the command line), then they will be automatically deleted (if permissions allow for it).nzbget_fan wrote:PS: An easy solution might be deleting all .dw-files in the source directories at the beginning of each cycle.
Code: Select all
import glob,os ; [os.remove(x) for x in glob.glob("D:\Test\*.dw")]
Users browsing this forum: No registered users and 33 guests