Commit 35b09df8 by Csók Tamás

client: windows connect method logging added

parent 5c4911f7
......@@ -14,6 +14,7 @@ import glob
import win32crypt
import binascii
import nxkey
import logging
def connect(vm):
......@@ -28,7 +29,10 @@ def connect(vm):
vm.user -- Username used for the connection
vm.password -- Password used for the connection
"""
logger = logging.getLogger()
logger.info('Connect methods started')
if vm.protocol == "SSH":
logger.debug('SSH protocol received')
arguments = ("-ssh -P %(port)s -pw %(password)s"
" %(user)s@%(host)s" % {
'port': vm.port,
......@@ -36,10 +40,13 @@ def connect(vm):
'user': vm.user,
'host': vm.host})
directory = os.path.dirname(os.path.abspath(__file__))
logger.debug('Popen: %s\\putty.exe', directory)
logger.info('Determined arguments: %s', arguments)
subprocess.Popen("%(path)s\\putty.exe %(arguments)s" % {
'path': directory,
'arguments': arguments}, shell=True)
elif vm.protocol == "NX":
logger.debug('NX protocol received')
listdir = os.path.expanduser("~\\.nx\\config\\*.nxs")
found = False
server = "\"Server host\" value=\"%s\"" % vm.host
......@@ -49,8 +56,10 @@ def connect(vm):
file = f.read()
if server in file and port in file:
found = True
logger.info('Config file found: %s', config_file)
break
if not found:
logger.info('No config file found, creating new one')
config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"),
str(int(time.time() * 1000)), ".nxs")
password = nxkey.NXKeyGen(vm.password).getEncrypted()
......@@ -59,8 +68,11 @@ def connect(vm):
f = open(config_file, 'w')
f.write(config)
f.close()
logger.info('Config file created: %s', config_file)
logger.debug('Popen the config file: %s', config_file)
subprocess.Popen(config_file, shell=True)
elif vm.protocol == "RDP":
logger.debug('NX protocol received')
listdir = os.path.dirname(os.path.realpath(__file__)) + "\\.rdp\\*.rdp"
found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port)
......@@ -70,8 +82,10 @@ def connect(vm):
file = f.read()
if full_address in file and user in file:
found = True
logger.info('Config file found: %s', config_file)
break
if not found:
logger.info('No config file found, creating new one')
config_file = "%s%s%s" % ((os.path.dirname(
os.path.realpath(__file__)) + "\\.rdp\\"),
str(int(time.time() * 1000)), ".rdp")
......@@ -82,8 +96,10 @@ def connect(vm):
f = open(config_file, 'w')
f.write(config)
f.close()
logger.info('Config file created: %s', config_file)
logger.debug('Popen the config file: %s', config_file)
subprocess.Popen(config_file, shell=True)
logger.info('Client finished working')
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment