Commit 35d6a80a by Belákovics Ádám

runtime py2to3

parent 8ac7e289
......@@ -12,9 +12,6 @@ import platform
import tempfile
from time import gmtime, strftime
from windowsclasses import ClientRegistry
class Struct:
"""
A struct used for parameter passing
......@@ -39,7 +36,7 @@ def parse_arguments():
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"uri", type=unicode, help="Specific schema handler", nargs='?',
"uri", type=str, help="Specific schema handler", nargs='?',
default=None)
parser.add_argument(
"-l", "--loglevel",
......@@ -49,7 +46,7 @@ def parse_arguments():
parser.add_argument(
"-f", "--logfile",
help="Explicit location of the wanted logfile location and name",
type=unicode,
type=str,
default=("%(directory)s\\%(file)s" % {
'directory': tempfile.gettempdir(),
'file': 'circle_client.log'}))
......@@ -91,17 +88,14 @@ def main():
else:
logger.critical("Client did not receive an URI which would be "
"necessary to continue")
if platform.system() == "Linux":
logger.debug('Linux OS found, proceeding to connect methods')
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
if platform.system() == "Windows":
logger.debug('Windows OS found, proceeding to connect methods')
from cloud_connect_from_windows import connect
connect(vm)
except:
logger.exception("An exception was raised before connect methods"
"could be invoked")
print "Unknown error occurred! Please contact the developers!"
print("Unknown error occurred! Please contact the developers!")
if __name__ == "__main__":
......
......@@ -17,8 +17,6 @@ import time
import tempfile
import win32crypt
from windowsclasses import ClientRegistry
def connect(vm):
"""
......@@ -56,20 +54,17 @@ def connect(vm):
tempfile.gettempdir(),
"\\circle_" + vm.user + str(int(time.time() * 1000)) + ".rdp")
logger.info('Creating config file %s' % config_file)
password = binascii.hexlify(win32crypt.CryptProtectData(
u"%s" % vm.password, u'psw', None, None, None, 0))
config = RPD_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
password = win32crypt.CryptProtectData(vm.password.encode('utf-16-le'), 'psw', None, None, None, 0).hex()
config = RPD_template.format(vm.user, vm.host, vm.port, password)
f = open(config_file, 'w')
f.write(config)
f.close()
logger.debug('Popen the config file: %s', config_file)
subprocess.Popen((u'"%s"' % config_file).encode(
locale.getpreferredencoding()), shell=True).wait()
subprocess.Popen([config_file], shell=True).wait()
os.remove(config_file)
logger.info('Client finished working')
RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s
RPD_template = """username:s:{}
full address:s:{}:{}
authentication level:i:0
password 51:b:%(PASSWORD)s"""
password 51:b:{}"""
......@@ -185,7 +185,7 @@ class RegistryHandler:
needed_rights | architect)
SetValueEx(new_key, None, 0, REG_SZ, value)
else:
print "The provided attribute wasn't a dictionary chain"
print("The provided attribute wasn't a dictionary chain")
raise AttributeError
def get_key(self, key_name, needed_rights=KEY_ALL_ACCESS):
......
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