Hi,
I have this code, which monitors folders for incoming files:
Can you tell me how I could run such a daemon on different folders in different terminals with using CPU threading?
Thanks
I have this code, which monitors folders for incoming files:
import os import glob import time import threading import smtplib smtpserver = '' smtpserverport = 587 fromaddress = '' fromaddressusername = '' fromaddresspassword = '' toaddress = '' class Sc: def __init__(self, name='Sc'): """ you may enter a name when instantiation""" self.name = name print('* ' * 3 + ' DAEMON STARTED' + ' *' * 3) print('[+] Instance name: ' + name) def getlastwav(self): pass def countfiles(self, folder): pass def sendmail(self, to): print('[+] email sent to ' + to) def checkfornewwav(self, folder='.',refresh=5): """ checks for new wav files, and sends email """ print('[+] Folder to watch: ' + folder) print('[+] Refresh time: ' + str(refresh) + ' sec') while True: before = self.countfiles(folder) time.sleep(refresh) after = self.countfiles(folder) if before < after: print('[+] Last file: ' + self.getlastwav()) self.sendmail('[email protected]') threading.sc1 = Sc('first') threading.sc1.checkfornewwav('.', 10) threading.sc2 = Sc('second') threading.sc2.checkfornewwav('.', 12)I'd like the instantiations pop up in new terminal, moreover the second instantiation never gets instantiated this way.
Can you tell me how I could run such a daemon on different folders in different terminals with using CPU threading?
Thanks