Add script to import from local directory, use local python from env

This commit is contained in:
Raphaël Vinot 2016-02-04 15:22:51 +01:00
parent 85f372c36a
commit 12aca6b760
13 changed files with 38 additions and 12 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """
The ZMQ_PubSub_Categ Module The ZMQ_PubSub_Categ Module

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
import pprint import pprint
import time import time

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """
The ZMQ_Feed_Q Module The ZMQ_Feed_Q Module

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
import redis import redis

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """
The ZMQ_Sub_Onion Module The ZMQ_Sub_Onion Module

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" """
The ZMQ_PubSub_Lines Module The ZMQ_PubSub_Lines Module

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
import redis import redis
import pprint import pprint

26
bin/import_dir.py Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import zmq
import base64
import argparse
import os
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Take files from a directory and push them into a 0MQ feed.')
parser.add_argument('-d', '--directory', type=str, required=True, help='Root directory to import')
parser.add_argument('-p', '--port', type=int, default=5556, help='Zero MQ port')
parser.add_argument('-c', '--channel', type=str, default='102', help='Zero MQ channel')
args = parser.parse_args()
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:{}".format(args.port))
for dirname, dirnames, filenames in os.walk(args.directory):
for filename in filenames:
messagedata = open(os.path.join(dirname, filename)).read()
print(os.path.join(dirname, filename))
socket.send('{} {} {}'.format(args.channel, filename, base64.b64encode(messagedata)))

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*