Commit 35d6a80a by Belákovics Ádám

runtime py2to3

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