#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os,sys,time
from matplotlib.cbook import print_cycles
from plate_detect import imgChecker,getPlate
from multiprocessing import Process,Queue,Pool
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import threading
def fileChecker(path):
cnt = 0
print('Child process %s.' % os.getpid())
dirs = os.listdir(path)
size = len(dirs)
while True :
lock.acquire()
tdirs = os.listdir(path)
if len(tdirs) > size :
time.sleep(5)
filename = tdirs[-1]
print( filename )
cnt += 1
print( 'cnt:%s'%(cnt) )
size = len(tdirs)
dirs = tdirs
lock.release()
def main():
"""Run administrative tasks."""
print('Child process %s.' % os.getpid())
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'parkSystem.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
print('Parent process %s.' % os.getpid())
p1 = Process( target=main )
p2 = Process( target=fileWatcher, args=('.\\pictures\\car_img',))
#p2 = Process( target=imgChecker, args=('./pictures/car_img',))
p1.start()
p2.start()
p1.join()
p2.join()
|