2016-02-15 05:30:43 -05:00
|
|
|
#. -*- coding: utf-8
|
|
|
|
#
|
2016-02-15 05:56:20 -05:00
|
|
|
# novnc daemon spawner :)
|
2016-02-15 05:30:43 -05:00
|
|
|
|
|
|
|
#import site packages
|
|
|
|
import shlex, subprocess
|
|
|
|
|
|
|
|
|
|
|
|
def spawn(target, options):
|
|
|
|
""" spawn """
|
|
|
|
vnctarget = '{}:{} {}:{} '.format(target['listen_host'], target['listen_port'], target['target_host'], target['target_port'])
|
|
|
|
|
|
|
|
a_options = ''
|
|
|
|
for key, value in options.items():
|
|
|
|
if value == True:
|
|
|
|
c_option = '--{} '.format(key)
|
|
|
|
else:
|
|
|
|
c_option = '--{} {} '.format(key, value)
|
|
|
|
a_options += c_option
|
|
|
|
|
2016-02-15 05:53:56 -05:00
|
|
|
try:
|
2018-03-09 21:40:58 -05:00
|
|
|
command_line = 'python3 runwebsockify.py -D ' + a_options + vnctarget
|
2016-02-15 05:53:56 -05:00
|
|
|
args = shlex.split(command_line)
|
2018-03-09 21:40:58 -05:00
|
|
|
#print(str(args))
|
|
|
|
p = subprocess.Popen(args, shell=False)
|
|
|
|
print('vnc connector API:{} <--> {}:{} spawned !'.format(target['listen_port'], target['target_host'], target['target_port']))
|
|
|
|
p.wait()
|
|
|
|
print('done.')
|
2016-02-15 06:04:29 -05:00
|
|
|
except:
|
|
|
|
raise
|