Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

DirectoryWatcher problems. Need Python coders

Questions and comments specific to a particular plugin should go here.
Post Reply
playahate
Posts: 1
Joined: Wed Jul 30, 2014 9:45 am

DirectoryWatcher problems. Need Python coders

Post by playahate »

I found an old thread viewtopic.php?f=2&t=2267&hilit=torrent&start=15 but as i'm not a programmer its wery hard to make it work.

So i got working profiles that Copy new files in folder to local sever.
ðÆÐàð¥ð┤ÐÅÐëð©ðÁ.jpg
ðÆÐàð¥ð┤ÐÅÐëð©ðÁ.jpg (22.67 KiB) Viewed 2411 times

Code: Select all

import shutil
import os
# coding: utf8
IgnoreFileTypes = 'txt,nfo'
FileName = ''.join(eg.event.payload)
FileExtension = FileName[-3:]
isFolder = os.path.isdir(FileName)
DestFolder = u'\\\\SERVERD\\path in russian language\\'
shutil.copy(FileName,DestFolder)
print os.path.basename(FileName) + ' copied.'
And i got another profile for another Folder that monitors files and copy them to backup folder with new name every time i hit save button.
Its working with local files and folders.
But when i change the monitoring path to server folder - it gives me 4 new files every time bacause event DirectoryWatcher4.Updated triggers 4 times. Maybe its due to Windows making temp files or the file is opend on several PCs...
I tried to make "stop presessing event", disable macro and enable it after sriypt... its not working.
When i insert "wait" in macro or time.sleep(5) in script it gives me the loop with new files that i cant stop or gives me 12 files...
I opened python yesturday for the first time, so the help is appreciated.
loop.jpg
So the profile is (dont look at the disabled items):
work.jpg
work.jpg (39.33 KiB) Viewed 2411 times

Code: Select all

import shutil
import os
import datetime
import time
# coding: utf8
FileName = ''.join(eg.event.payload)
FileExtension = FileName[-4:]
isFolder = os.path.isdir(FileName)
DestFolder = u'D:\\backup folder\\'
shutil.copy(FileName,DestFolder)
print os.path.basename(FileName) + ' copied.'

FileName1 = os.path.basename(FileName)
Name =  FileName1[0:-4]
now_time = datetime.datetime.now() 

print(now_time.strftime("%Y-%m-%d-%I-%M-%S"))
date = now_time.strftime("%Y-%m-%d-%I-%M-%S")
os.rename(DestFolder+FileName1,DestFolder+Name+' '+date+FileExtension)
Any ideas?
It gives me often the IOError: [Errno 13] Permission denied or WindowsError: [Error 183] Cant create file but still makes 4 files
By the way can i make copy with rename at the same time?
And again: im very far avay from programming so dont say "try to use .... function" =) i need direct code lines.
Post Reply