I am currently working on a django project and trying to import models from a python source file
I typed python manage.py shell < dummy_source.py
in cmd and it resulted in an error:
observer.join()
^
SyntaxError: invalid syntax
However, when I just typed python dummy_source.py
, it worked without any problems. I have gone online to find something useful but there are not any.
I would love to know why does this happen, thanks in advance.
Here is the content of dummy_source.py:
import os, time, sys
import subprocess as proc
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class MyHandler(FileSystemEventHandler):
def on_created(self, event):
print("Created!")
os.system('cmd /c "mkdir workspace"')
print("Deleted!")
os.system('cmd /c "rmdir /s /q workspace"')
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, path = 'media/submited_files', recursive = False)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()