Skip to content

Commit

Permalink
Fix bug with X11 in MacOS
Browse files Browse the repository at this point in the history
The issue was in the subprocess.call for 'xhost +',
where the permission granted seem to vanish somehow.
As I have done for the 'docker run' call, changed
subprocess.call for 'os.system' and voila'!
There was also a minor issue with bytearrays, the
host machine address was being printed with the "b''"
in front of the IP (only in Python3).
  • Loading branch information
Carlos Brandt committed Mar 10, 2018
1 parent 0b1ce8f commit 5ea7602
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions dockeri/x11.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,6 @@

def hostip4darwin():
ipaddr = None
# try:
# assert False
# cmdline = ["docker-machine","ip","default"]
# subprocess.call(cmdline,stdout=DEVNULL,stderr=STDOUT)
# ipaddr = subprocess.check_output(cmdline)
# ipaddr = ipaddr.strip()
# except:
# for i in range(9):
# netint = "vboxnet{}".format(i)
# cmdline = ["ifconfig",netint]
# if subprocess.call(cmdline,stdout=DEVNULL,stderr=STDOUT)!=0:
# continue
# ifout = subprocess.check_output(cmdline)
# cmdline = ["awk","{if(/inet/){print substr($2,1)}}"]
# proc = subprocess.Popen(cmdline,stdout=PIPE,stderr=PIPE,stdin=PIPE)
# out,err = proc.communicate(ifout)
# out = out.strip()
# if out is not "":
# ipaddr = out
cmdline = 'ifconfig en0'.split()
if subprocess.call(cmdline, stdout=DEVNULL, stderr=STDOUT) != 0:
return None
Expand All @@ -42,8 +23,10 @@ def hostip4darwin():
out = out.strip()
if out is not "":
ipaddr = out
ipaddr = ipaddr.decode('utf-8')
cmdline = ['xhost', '+{}'.format(ipaddr)]
proc = subprocess.call(cmdline, stdout=DEVNULL, stderr=STDOUT)
#proc = subprocess.call(cmdline, stdout=DEVNULL, stderr=STDOUT)
_= os.system(' '.join(cmdline))
return ipaddr


Expand All @@ -52,7 +35,7 @@ def x114darwin():
# proc = subprocess.Popen(cmdline.split(),stdout=PIPE,stderr=PIPE,stdin=PIPE)
#procid = proc.pid
vmip = hostip4darwin()
return '{0}:0'.format(vmip)
return '{!s}:0'.format(vmip)


def x114linux():
Expand Down

0 comments on commit 5ea7602

Please sign in to comment.