Commit 911273ea by Csók Tamás

changed Inno Setup to Nullsoft Scriptable Install System to solve compatibility issues

parent d3077f0d
A telepítéshez szükséges összes fájlt valamint a dokumentációt egy tömörített állomány tartalmazza.
1. Csomagoljuk ki az állományt egy tetszőleges helyre.
2. A következő lépésben nyissunk egy terminált és menjünk el (cd parancs) arra a mappára ahova az előbb kitömörí-tettünk.
3. Végül írjuk be: ./install.sh a konzolba.
A telepítés sikeres lefuttatásához szükség lesz majd megadni a jelszavunkat (vagy a rendszergazda jelszavát, helyi beállítástól függő-en).
A többit a szkript automatikusan végzi, amint végzett bezárhatjuk a konzolt és az asztalon megjelent ikonnal használhatjuk is a programot.
A program törlése hasonlóképpen zajlik, a kitömörített mappában adjuk ki a: ./uninstall.sh parancsot terminál segítségével (lsd. telepítés).
A szkript telepítéshez hasonló-an szintén kérni fog jelszót a törlés sikeres elvégzéséhez.
\ No newline at end of file
#!/bin/bash
sudo apt-get install sshpass python-pip remmina-plugin-nx remmina-plugin-rdp xdg-user-dirs
sudo pip install selenium
if [ "$(uname -m)" == 'x86_64' ]; then
sudo cp x64/remminapasswd /usr/local/bin/remminapasswd
else
sudo cp x86/remminapasswd /usr/local/bin/remminapasswd
fi
sudo chmod +x /usr/local/bin/remminapasswd
sudo cp cloud2 /usr/local/bin/
sudo chmod +x /usr/local/bin/cloud2
sudo cp cloud.py /usr/local/bin/
sudo chmod +x /usr/local/bin/cloud.py
sudo cp cloud_connect_from_linux.py /usr/local/bin/
sudo chmod +x /usr/local/bin/cloud_connect_from_linux.py
sudo cp cloud.svg /usr/share/icons/
sudo cp cloud.desktop /usr/share/applications
sudo chmod +x /usr/share/applications/cloud.desktop
sudo update-desktop-database
cp cloud.desktop $(xdg-user-dir DESKTOP)
chmod +x $(xdg-user-dir DESKTOP)/cloud.desktop
remmina
\ No newline at end of file
#!/bin/bash
sudo rm -f /usr/local/bin/remminapasswd
sudo rm -f /usr/local/bin/cloud2
sudo rm -f /usr/local/bin/cloud.py
sudo rm -f /usr/local/bin/cloud_connect_from_linux.py
sudo rm -f /usr/share/icons/cloud.svg
rm -f $(xdg-user-dir DESKTOP)/cloud.desktop
\ No newline at end of file
#!/bin/bash
sudo rm -f /usr/local/bin/remminapasswd
sudo rm -f /usr/local/bin/cloud2
sudo rm -f /usr/local/bin/cloud.py
sudo rm -f /usr/local/bin/cloud_connect_from_linux.py
sudo rm -f /usr/share/icons/cloud.svg
rm -f $(xdg-user-dir DESKTOP)/cloud.desktop
\ No newline at end of file
# fordításhoz szükséges: libglib2.0-dev, libgtk2.0-dev, libgcrypt11-dev
gcc -DHAVE_LIBGCRYPT -o remminapasswd remmina_passwd.c remmina_crypt.c remmina_pref.c remmina_string_array.c -Wall `pkg-config --libs --cflags gtk+-2.0` `libgcrypt-config --cflags --libs`
/*
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2009 - Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
#endif
#include "remmina_pref.h"
#include "remmina_crypt.h"
#ifdef HAVE_LIBGCRYPT
static gboolean remmina_crypt_init(gcry_cipher_hd_t *phd)
{
guchar* secret;
gcry_error_t err;
gsize secret_len;
secret = g_base64_decode(remmina_pref.secret, &secret_len);
if (secret_len < 32)
{
g_print("secret corrupted\n");
g_free(secret);
return FALSE;
}
err = gcry_cipher_open(phd, GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC, 0);
if (err)
{
g_print("gcry_cipher_open failure: %s\n", gcry_strerror(err));
g_free(secret);
return FALSE;
}
err = gcry_cipher_setkey((*phd), secret, 24);
if (err)
{
g_print("gcry_cipher_setkey failure: %s\n", gcry_strerror(err));
g_free(secret);
gcry_cipher_close((*phd));
return FALSE;
}
err = gcry_cipher_setiv((*phd), secret + 24, 8);
if (err)
{
g_print("gcry_cipher_setiv failure: %s\n", gcry_strerror(err));
g_free(secret);
gcry_cipher_close((*phd));
return FALSE;
}
g_free(secret);
return TRUE;
}
gchar* remmina_crypt_encrypt(const gchar *str)
{
guchar* buf;
gint buf_len;
gchar* result;
gcry_error_t err;
gcry_cipher_hd_t hd;
if (!str || str[0] == '\0')
return NULL;
if (!remmina_crypt_init(&hd))
return NULL;
buf_len = strlen(str);
/* Pack to 64bit block size, and make sure it's always 0-terminated */
buf_len += 8 - buf_len % 8;
buf = (guchar*) g_malloc(buf_len);
memset(buf, 0, buf_len);
memcpy(buf, str, strlen(str));
err = gcry_cipher_encrypt(hd, buf, buf_len, NULL, 0);
if (err)
{
g_print("gcry_cipher_encrypt failure: %s\n", gcry_strerror(err));
g_free(buf);
gcry_cipher_close(hd);
return NULL;
}
result = g_base64_encode(buf, buf_len);
g_free(buf);
gcry_cipher_close(hd);
return result;
}
gchar* remmina_crypt_decrypt(const gchar *str)
{
guchar* buf;
gsize buf_len;
gcry_error_t err;
gcry_cipher_hd_t hd;
if (!str || str[0] == '\0')
return NULL;
if (!remmina_crypt_init(&hd))
return NULL;
buf = g_base64_decode(str, &buf_len);
err = gcry_cipher_decrypt(hd, buf, buf_len, NULL, 0);
if (err)
{
g_print("gcry_cipher_decrypt failure: %s\n", gcry_strerror(err));
g_free(buf);
gcry_cipher_close(hd);
return NULL;
}
gcry_cipher_close(hd);
/* Just in case */
buf[buf_len - 1] = '\0';
return (gchar*) buf;
}
#else
gchar* remmina_crypt_encrypt(const gchar *str)
{
return NULL;
}
gchar* remmina_crypt_decrypt(const gchar *str)
{
return NULL;
}
#endif
/*
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2009 - Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __REMMINACRYPT_H__
#define __REMMINACRYPT_H__
G_BEGIN_DECLS
gchar* remmina_crypt_encrypt(const gchar* str);
gchar* remmina_crypt_decrypt(const gchar* str);
G_END_DECLS
#endif /* __REMMINACRYPT_H__ */
#include <glib/gprintf.h>
#include "remmina_pref.h"
#include "remmina_crypt.h"
int main(int argc, char **argv)
{
if (argc == 2) {
remmina_pref_init();
g_printf("%s", remmina_crypt_encrypt(argv[1]));
return 0;
} else {
/* No (or too many) parameter(s) given, exit with code 1 to signal error */
return 1;
}
}
/*
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2009-2011 Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __REMMINAPREF_H__
#define __REMMINAPREF_H__
/*
* Remmina Perference Loader
*/
G_BEGIN_DECLS
enum
{
REMMINA_VIEW_FILE_LIST,
REMMINA_VIEW_FILE_TREE
};
enum
{
REMMINA_ACTION_CONNECT = 0,
REMMINA_ACTION_EDIT = 1
};
enum
{
AUTO_MODE = 0,
SCROLLED_WINDOW_MODE = 1,
FULLSCREEN_MODE = 2,
SCROLLED_FULLSCREEN_MODE = 3,
VIEWPORT_FULLSCREEN_MODE = 4
};
enum
{
REMMINA_TAB_BY_GROUP = 0,
REMMINA_TAB_BY_PROTOCOL = 1,
REMMINA_TAB_ALL = 8,
REMMINA_TAB_NONE = 9
};
typedef struct _RemminaPref
{
/* In RemminaPrefDialog */
gboolean save_view_mode;
gboolean save_when_connect;
gboolean invisible_toolbar;
gboolean always_show_tab;
gboolean hide_connection_toolbar;
gint default_action;
gint scale_quality;
gchar *resolutions;
gint sshtunnel_port;
gint recent_maximum;
gint default_mode;
gint tab_mode;
gint auto_scroll_step;
gboolean applet_new_ontop;
gboolean applet_hide_count;
gboolean applet_enable_avahi;
gboolean disable_tray_icon;
gboolean minimize_to_tray;
guint hostkey;
guint shortcutkey_fullscreen;
guint shortcutkey_autofit;
guint shortcutkey_nexttab;
guint shortcutkey_prevtab;
guint shortcutkey_scale;
guint shortcutkey_grab;
guint shortcutkey_minimize;
guint shortcutkey_disconnect;
guint shortcutkey_toolbar;
/* In View menu */
gboolean hide_toolbar;
gboolean hide_statusbar;
gboolean show_quick_search;
gboolean small_toolbutton;
gint view_file_mode;
/* Auto */
gint main_width;
gint main_height;
gboolean main_maximize;
gint main_sort_column_id;
gint main_sort_order;
gchar *expanded_group;
gboolean toolbar_pin_down;
/* Crypto */
gchar *secret;
/* VTE */
gchar *vte_font;
gboolean vte_allow_bold_text;
gint vte_lines;
guint vte_shortcutkey_copy;
guint vte_shortcutkey_paste;
} RemminaPref;
#define DEFAULT_SSHTUNNEL_PORT 4732
#define DEFAULT_SSH_PORT 22
extern const gchar *default_resolutions;
extern gchar *remmina_pref_file;
extern RemminaPref remmina_pref;
void remmina_pref_init(void);
void remmina_pref_save(void);
void remmina_pref_add_recent(const gchar *protocol, const gchar *server);
gchar* remmina_pref_get_recent(const gchar *protocol);
void remmina_pref_clear_recent(void);
guint remmina_pref_keymap_get_keyval(const gchar *keymap, guint keyval);
gchar** remmina_pref_keymap_groups(void);
gint remmina_pref_get_scale_quality(void);
gint remmina_pref_get_sshtunnel_port(void);
void remmina_pref_set_value(const gchar *key, const gchar *value);
gchar* remmina_pref_get_value(const gchar *key);
G_END_DECLS
#endif /* __REMMINAPREF_H__ */
/*
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2009 - Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <glib.h>
#include <string.h>
#include "remmina_string_array.h"
RemminaStringArray*
remmina_string_array_new(void)
{
return g_ptr_array_new();
}
RemminaStringArray*
remmina_string_array_new_from_string(const gchar *strs)
{
RemminaStringArray *array;
gchar *buf, *ptr1, *ptr2;
array = remmina_string_array_new();
if (!strs || strs[0] == '\0')
return array;
buf = g_strdup(strs);
ptr1 = buf;
while (ptr1)
{
ptr2 = strchr(ptr1, ',');
if (ptr2)
*ptr2++ = '\0';
remmina_string_array_add(array, ptr1);
ptr1 = ptr2;
}
g_free(buf);
return array;
}
RemminaStringArray*
remmina_string_array_new_from_allocated_string(gchar *strs)
{
RemminaStringArray *array;
array = remmina_string_array_new_from_string(strs);
g_free(strs);
return array;
}
void remmina_string_array_add(RemminaStringArray* array, const gchar *str)
{
g_ptr_array_add(array, g_strdup(str));
}
gint remmina_string_array_find(RemminaStringArray* array, const gchar *str)
{
gint i;
for (i = 0; i < array->len; i++)
{
if (g_strcmp0(remmina_string_array_index(array, i), str) == 0)
return i;
}
return -1;
}
void remmina_string_array_remove_index(RemminaStringArray* array, gint i)
{
g_ptr_array_remove_index(array, i);
}
void remmina_string_array_remove(RemminaStringArray* array, const gchar *str)
{
gint i;
i = remmina_string_array_find(array, str);
if (i >= 0)
{
remmina_string_array_remove_index(array, i);
}
}
void remmina_string_array_intersect(RemminaStringArray* array, const gchar *dest_strs)
{
RemminaStringArray *dest_array;
gint i, j;
dest_array = remmina_string_array_new_from_string(dest_strs);
i = 0;
while (i < array->len)
{
j = remmina_string_array_find(dest_array, remmina_string_array_index(array, i));
if (j < 0)
{
remmina_string_array_remove_index(array, i);
continue;
}
i++;
}
remmina_string_array_free(dest_array);
}
static gint remmina_string_array_compare_func(const gchar **a, const gchar **b)
{
return g_strcmp0(*a, *b);
}
void remmina_string_array_sort(RemminaStringArray *array)
{
g_ptr_array_sort(array, (GCompareFunc) remmina_string_array_compare_func);
}
gchar*
remmina_string_array_to_string(RemminaStringArray* array)
{
GString *gstr;
gint i;
gstr = g_string_new("");
for (i = 0; i < array->len; i++)
{
if (i > 0)
g_string_append_c(gstr, ',');
g_string_append(gstr, remmina_string_array_index(array, i));
}
return g_string_free(gstr, FALSE);
}
void remmina_string_array_free(RemminaStringArray *array)
{
g_ptr_array_foreach(array, (GFunc) g_free, NULL);
g_ptr_array_free(array, TRUE);
}
/*
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2009 - Vic Lee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __REMMINASTRINGARRAY_H__
#define __REMMINASTRINGARRAY_H__
G_BEGIN_DECLS
typedef GPtrArray RemminaStringArray;
RemminaStringArray* remmina_string_array_new(void);
#define remmina_string_array_index(array,i) (gchar*)g_ptr_array_index(array,i)
RemminaStringArray* remmina_string_array_new_from_string(const gchar *strs);
RemminaStringArray* remmina_string_array_new_from_allocated_string(gchar *strs);
void remmina_string_array_add(RemminaStringArray *array, const gchar *str);
gint remmina_string_array_find(RemminaStringArray *array, const gchar *str);
void remmina_string_array_remove_index(RemminaStringArray *array, gint i);
void remmina_string_array_remove(RemminaStringArray *array, const gchar *str);
void remmina_string_array_intersect(RemminaStringArray *array, const gchar *dest_strs);
void remmina_string_array_sort(RemminaStringArray *array);
gchar* remmina_string_array_to_string(RemminaStringArray *array);
void remmina_string_array_free(RemminaStringArray *array);
G_END_DECLS
#endif /* __REMMINASTRINGARRAY_H__ */
[Desktop Entry]
Encoding=UTF-8
Version=0.2
Type=Application
Name=Cloud GUI
Comment=Tool to use CIRCLE Cloud
Exec=cloud2 %u
Icon=/usr/share/icons/cloud.svg
Terminal=true
MimeType=x-scheme-handler/rdp;x-scheme-handler/nx;x-scheme-handler/ssh;
Categories=Utility;Application;
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "CIRCLE Client"
#define MyAppProgramInfo "Visit the CIRCLE"
#define MyAppProgram "Cloud GUI.url"
#define MyAppDir "{userappdata}\CIRCLE"
#define MyAppVersion "1.0"
#define MyAppPublisher "BME IK, IIT, VIK"
#define MyAppURL "http://cloud.bme.hu/"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{86EFCEF4-69E1-4AE5-BF33-30FE7117F45D}
ExtraDiskSpaceRequired=2097140
PrivilegesRequired=poweruser
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={localappdata}\CIRCLE
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=setup
SetupIconFile=installer\cloud.ico
UninstallIconFile=installer\cloud.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
[Files]
; "installer" folder contains every necessary files except the uninstall.bat
Source: "installer\*"; DestDir: "{tmp}"; Flags: ignoreversion recursesubdirs createallsubdirs
; "uninstaller" folder contains ONLY the uninstall.bat
Source: "uninstaller\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Code]
procedure CurPageChanged(CurPageID: Integer);
var
ErrorCode: Integer;
show_stuff: String;
install_selenium: String;
page: String;
command: String;
OldState: Boolean;
begin
show_stuff := 'True';
install_selenium := 'False';
page := 'https://cloud.bme.hu/'
command := show_stuff + ' ' + install_selenium + ' ' + AddQuotes(page)
case CurPageID of
wpFinished:
begin
if IsWin64 then
begin
OldState := EnableFsRedirection(False);
end;
try
Exec(ExpandConstant('{cmd}'), '/C '+AddQuotes(ExpandConstant('{tmp}\install.bat'))+ ' ' + command, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
finally
if IsWin64 then
begin
EnableFsRedirection(OldState);
end;
end;
end;
end;
end;
[UninstallRun]
Filename: "{app}\uninstall.bat"; Parameters: "True"; Flags: waituntilterminated runascurrentuser shellexec
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{group}\{#MyAppProgramInfo}"; Filename: "{#MyAppDir}\{#MyAppProgram}"; IconFilename: "{#MyAppDir}\cloud.ico"
@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
This source diff could not be displayed because it is too large. You can view the blob instead.
@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
;NSIS Modern User Interface
;Multilingual Cloud Installer Script
;Written by Csk Tams
;--------------------------------
;Include Modules
!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "x64.nsh"
;--------------------------------
;Defining new constants
!define Company "CIRCLE Cloud"
!define AppName "Client"
!define AppUrlName "BME CIRCLE"
!define AppUrl "http://cloud.bme.hu/"
!define AppUninstaller "Uninstall.exe"
!define IconName "cloud"
!define Show_output "True"
!define Install_selenium "False"
;--------------------------------
;General
;Properly display all languages (Installer will not work on Windows 95, 98 or ME!)
Unicode true
;Name and file
Name "${Company} ${AppName}"
OutFile "..\..\dist\CIRCLE_Client_Setup.exe"
;Disable to skip files from installing
AllowSkipFiles off
;If there are existing files stored try to overwrite it
SetOverwrite try
;Default installation folder
InstallDir "$LOCALAPPDATA\CIRCLE"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${Company} ${AppName}" ""
;Request application privileges
RequestExecutionLevel admin
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${IconName}.ico"
!define MUI_UNICON "${IconName}.ico"
;Show all languages, despite user's codepage
!define MUI_LANGDLL_ALLLANGUAGES
;--------------------------------
;Language Selection Dialog Settings
;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\${Company} ${AppName}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "gpl-3.0.txt"
!insertmacro MUI_PAGE_INSTFILES
;Done fuction to launch install.bat
!define MUI_PAGE_CUSTOMFUNCTION_PRE Done
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English" ;first language is the default language
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Macedonian"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Indonesian"
!insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Luxembourgish"
!insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Icelandic"
!insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Kurdish"
!insertmacro MUI_LANGUAGE "Irish"
!insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "Afrikaans"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Esperanto"
!insertmacro MUI_LANGUAGE "Asturian"
!insertmacro MUI_LANGUAGE "Pashto"
;!insertmacro MUI_LANGUAGE "ScotsGaelic"
!ifdef NSIS_UNICODE
!insertmacro MUI_LANGUAGE "Georgian"
!endif
;--------------------------------
;Reserve Files
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------
;Installer Sections
Section "Install Section" SecInstall
SetOutPath "$INSTDIR"
;ADD OWN FILES HERE----------------------------------------
File /r installer
File /r uninstaller
;Store installation folder
WriteRegStr HKCU "Software\${Company} ${AppName}" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\${AppUninstaller}"
;Creating ShortCuts
CreateDirectory '$SMPROGRAMS\${Company}\${AppName}'
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +3
WriteINIStr "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" "InternetShortcut" "URL" "${AppUrl}"
Goto +2
WriteINIStr "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" "InternetShortcut" "URL" "${AppUrl}"
CreateShortCut '$SMPROGRAMS\${Company}\${AppName}\Uninstall ${AppName}.lnk' '$INSTDIR\${AppUninstaller}' "" '$INSTDIR\${AppUninstaller}' 0
SectionEnd
;--------------------------------
;Installer Functions
Function .onInit
${If} ${RunningX64}
${DisableX64FSRedirection}
SetRegView 64
${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Function Done
ExecWait '"$INSTDIR\installer\install.cmd" ${Show_output} ${Install_selenium} "${AppUrl}"'
RMDir /r "$INSTDIR\installer"
FunctionEnd
;--------------------------------
;Descriptions
;USE A LANGUAGE STRING IF YOU WANT YOUR DESCRIPTIONS TO BE LANGAUGE SPECIFIC
;Assign descriptions to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +3
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstall} "A ${AppName} installlsa"
Goto +2
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstall} "Installing the ${AppName}"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
ExecWait '"$INSTDIR\uninstaller\uninstall.cmd" ${Show_output}'
Delete "$INSTDIR\${AppUninstaller}"
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +3
Delete "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url"
Goto +2
Delete "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url"
RMDir /r "$INSTDIR"
RMDir /r "$SMPROGRAMS\${Company}\${AppName}"
DeleteRegKey /ifempty HKCU "Software\${Company} ${AppName}"
SectionEnd
;--------------------------------
;Uninstaller Functions
Function un.onInit
${If} ${RunningX64}
${DisableX64FSRedirection}
SetRegView 64
${EndIf}
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
\ No newline at end of file
......@@ -18,7 +18,7 @@ IF NOT "%2"=="" (
SET "install_selenium=False"
)
rem Set which website should the icon point to
SET "website="
SET "site=^"http://cloud.bme.hu/^""
IF NOT "%3"=="" (
IF "%install_selenium%"=="False" (
SET site=%3
......@@ -39,11 +39,11 @@ if '%errorlevel%' NEQ '0' (
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo Set UAC = CreateObject^("Shell.Application"^) > ^"%temp%\getadmin.vbs^"
set vbs_site=!site:"=""!
echo UAC.ShellExecute "cmd.exe", "/c %~s0 !output_on_screen! !install_selenium! !vbs_site!", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
^"%temp%\getadmin.vbs^"
del "%temp%\getadmin.vbs"
exit /B
......@@ -97,14 +97,14 @@ IF NOT "!output_on_screen!"=="False" (
IF NOT "!output_on_screen!"=="False" (
@echo 64 bit system detected, commencing the install
)
start /WAIT %running_directory%x64^\python-2.7.7.amd64.msi
start /WAIT ^"%running_directory%x64^\python-2.7.7.amd64.msi^"
GOTO NOWHASPYTHON
)
if "!architecture!"=="32" (
IF NOT "!output_on_screen!"=="False" (
@echo 32 bit system detected, commencing the install
)
start /WAIT %running_directory%x86^\python-2.7.7.msi
start /WAIT ^"%running_directory%x86^\python-2.7.7.msi^"
GOTO NOWHASPYTHON
)
GOTO ERR
......@@ -162,38 +162,21 @@ IF NOT "!output_on_screen!"=="False" (
goto loop
) else (
set test=%install_path:~0,-1%
call %running_directory%inPath test && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call %running_directory%addPath test & setx>nul PATH "%PATH%;%test%" /m & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to PATH))
call ^"%running_directory%inPath^" ^"test^" && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call ^"%running_directory%addPath^" ^"test^" & setx>nul PATH "%PATH%;%test%" /m & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to PATH))
set test=%install_path%Scripts
call %running_directory%inPath test && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call %running_directory%addPath test & setx>nul PATH "%PATH%;%test%" /m & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to PATH))
call ^"%running_directory%inPath^" ^"test^" && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call ^"%running_directory%addPath^" ^"test^" & setx>nul PATH "%PATH%;%test%" /m & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to PATH))
)
GOTO PIP_CHECK
GOTO PIP_INSTALL
rem Check whether PIP is installed or not
:PIP_CHECK
:PIP_INSTALL
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Checking if PIP is installed
)
IF EXIST %install_path%Scripts/PIP.exe GOTO PIP_VERSION_CHECK
IF NOT "!output_on_screen!"=="False" (
@echo No PIP found, commencing PIP install
)
IF NOT "!output_on_screen!"=="False" (
call python %running_directory%get-pip.py
) else (
call python %running_directory%get-pip.py >nul 2>&1
)
rem Try to update the PIP
:PIP_VERSION_CHECK
IF NOT "!output_on_screen!"=="False" (
@echo PIP is found
@echo Checking whether the latest PIP is installed
@echo Commencing PIP reinstall to solve compatibility issues
)
IF NOT "!output_on_screen!"=="False" (
call python -m pip install --upgrade pip
CALL easy_install pip
) else (
call python -m pip install --upgrade pip >nul 2>&1
CALL easy_install pip >nul 2>&1
)
SET "pip_program=requirements.txt"
IF NOT "!output_on_screen!"=="False" (
......@@ -375,7 +358,7 @@ if "!browserToUse!"=="None" (
call :Split "%browser_path%" test
set myTest=!test:~0,-1!
rem Set that path in the PATH environment variable
call %running_directory%inPath myTest && (IF NOT "!output_on_screen!"=="False" ( @echo !myTest! is already in PATH)) || (call %running_directory%addPath myTest & setx>nul PATH "%PATH%;!myTest!" /m & IF NOT "!output_on_screen!"=="False" ( @echo !myTest! set to PATH) )
call ^"%running_directory%inPath^" ^"myTest^" && (IF NOT "!output_on_screen!"=="False" ( @echo !myTest! is already in PATH)) || (call ^"%running_directory%addPath^" ^"myTest^" & setx>nul PATH "%PATH%;!myTest!" /m & IF NOT "!output_on_screen!"=="False" ( @echo !myTest! set to PATH) )
:install_driver
IF NOT "%install_selenium%"=="False" (
if NOT "!selenium_driver_name!"=="" (
......@@ -428,12 +411,12 @@ rem Create folder if needed and set it to PATH
IF NOT "!output_on_screen!"=="False" (
@echo Checking wheter ^'%install_location%^\^' exists already
)
call %running_directory%inPath install_location && (IF NOT "!output_on_screen!"=="False" ( @echo !install_location! is already in PATH)) || (call %running_directory%addPath install_location & setx>nul PATH "%PATH%;!install_location!" /m & IF NOT "!output_on_screen!"=="False" ( @echo !install_location! set to PATH))
call ^"%running_directory%inPath^" ^"install_location^" && (IF NOT "!output_on_screen!"=="False" ( @echo !install_location! is already in PATH)) || (call ^"%running_directory%addPath^" ^"install_location^" & setx>nul PATH "%PATH%;!install_location!" /m & IF NOT "!output_on_screen!"=="False" ( @echo !install_location! set to PATH))
if not exist "%install_location%\" (
mkdir "%install_location%"
mkdir ^"%install_location%^"
)
if not exist "%install_location%\.rdp\" (
mkdir "%install_location%\.rdp"
mkdir ^"%install_location%\.rdp^"
)
rem Copy the files to the folder
IF NOT "!output_on_screen!"=="False" (
......@@ -463,9 +446,9 @@ if NOT "!browserToUse!"=="" (
SET "selenium_driver= -d !browserToUse!"
)
IF NOT "!output_on_screen!"=="False" (
call python %running_directory%win_install.py!selenium_driver! ^-l "%install_location%\\"!create_url_icon!!website!
call python ^"%running_directory%win_install.py!selenium_driver!^" ^-l "%install_location%\\"!create_url_icon!!website!
) else (
call python %running_directory%win_install.py!selenium_driver! ^-l "%install_location%\\"!create_url_icon!!website! >nul 2>&1
call python ^"%running_directory%win_install.py!selenium_driver!^" ^-l "%install_location%\\"!create_url_icon!!website! >nul 2>&1
)
IF NOT "!output_on_screen!"=="False" (
@echo Done
......
......@@ -102,7 +102,7 @@ def main():
desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove:
location = os.path.join(desktop_path, "Cloud GUI")
location = os.path.join(desktop_path, "CIRCLE Client")
if os.path.isfile("%s%s" % (location, ".lnk")):
os.remove("%s%s" % (location, ".lnk"))
if os.path.isfile("%s%s" % (location, ".url")):
......@@ -112,7 +112,7 @@ def main():
"python %s\\nx_client_installer.py" % os.path.dirname(
os.path.realpath(__file__)))
if args.url:
location = os.path.join(desktop_path, "Cloud GUI.url")
location = os.path.join(desktop_path, "CIRCLE Client.url")
shortcut = file(location, 'w')
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL='+args.target)
......@@ -131,7 +131,7 @@ def main():
0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface(
pythoncom.IID_IPersistFile)
location = os.path.join(desktop_path, "Cloud GUI.lnk")
location = os.path.join(desktop_path, "CIRCLE Client.lnk")
persist_file.Save(location, 0)
print "Icon successfully created on desktop"
shutil.copy(location, args.location)
......
# 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
#!/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 platform
import argparse
try:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
except ImportError:
pass
class Struct:
"""
A struct used for parameter passing
Keyword arguments:
state -- State of the Virtual Computer (running, etc..)
protocol -- SSH, NX 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("-u", "--username", type=str)
parser.add_argument("-p", "--password", type=str)
parser.add_argument(
"-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "
+ "first the proper driver.", type=str,
choices=['firefox', 'chrome', 'ie', 'opera'],
default="firefox")
args = parser.parse_args()
return args
class Browser:
"""
Browser initialisation
Keyword arguments:
@param args -- args.driver tells us which installed browser
we want to use with selenium.
"""
def __init__(self, args):
self.args = args
if args.driver == "firefox":
self.driver = webdriver.Firefox()
elif args.driver == "chrome":
self.driver = webdriver.Chrome()
elif args.driver == "ie":
self.driver = webdriver.Ie()
elif args.driver == "opera":
self.driver = webdriver.Opera()
self.driver.implicitly_wait(10)
def login(self):
"""
Eduid login based on the given console arguments
"""
driver = self.driver
args = self.args
if args.username is not None:
driver.find_element_by_name("j_username").clear()
driver.find_element_by_name("j_username").send_keys(args.username)
if args.password is not None:
driver.find_element_by_name("j_password").clear()
driver.find_element_by_name("j_password").send_keys(args.password)
if args.username is not None and args.password is not None:
driver.find_element_by_css_selector(
"input[type='submit']").click()
def main(self):
"""
Use of the https://cloud.bme.hu/
Keyword arguments:
@return vm -- Necessarily parameters to connect
to the Virtual Machine
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://cloud.bme.hu/")
# driver.find_element_by_css_selector("a[href*='/login/']").click()
# self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
WebDriverWait(driver, 7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"#vm-details-pw-eye.fa.fa-eye-slash")))
vm.state = driver.find_element_by_css_selector(
"#vm-details-state > span").text
# cl: connection string converted to list
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
if cl[0] == "sshpass":
vm.protocol = "SSH"
vm.user, vm.host = cl[6].split("@")
vm.password, vm.port = cl[2], cl[8]
elif cl[0] == "rdesktop":
vm.protocol = "RDP"
vm.host, vm.port = cl[1].split(":")
vm.user, vm.password = cl[3], cl[5]
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
def main():
"""
Main program
"""
try:
args = parse_arguments()
if args.uri is not None:
vm = Struct()
x, vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':', 5)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
vm = browser.main()
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
except:
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 time
import os
import subprocess
import glob
import win32crypt
import binascii
import nxkey
def connect(vm):
"""
Handles to connection to the Virtual Machines from the local
machine
Keyword arguments:
vm.protocol -- SSH, NX 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
"""
if vm.protocol == "SSH":
arguments = ("-ssh -P %s -pw %s" % (vm.port, vm.password)
+ " %s@%s" % (vm.user, vm.host))
subprocess.Popen("putty.exe "+arguments, shell=True)
elif vm.protocol == "NX":
listdir = os.path.expanduser("~\\.nx\\config\\*.nxs")
found = False
server = "\"Server host\" value=\"%s\"" % vm.host
port = "\"Server port\" value=\"%s\"" % vm.port
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if server in file and port in file:
found = True
break
if not found:
config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"),
str(int(time.time()*1000)), ".nxs")
password = nxkey.NXKeyGen(vm.password).getEncrypted()
config = NX_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
f = open(config_file, 'w')
f.write(config)
f.close()
subprocess.Popen(config_file, shell=True)
elif vm.protocol == "RDP":
listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp"
found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if full_address in file and user in file:
found = True
break
if not found:
config_file = "%s%s%s" % ((os.path.dirname(
os.path.realpath(__file__))+"\\.rdp\\"),
str(int(time.time()*1000)), ".rdp")
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}
f = open(config_file, 'w')
f.write(config)
f.close()
subprocess.Popen(config_file, shell=True)
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="General" >
<option key="Remember password" value="true" />
<option key="Resolution" value="fullscreen" />
<option key="Server host" value="%(HOST)s" />
<option key="Server port" value="%(PORT)s" />
<option key="Session" value="unix" />
</group>
<group name="Login" >
<option key="Auth" value="%(PASSWORD)s" />
<option key="Guest Mode" value="false" />
<option key="Login Method" value="nx" />
<option key="User" value="%(USERNAME)s" />
</group>
</NXClientSettings>"""
RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s
password 51:b:%(PASSWORD)s"""
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
NX Client for Windows installer
Checks whether NX Client for Windows is installed in the system, the
classes used for this process are used for other operations too.
"""
import os
import argparse
import subprocess
import time
import windowsclasses
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",
default=local_default)
args = parser.parse_args()
return args
def main():
try:
nx_install_location = None
while nx_install_location is None:
print "Checking whether NX Client for Windows is installed"
handler = windowsclasses.RegistryHandler()
try:
nx_install_location = handler.get_key_value(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
+ "Uninstall\\nxclient_is1",
"InstallLocation", "key")
print ("NX Client for Windows is found at "
"'%s'" % nx_install_location)
process = subprocess.Popen(
"%s\\nxclient.exe" % nx_install_location)
time.sleep(2)
process.terminate()
except:
print "NX Client for Windows isn't installed on the system."
print "\tCommencing the install"
subprocess.Popen(os.path.dirname(
os.path.realpath(__file__))
+ "\\nxclient-3.5.0-9.exe").wait()
except:
pass
if __name__ == "__main__":
main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Generating NoMachine NX scrambled key according to
https://www.nomachine.com/AR01C00125
"""
import sys
import random
from xml.sax.saxutils import escape
class NXKeyGen:
"""
NXKeyGen class
Creates NoMachine NX scrambled keys
"""
numValidCharList = 85
dummyString = "{{{{"
def __init__(self, password):
"""
Initialize the class
Keyword arguments:
@param password -- Password that will be scrambled
"""
self.password = password
def getEncrypted(self):
"""
Encrypt (scramble) the given password
Keyword arguments:
@return scrambleString -- Scrambled version of the original
password
"""
return self.scrambleString(self.password)
def getvalidCharList(self, pos):
"""
Valid character list
Keyword arguments:
@return validcharlist -- List of the valid characters
"""
validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}"]
return validcharlist[pos]
def encodePassword(self, p):
"""
Password encoder
Keyword arguments:
@return sPass -- Encoded password
"""
sPass = ":"
sTmp = ""
if not p:
return ""
for i in range(len(p)):
c = p[i:i+1]
a = ord(c)
sTmp = str(a + i + 1) + ":"
sPass += sTmp
sTmp = ""
return sPass
def findCharInList(self, c):
"""
Character position finder
Keyword arguments:
@param c -- Character that needs to be matched if valid
@return i -- Place where the character is in the valid list
"""
i = -1
for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j)
if randchar == c:
i = j
return i
return i
def getRandomValidCharFromList(self):
"""
Random valid character getter
Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list
"""
return self.getvalidCharList(random.randint(0, 60))
def scrambleString(self, s):
"""
Password scrambler
Keyword arguments:
@param s -- Password that needs to be scrambled
@return sRet -- NoMachine NX scrambled password
"""
sRet = ""
if not s:
return s
strp = self.encodePassword(s)
if len(strp) < 32:
sRet += self.dummyString
for iR in reversed(range(len(strp))):
sRet += strp[iR:iR+1]
if len(sRet) < 32:
sRet += self.dummyString
app = self.getRandomValidCharFromList()
k = ord(app)
l = k + len(sRet) - 2
sRet = app + sRet
for i1 in range(1, len(sRet)):
app2 = sRet[i1: i1 + 1]
j = self.findCharInList(app2)
if j == -1:
return sRet
i = (j + l * (i1 + 1)) % self.numValidCharList
car = self.getvalidCharList(i)
sRet = self.substr_replace(sRet, car, i1, 1)
c = (ord(self.getRandomValidCharFromList())) + 2
c2 = chr(c)
sRet = sRet + c2
return escape(sRet)
def substr_replace(self, in_str, ch, pos, qt):
"""
Replace a character at a special position
"""
clist = list(in_str)
count = 0
tmp_str = ''
for key in clist:
if count != pos:
tmp_str += key
else:
tmp_str += ch
count = count+1
return tmp_str
if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1])
print NXPass.password
print NXPass.getEncrypted()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Pywin32 installer for CIRCLE client application
"""
import os
import sys
import subprocess
import windowsclasses
def main():
"""
Main program
Job:
Install Pywin32 to the computer
"""
if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen(
"%s\\no_root_install.bat" % os.path.dirname(
os.path.realpath(__file__)))
sys.exit(1)
else:
pywin32_version = str(219)
if sys.hexversion < 0x02070000:
if windowsclasses.DecideArchitecture.Is64Windows():
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():
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 icon 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()
parser.add_argument(
"-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "
+ "first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome',
'iexplore', 'opera'])
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",
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(
"-u", "--url",
help="Whether we installed and we want to use selenium or not",
action="store_true", required=False)
parser.add_argument(
"-t", "--target",
help="If this is an URL icon, where should it point",
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():
"""
Main program
Jobs:
read the parameters
create a proper icon with the proper driver (or delete)
call the nx_client_installer
"""
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, "Cloud GUI")
if os.path.isfile("%s%s" % (location, ".lnk")):
os.remove("%s%s" % (location, ".lnk"))
if os.path.isfile("%s%s" % (location, ".url")):
os.remove("%s%s" % (location, ".url"))
else:
subprocess.call(
"python %s\\nx_client_installer.py" % os.path.dirname(
os.path.realpath(__file__)))
if args.url:
location = os.path.join(desktop_path, "Cloud GUI.url")
shortcut = file(location, 'w')
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL='+args.target)
shortcut.close()
else:
shortcut.SetPath(args.location+"cloud.py")
if args.driver == "chrome":
shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore":
shortcut.SetArguments("-d ie")
elif args.driver == "opera":
shortcut.SetArguments("-d opera")
shortcut.SetDescription("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation(args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface(
pythoncom.IID_IPersistFile)
location = os.path.join(desktop_path, "Cloud GUI.lnk")
persist_file.Save(location, 0)
print "Icon successfully created on desktop"
shutil.copy(location, args.location)
print "Creating custom URL protocol handlers"
try:
custom_protocol = OrderedDict([
('circle', ["default",
"URL:circle Protocol",
"URL Protocol",
""]),
('circle\\URL Protocol', ""),
('circle\\DefaultIcon', args.location+"cloud.ico"),
('circle\\shell', {'open': {
'command': r'"%s\pythonw.exe"' % sys.exec_prefix
+ r' "%s' % args.location
+ r'\cloud.py" "%1"'}})])
custom_protocol_register(custom_protocol)
except:
print "Error! URL Protocol handler installation aborted!"
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
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