Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def request_start(timestamp, targetAddr):
print('request_start')
# set addresses #
NetworkManager.prepareServerConn(None, targetAddr)
# get connection with server #
conn = NetworkManager.getServerConn()
if not conn:
print('\nFail to get connection with server')
sys.exit(0)
# request command #
pipe = NetworkManager.getCmdPipe(conn, 'GUIDER top -a -J -e dn')
if not pipe:
print('\nFail to get command pipe')
sys.exit(0)
# build message #
msg = {'timestamp': timestamp}
RequestManager.add_request(timestamp)
'''
# for multi-thread feature #
global thread
with thread_lock:
if thread is None:
thread = socketio.start_background_task(thread_task)
'''
'''
Choose one of below calls. (None: default address)
1. NetworkManager.prepareServerConn(CLIENT_IP:PORT, SERVER_IP:PORT)
2. NetworkManager.prepareServerConn(None, SERVER_IP:PORT)
3. NetworkManager.prepareServerConn(None, None)
'''
NetworkManager.prepareServerConn(None, None)
# get connection with server #
conn = NetworkManager.getServerConn()
if not conn:
print('\nFail to get connection with server')
sys.exit(0)
# request command #
pipe = NetworkManager.getCmdPipe(conn, 'GUIDER top -a -J')
if not pipe:
print('\nFail to get command pipe')
sys.exit(0)
# get data from server #
while 1:
data = pipe.getData()
if not data:
break
print(data.rstrip())
# close command pipe to terminate process on server #
pipe.close()
# run server before launch below client code #
'''
$ guider/guider.py server
'''
# set network info #
'''
Choose one of below calls. (None: default address)
1. NetworkManager.prepareServerConn(CLIENT_IP:PORT, SERVER_IP:PORT)
2. NetworkManager.prepareServerConn(None, SERVER_IP:PORT)
3. NetworkManager.prepareServerConn(None, None)
'''
NetworkManager.prepareServerConn(None, None)
# get connection with server #
conn = NetworkManager.getServerConn()
if not conn:
print('\nFail to get connection with server')
sys.exit(0)
# request command #
pipe = NetworkManager.getCmdPipe(conn, 'GUIDER top -a -J')
if not pipe:
print('\nFail to get command pipe')
sys.exit(0)
# get data from server #
while 1:
data = pipe.getData()
if not data:
break
def request_start(timestamp, targetAddr):
print('request_start')
# set addresses #
NetworkManager.prepareServerConn(None, targetAddr)
# get connection with server #
conn = NetworkManager.getServerConn()
if not conn:
print('\nFail to get connection with server')
sys.exit(0)
# request command #
pipe = NetworkManager.getCmdPipe(conn, 'GUIDER top -a -J -e dn')
if not pipe:
print('\nFail to get command pipe')
sys.exit(0)
# build message #
msg = {'timestamp': timestamp}
RequestManager.add_request(timestamp)
'''
# for multi-thread feature #
if __name__ == '__main__':
# run server before launch below client code #
'''
$ guider/guider.py server
'''
# set network info #
'''
Choose one of below calls. (None: default address)
1. NetworkManager.prepareServerConn(CLIENT_IP:PORT, SERVER_IP:PORT)
2. NetworkManager.prepareServerConn(None, SERVER_IP:PORT)
3. NetworkManager.prepareServerConn(None, None)
'''
NetworkManager.prepareServerConn(None, None)
# get connection with server #
conn = NetworkManager.getServerConn()
if not conn:
print('\nFail to get connection with server')
sys.exit(0)
# request command #
pipe = NetworkManager.getCmdPipe(conn, 'GUIDER top -a -J')
if not pipe:
print('\nFail to get command pipe')
sys.exit(0)
# get data from server #
while 1:
data = pipe.getData()
def request_start(timestamp, targetAddr):
print('request_start')
# set addresses #
NetworkManager.prepareServerConn(None, targetAddr)
# get connection with server #
conn = NetworkManager.getServerConn()
if not conn:
print('\nFail to get connection with server')
sys.exit(0)
# request command #
pipe = NetworkManager.getCmdPipe(conn, 'GUIDER top -a -J -e dn')
if not pipe:
print('\nFail to get command pipe')
sys.exit(0)
# build message #
msg = {'timestamp': timestamp}
RequestManager.add_request(timestamp)
def set_network_manager(cls, target_addr):
network_mgr = NetworkMgr(mode=None, ip=None, port=None)
network_mgr.prepareServerConn(None, target_addr)
if target_addr not in cls.instances:
cls.instances[target_addr] = network_mgr
import os
from .guider import main
# set main environment #
os.environ["ISMAIN"] = "True"
main(args=None)