Folder Structure
Sym\sym : source code
\test : testing code
\docs : documentation
On Testing
Also like the idea of Thomas Andrews in [1] to put unit test code in the module itself:if __name__ == '__main__':
do tests...
if __name__ == '__main__':
do tests...
# File: sym.py
# Author: hoekit [at] gmail [dot] com
from multiprocessing import Process
import os
import time
def sym_do(cmds):
fp = open('sym.log','a')
for x in cmds:
if x.strip() == 'terminate':
return False
else:
fp.write(x)
return True
def sym_run():
try:
fname = 'cmd.sym'
fp = open(fname,'r')
commands = fp.readlines()
fp.close()
os.remove(fname)
return sym_do(commands)
except IOError:
return True
def sym_loop():
keep_running = True
while keep_running == True:
keep_running = sym_run()
if keep_running == True:
time.sleep(5)
if __name__ == '__main__':
sym = Process(target=sym_loop)
# sym.daemon = True
sym.start()