Prevent the loss of the 1 message in import_dir.py

This commit is contained in:
Mokaddem 2017-07-17 16:14:27 +02:00
parent 7c88e7d013
commit 9558aafe67
2 changed files with 3 additions and 2 deletions

View file

@ -18,10 +18,11 @@ if __name__ == "__main__":
context = zmq.Context() context = zmq.Context()
socket = context.socket(zmq.PUB) socket = context.socket(zmq.PUB)
socket.bind("tcp://*:{}".format(args.port)) socket.bind("tcp://*:{}".format(args.port))
time.sleep(1) #Important, avoid loosing the 1 message
for dirname, dirnames, filenames in os.walk(args.directory): for dirname, dirnames, filenames in os.walk(args.directory):
for filename in filenames: for filename in filenames:
messagedata = open(os.path.join(dirname, filename)).read() messagedata = open(os.path.join(dirname, filename)).read()
print(os.path.join(dirname, filename)) print(os.path.join(dirname, filename))
socket.send('{} {} {}'.format(args.channel, filename, base64.b64encode(messagedata))) socket.send('{} {} {}'.format(args.channel, filename, base64.b64encode(messagedata)))
time.sleep(.1) time.sleep(.2)

View file

@ -25,7 +25,7 @@
</ul> </ul>
</li> </li>
<li id='page-myNewModule'><a href="{{ url_for('myNewModule.myNewModule_page') }}"><i class="glyphicon glyphicon-new-window"></i> myNewModule page</a></li> <li id='page-thisisatest'><a href="{{ url_for('thisisatest.thisisatest_page') }}"><i class="glyphicon glyphicon-new-window"></i> thisisatest </a></li>
</ul> </ul>
</div> </div>