Created
August 27, 2015 12:08
-
-
Save mebjas/cf5b6f3ffa9bd33a95a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import time | |
import json | |
import inspect | |
import random | |
import string | |
def getRandStr(len): | |
return ''.join(random.SystemRandom().choice( | |
string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in range(len)) | |
randStr = "qwerty122" +getRandStr(5) | |
o_pipename = "../tmp/pipe" | |
i_pipename = "../tmp/" + randStr | |
outfifo = open(o_pipename, 'w+') | |
currentdir = os.path.dirname( | |
os.path.abspath(inspect.getfile(inspect.currentframe()))) | |
parentdir = os.path.dirname(currentdir) | |
command = randStr + " create /Users/minhazav/github/vagrant-pyd/test/sample " | |
print command + " sending to daemon" | |
outfifo.write(command) | |
outfifo.close() | |
print command + " sent to daemon" | |
# Now listen to a specific pipe | |
if not os.path.exists(i_pipename): | |
os.mkfifo(i_pipename) | |
print command + " reading from daemon" | |
i_fifo = open(i_pipename, 'r') | |
while True: | |
line = i_fifo.readline()[:-1] | |
if line: | |
data = json.loads(line) | |
print data | |
os.unlink(i_pipename) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment