Commit 24ba9dcb by Szeberényi Imre

Initial version from CIRLCE project

parents
Desktop client for CIRCLE, providing single click connection to the VMs further enhancing the ease of use.
Python based application using third party softwares.
Tested and made for:
- Debian based Linux systems. [RDP, SSH - built in console]
- Windows Vista 32/64 or newer. [RDP - windows built in, SSH - Putty]
To install the client Root rights are necessary.
The installation guide can be found at the CIRCLE running site.
The newest installation files are located at: https://circlecloud.org/client/download/
To install simply run the downloaded executable file.
# Generating .exe file
To generate the .exe file for the windows installer, you have to use the cloud.nsi script located here.
The NSIS software can execute the script. You can download it from [here](http://nsis.sourceforge.net/Main_Page).
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.
# flake8: noqa
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
try:
from _abcoll import KeysView, ValuesView, ItemsView
except ImportError:
pass
class OrderedDict(dict):
'Dictionary that remembers insertion order'
# An inherited dict maps keys to values.
# The inherited dict provides __getitem__, __len__, __contains__, and get.
# The remaining methods are order-aware.
# Big-O running times for all methods are the same as for regular dictionaries.
# The internal self.__map dictionary maps keys to links in a doubly linked list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
# Each link is stored as a list of length three: [PREV, NEXT, KEY].
def __init__(self, *args, **kwds):
'''Initialize an ordered dictionary. Signature is the same as for
regular dictionaries, but keyword arguments are not recommended
because their insertion order is arbitrary.
'''
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
self.__root
except AttributeError:
self.__root = root = [] # sentinel node
root[:] = [root, root, None]
self.__map = {}
self.__update(*args, **kwds)
def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
'od.__setitem__(i, y) <==> od[i]=y'
# Setting a new item creates a new link which goes at the end of the linked
# list, and the inherited dictionary is updated with the new key/value pair.
if key not in self:
root = self.__root
last = root[0]
last[1] = root[0] = self.__map[key] = [last, root, key]
dict_setitem(self, key, value)
def __delitem__(self, key, dict_delitem=dict.__delitem__):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
dict_delitem(self, key)
link_prev, link_next, key = self.__map.pop(key)
link_prev[1] = link_next
link_next[0] = link_prev
def __iter__(self):
'od.__iter__() <==> iter(od)'
root = self.__root
curr = root[1]
while curr is not root:
yield curr[2]
curr = curr[1]
def __reversed__(self):
'od.__reversed__() <==> reversed(od)'
root = self.__root
curr = root[0]
while curr is not root:
yield curr[2]
curr = curr[0]
def clear(self):
'od.clear() -> None. Remove all items from od.'
try:
for node in self.__map.itervalues():
del node[:]
root = self.__root
root[:] = [root, root, None]
self.__map.clear()
except AttributeError:
pass
dict.clear(self)
def popitem(self, last=True):
'''od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.
'''
if not self:
raise KeyError('dictionary is empty')
root = self.__root
if last:
link = root[0]
link_prev = link[0]
link_prev[1] = root
root[0] = link_prev
else:
link = root[1]
link_next = link[1]
root[1] = link_next
link_next[0] = root
key = link[2]
del self.__map[key]
value = dict.pop(self, key)
return key, value
# -- the following methods do not depend on the internal structure --
def keys(self):
'od.keys() -> list of keys in od'
return list(self)
def values(self):
'od.values() -> list of values in od'
return [self[key] for key in self]
def items(self):
'od.items() -> list of (key, value) pairs in od'
return [(key, self[key]) for key in self]
def iterkeys(self):
'od.iterkeys() -> an iterator over the keys in od'
return iter(self)
def itervalues(self):
'od.itervalues -> an iterator over the values in od'
for k in self:
yield self[k]
def iteritems(self):
'od.iteritems -> an iterator over the (key, value) items in od'
for k in self:
yield (k, self[k])
def update(*args, **kwds):
'''od.update(E, **F) -> None. Update od from dict/iterable E and F.
If E is a dict instance, does: for k in E: od[k] = E[k]
If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
Or if E is an iterable of items, does: for k, v in E: od[k] = v
In either case, this is followed by: for k, v in F.items(): od[k] = v
'''
if len(args) > 2:
raise TypeError('update() takes at most 2 positional '
'arguments (%d given)' % (len(args),))
elif not args:
raise TypeError('update() takes at least 1 argument (0 given)')
self = args[0]
# Make progressively weaker assumptions about "other"
other = ()
if len(args) == 2:
other = args[1]
if isinstance(other, dict):
for key in other:
self[key] = other[key]
elif hasattr(other, 'keys'):
for key in other.keys():
self[key] = other[key]
else:
for key, value in other:
self[key] = value
for key, value in kwds.items():
self[key] = value
__update = update # let subclasses override update without breaking __init__
__marker = object()
def pop(self, key, default=__marker):
'''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
'''
if key in self:
result = self[key]
del self[key]
return result
if default is self.__marker:
raise KeyError(key)
return default
def setdefault(self, key, default=None):
'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
if key in self:
return self[key]
self[key] = default
return default
def __repr__(self, _repr_running={}):
'od.__repr__() <==> repr(od)'
call_key = id(self), _get_ident()
if call_key in _repr_running:
return '...'
_repr_running[call_key] = 1
try:
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
finally:
del _repr_running[call_key]
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
inst_dict = vars(self).copy()
for k in vars(OrderedDict()):
inst_dict.pop(k, None)
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def copy(self):
'od.copy() -> a shallow copy of od'
return self.__class__(self)
@classmethod
def fromkeys(cls, iterable, value=None):
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
and values equal to v (which defaults to None).
'''
d = cls()
for key in iterable:
d[key] = value
return d
def __eq__(self, other):
'''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.
'''
if isinstance(other, OrderedDict):
return len(self)==len(other) and self.items() == other.items()
return dict.__eq__(self, other)
def __ne__(self, other):
return not self == other
# -- the following methods are only used in Python 2.7 --
def viewkeys(self):
"od.viewkeys() -> a set-like object providing a view on od's keys"
return KeysView(self)
def viewvalues(self):
"od.viewvalues() -> an object providing a view on od's values"
return ValuesView(self)
def viewitems(self):
"od.viewitems() -> a set-like object providing a view on od's items"
return ItemsView(self)
\ No newline at end of file
@echo off
:addPath pathVar /B
::
:: Safely appends the path contained within variable pathVar to the end
:: of PATH if and only if the path does not already exist within PATH.
::
:: If the case insensitive /B option is specified, then the path is
:: inserted into the front (Beginning) of PATH instead.
::
:: If the pathVar path is fully qualified, then it is logically compared
:: to each fully qualified path within PATH. The path strings are
:: considered a match if they are logically equivalent.
::
:: If the pathVar path is relative, then it is strictly compared to each
:: relative path within PATH. Case differences and double quotes are
:: ignored, but otherwise the path strings must match exactly.
::
:: Before appending the pathVar path, all double quotes are stripped, and
:: then the path is enclosed in double quotes if and only if the path
:: contains at least one semicolon.
::
:: addPath aborts with ERRORLEVEL 2 if pathVar is missing or undefined
:: or if PATH is undefined.
::
::------------------------------------------------------------------------
::
:: Error checking
if "%~1"=="" exit /b 2
if not defined %~1 exit /b 2
if not defined path exit /b 2
::
:: Determine if function was called while delayed expansion was enabled
setlocal
set "NotDelayed=!"
::
:: Prepare to safely parse PATH into individual paths
setlocal DisableDelayedExpansion
set "var=%path:"=""%"
set "var=%var:^=^^%"
set "var=%var:&=^&%"
set "var=%var:|=^|%"
set "var=%var:<=^<%"
set "var=%var:>=^>%"
set "var=%var:;=^;^;%"
set var=%var:""="%
set "var=%var:"=""Q%"
set "var=%var:;;="S"S%"
set "var=%var:^;^;=;%"
set "var=%var:""="%"
setlocal EnableDelayedExpansion
set "var=!var:"Q=!"
set "var=!var:"S"S=";"!"
::
:: Remove quotes from pathVar and abort if it becomes empty
set "new=!%~1:"^=!"
if not defined new exit /b 2
::
:: Determine if pathVar is fully qualified
echo("!new!"|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& set "abs=1" || set "abs=0"
::
:: For each path in PATH, check if path is fully qualified and then
:: do proper comparison with pathVar. Exit if a match is found.
:: Delayed expansion must be disabled when expanding FOR variables
:: just in case the value contains !
for %%A in ("!new!\") do for %%B in ("!var!") do (
if "!!"=="" setlocal disableDelayedExpansion
for %%C in ("%%~B\") do (
echo(%%B|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& (if %abs%==1 if /i "%%~sA"=="%%~sC" exit /b 0) ^
|| (if %abs%==0 if /i %%A==%%C exit /b 0)
)
)
::
:: Build the modified PATH, enclosing the added path in quotes
:: only if it contains ;
setlocal enableDelayedExpansion
if "!new:;=!" neq "!new!" set new="!new!"
if /i "%~2"=="/B" (set "rtn=!new!;!path!") else set "rtn=!path!;!new!"
::
:: rtn now contains the modified PATH. We need to safely pass the
:: value accross the ENDLOCAL barrier
::
:: Make rtn safe for assignment using normal expansion by replacing
:: % and " with not yet defined FOR variables
set "rtn=!rtn:%%=%%A!"
set "rtn=!rtn:"=%%B!"
::
:: Escape ^ and ! if function was called while delayed expansion was enabled.
:: The trailing ! in the second assignment is critical and must not be removed.
if not defined NotDelayed set "rtn=!rtn:^=^^^^!"
if not defined NotDelayed set "rtn=%rtn:!=^^^!%" !
::
:: Pass the rtn value accross the ENDLOCAL barrier using FOR variables to
:: restore the % and " characters. Again the trailing ! is critical.
for /f "usebackq tokens=1,2" %%A in ('%%^ ^"') do (
endlocal & endlocal & endlocal & endlocal & endlocal
set "path=%rtn%" !
)
exit /b 0
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main program of the Client written for CIRCLE Cloud.
The Client job is to help the ease of use of the cloud system.
"""
import argparse
import logging
import platform
import tempfile
from time import gmtime, strftime
class Struct:
"""
A struct used for parameter passing
Keyword arguments:
state -- State of the Virtual Computer (running, etc..)
protocol -- SSH and RDP possible
host -- Address of the Virtual Computer
port -- The port where we can access the Virtual Computer
user -- Username used for the connection
password -- Password used for the connection
"""
pass
def parse_arguments():
"""
Argument parser, based on the argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"uri", type=str, help="Specific schema handler", nargs='?',
default=None)
parser.add_argument(
"-l", "--loglevel",
help="The level of logging severity", type=str,
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
default="INFO")
parser.add_argument(
"-f", "--logfile",
help="Explicit location of the wanted logfile location and name",
type=str,
default=("%(directory)s\\%(file)s" % {
'directory': tempfile.gettempdir(),
'file': 'circle_client.log'}))
args = parser.parse_args()
return args
def main():
"""
Main program
"""
args = parse_arguments()
logging.basicConfig(filename='%s' % args.logfile,
format='%(levelname)s:%(message)s')
logger = logging.getLogger()
logger.setLevel(args.loglevel)
logger.info("----------------------------")
logger.info("Client started running at %s",
strftime("%Y-%d-%m %H:%M:%S GMT", gmtime()))
try:
if args.uri is not None:
vm = Struct()
x, vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':', 5)
logger.info(("Received the following URI: %(handler)s:"
"%(protocol)s:%(user)s:password:%(host)s:%(port)s" % {
'handler': x,
'protocol': vm.protocol,
'user': vm.user,
'host': vm.host,
'port': vm.port
}))
vm.protocol = vm.protocol.upper()
logger.debug("The Client split it followingly: protocol -> %s | "
"user -> %s | password -> %s | "
"host -> %s | port -> %s",
vm.protocol, vm.user, vm.password, vm.host, vm.port)
else:
logger.critical("Client did not receive an URI which would be "
"necessary to continue")
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!")
if __name__ == "__main__":
main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Configuration of the Windows specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs.
"""
import binascii
import glob
import locale
import logging
import os
import subprocess
import time
import tempfile
import win32crypt
def connect(vm):
"""
Handles to connection to the Virtual Machines from the local
machine
Keyword arguments:
vm.protocol -- SSH and RDP possible
vm.host -- Address of the Virtual Computer
vm.port -- The port where we can access the Virtual Computer
vm.user -- Username used for the connection
vm.password -- Password used for the connection
"""
logger = logging.getLogger()
logger.debug('Connect methods started')
if vm.protocol == "SSH":
logger.info('SSH protocol received')
arguments = str("-ssh -P %(port)s -pw %(password)s"
" %(user)s@%(host)s" % {
'port': vm.port,
'password': vm.password,
'user': vm.user,
'host': vm.host})
directory = os.path.dirname(os.path.abspath(__file__))
logger.info('Popen: "%s\\putty.exe"', directory)
logger.debug('Determined arguments: %s', arguments)
subprocess.Popen('"%(path)s\\putty.exe" %(arguments)s' % {
'path': directory,
'arguments': arguments}, shell=True)
elif vm.protocol == "RDP":
logger.debug('RDP protocol received')
full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user
config_file = "%s%s" % (
tempfile.gettempdir(),
"\\circle_" + vm.user + str(int(time.time() * 1000)) + ".rdp")
logger.info('Creating config file %s' % config_file)
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([config_file], shell=True).wait()
os.remove(config_file)
logger.info('Client finished working')
RPD_template = """username:s:{}
full address:s:{}:{}
authentication level:i:0
password 51:b:{}"""
@echo off
:inPath pathVar
::
:: Tests if the path stored within variable pathVar exists within PATH.
::
:: The result is returned as the ERRORLEVEL:
:: 0 if the pathVar path is found in PATH.
:: 1 if the pathVar path is not found in PATH.
:: 2 if pathVar is missing or undefined or if PATH is undefined.
::
:: If the pathVar path is fully qualified, then it is logically compared
:: to each fully qualified path within PATH. The path strings don't have
:: to match exactly, they just need to be logically equivalent.
::
:: If the pathVar path is relative, then it is strictly compared to each
:: relative path within PATH. Case differences and double quotes are
:: ignored, but otherwise the path strings must match exactly.
::
::------------------------------------------------------------------------
::
:: Error checking
if "%~1"=="" exit /b 2
if not defined %~1 exit /b 2
if not defined path exit /b 2
::
:: Prepare to safely parse PATH into individual paths
setlocal DisableDelayedExpansion
set "var=%path:"=""%"
set "var=%var:^=^^%"
set "var=%var:&=^&%"
set "var=%var:|=^|%"
set "var=%var:<=^<%"
set "var=%var:>=^>%"
set "var=%var:;=^;^;%"
set var=%var:""="%
set "var=%var:"=""Q%"
set "var=%var:;;="S"S%"
set "var=%var:^;^;=;%"
set "var=%var:""="%"
setlocal EnableDelayedExpansion
set "var=!var:"Q=!"
set "var=!var:"S"S=";"!"
::
:: Remove quotes from pathVar and abort if it becomes empty
set "new=!%~1:"=!"
if not defined new exit /b 2
::
:: Determine if pathVar is fully qualified
echo("!new!"|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& set "abs=1" || set "abs=0"
::
:: For each path in PATH, check if path is fully qualified and then do
:: proper comparison with pathVar.
:: Exit with ERRORLEVEL 0 if a match is found.
:: Delayed expansion must be disabled when expanding FOR variables
:: just in case the value contains !
for %%A in ("!new!\") do for %%B in ("!var!") do (
if "!!"=="" endlocal
for %%C in ("%%~B\") do (
echo(%%B|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& (if %abs%==1 if /i "%%~sA"=="%%~sC" exit /b 0) ^
|| (if %abs%==0 if /i "%%~A"=="%%~C" exit /b 0)
)
)
:: No match was found so exit with ERRORLEVEL 1
exit /b 1
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Pywin32 installer for CIRCLE client application
"""
import os
import sys
import subprocess
import windowsclasses
import argparse
if windowsclasses.DecideArchitecture.Is64Windows():
default_mode = '64'
else:
default_mode = '32'
def parse_arguments():
"""
Argument parser, based on argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-m", "--mode",
help="Python running mode (32bit or 64bit)", type=str,
required=True, choices=['32', '64'], default=default_mode)
args = parser.parse_args()
return args
def main():
"""
Main program
Job:
Install Pywin32 to the computer
"""
args = parse_arguments()
if args.mode != default_mode:
change_architect = True
else:
change_architect = False
if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen(
"%s\\install.cmd" % os.path.dirname(
os.path.realpath(__file__)))
sys.exit(1)
else:
pywin32_version = str(219)
if sys.hexversion < 0x02070000:
if (windowsclasses.DecideArchitecture.Is64Windows()
and not change_architect):
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
subprocess.Popen(
"%s\\x86\\pywin32-%s.win32-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
elif sys.hexversion < 0x02080000:
if (windowsclasses.DecideArchitecture.Is64Windows()
and not change_architect):
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
subprocess.Popen(
"%s\\x86\\pywin32-%s.win32-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
print "Unsupported Python version is found!"
if __name__ == "__main__":
main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Windows installer for CIRCLE client application
"""
import os
import argparse
import subprocess
import pythoncom
import shutil
import sys
from win32com.shell import shell, shellcon
import windowsclasses
try:
from collections import * # noqa
except ImportError:
from OrderedDict import * # noqa
def parse_arguments():
"""
Argument parser, based on argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+ "\\CIRCLE\\")
else:
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32()
+ "\\CIRCLE\\")
if (not os.path.exists(local_default[:-1]) and
os.path.exists(os.environ['APPDATA'] + "\\CIRCLE")):
local_default = os.environ['APPDATA'] + "\\CIRCLE\\"
parser.add_argument(
"-l", "--location", help="Location of the client files in the system",
type=unicode, default=local_default, required=False)
parser.add_argument(
"-r", "--remove",
help="Remove installed files instead of creating them",
action="store_true", required=False)
parser.add_argument(
"-n", "--nx",
help="Whether we want to install the NX Client or not",
action="store_true", required=False)
parser.add_argument(
"-t", "--target",
help="If this is an URL icon, where should it point",
type=unicode, default="https://cloud.bme.hu/", required=False)
args = parser.parse_args()
return args
def custom_protocol_register(custom_protocol):
"""
Custom protocol register based on RegistryHandler module
Can raise AttributeError on wrongly provided dictionary chain
Keyword arguments:
@param dict_chain -- OrderedDictionary chain of the registry tree
"""
if not isinstance(custom_protocol, OrderedDict):
raise AttributeError
print "\t" + custom_protocol.iterkeys().next()
try:
custom_arguments = windowsclasses.Struct()
custom_arguments.registry = "HKCR"
handler = windowsclasses.RegistryHandler(custom_arguments)
handler.create_registry_from_dict_chain(custom_protocol, True)
print "\t\tDone!"
except:
raise
def main():
try:
args = parse_arguments()
shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove:
location = os.path.join(desktop_path, "CIRCLE Client")
if os.path.isfile("%s%s" % (location, ".lnk")):
os.remove("%s%s" % (location, ".lnk"))
print "%s%s file successfully removed" % (location, ".lnk")
if os.path.isfile("%s%s" % (location, ".url")):
os.remove("%s%s" % (location, ".url"))
print "%s%s file successfully removed" % (location, ".url")
for subdir, dirs, files in os.walk(args.location):
for current_file in files:
path = os.path.join(subdir, current_file)
fileName, fileExtension = os.path.splitext(path)
if ((fileExtension == '.pyc' or
fileExtension == '.lnk' or
fileExtension == '.url' or
fileExtension == '.log') and
"windowsclasses" not in fileName and
"uninstall" not in fileName):
os.remove(path)
print "%s file successfully removed" % path
else:
print "Creating custom URL protocol handler"
try:
custom_protocol = OrderedDict([
('circle', ["default",
"URL:circle Protocol",
"URL Protocol",
""]),
('circle\\URL Protocol', ""),
('circle\\DefaultIcon', args.location + "cloud.ico"),
('circle\\shell', {'open': {
'command': (
"\"%(prefix)s\pythonw.exe\""
" \"%(location)s"
"cloud.py\" " % {
'prefix': sys.exec_prefix,
'location': args.location
} + r'"%1"')
}})
])
custom_protocol_register(custom_protocol)
except:
print "Error! URL Protocol handler installation aborted!"
print "Creating icon in the installation folder"
location = os.path.join(desktop_path, "CIRCLE Client.url")
shortcut = open(location, "w")
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL=' + args.target)
shortcut.close()
shutil.copy(location, args.location)
print "Icon successfully created"
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
@echo off
cls
setLocal EnableDelayedExpansion
rem Set where this file will install the rest of the files
IF NOT "%1"=="" (
SET "location=%1"
SET install_location=!location:"=!
) else (
SET "install_location=%APPDATA%\CIRCLE"
)
rem Set whether we want output info on screen or not
IF NOT "%2"=="" (
SET "output_on_screen=%2"
) else (
SET "output_on_screen=True"
)
rem Starting the uninstall script
IF NOT "!output_on_screen!"=="False" (
@echo Starting CIRCLE Client uninstall script>CON
@echo.>CON
)
@echo Starting CIRCLE Client uninstall script
@echo.
rem Get the running directory for later ease of use
SET running_directory=%~dp0
rem Check the install location whether it exists
if not exist "%install_location%\" (
IF NOT "!output_on_screen!"=="False" (
@echo Installation direcory not found^^! Please delete ^'CIRCLE^' direcory manually>CON
pause
)
@echo Installation direcory not found^^! Please delete ^'CIRCLE^' direcory manually 1>&2
goto end
)
IF NOT "!output_on_screen!"=="False" (
@echo Installation direcory found at ^'%install_location%^'>CON
)
@echo Installation direcory found at ^'%install_location%^'
rem Delete files and directory
IF NOT "!output_on_screen!"=="False" (
@echo Removing desktop icon>CON
)
@echo Removing desktop icon
call python "%install_location%\win_install.py" ^-r ^-l "%install_location%\\"
IF NOT "!output_on_screen!"=="False" (
@echo Done>CON
)
@echo Done
:end
\ No newline at end of file
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