From 4cfe71bee3d26432cd7b7919e4c5f4ef2dc63585 Mon Sep 17 00:00:00 2001 From: novak_i Date: Sun, 1 Mar 2020 15:04:47 -0500 Subject: [PATCH] Update readme file --- Readme.md | 44 ++++++++++++++- examples/menus2/menu_5.json | 107 ++++++++++++++++++++++++++++++------ src/protect.py | 1 - 3 files changed, 130 insertions(+), 22 deletions(-) diff --git a/Readme.md b/Readme.md index 48ae598..6f88658 100644 --- a/Readme.md +++ b/Readme.md @@ -40,8 +40,39 @@ optional arguments: _Note:_ `--position` - 0 0 is on the top left, -1 -1 is on the lower right. +Password can be added to JSON configuration file(s) as follows: +```bash +pylauncher-protect +``` +Password can be added in the same call using the option + +* `-p (--password) ` + +If not, the user will be prompted to enter it. +Password can be added to all the configuration file referenced within configuration file and any files referenced in the referenced file and so on using the option + +* `-r (--recursive) ` + +For all available options and detailed help run + +```bash +~$ pylauncher -h +usage: pylauncher-protect [-h] [--password PASSWORD] [--recursive] configuration +Example: pylauncher-protect -r menus/menu.json -p ***** + +positional arguments: + configuration menu/configuration file + +optional arguments: + -h, --help show this help message and exit + --password PASSWORD, -p PASSWORD + password to be added to json file, if not provided + user is prompted to enter it + --recursive, -r add recursively to all files referenced in json + + ## Configuration -Launcher menus are defined via JSON configuration file(s). On top level, the configuration of the menu is divided in the following 3 sections: +Launcher menus are defined via JSON configuration file(s). On top level, the configuration of the menu is divided in the following 4 sections: * __menu-title__ - An optional section to set the menu title. If no title is specified a file name is used instead. @@ -78,8 +109,13 @@ Launcher menus are defined via JSON configuration file(s). On top level, the con } ] ``` +* __password__ - Hash of a password guarding a section of menu and all submenus. Main section to define launcher items. The type of each item is defined with the `type` property. All supported types with available parameters are described in the next section. -An detailed example can be found at [examples/menus/menu_example.json](examples/menus/menu_example.json). +```json +"password": "5f4dcc3b5aa765d61d8327deb882cf99" +``` + +A detailed example can be found at [examples/menus/menu_example.json](examples/menus/menu_example.json). ### Menu Items @@ -91,7 +127,7 @@ For any menu item the two optional parameters __help_link__ and __tip__ can be s #### Styles -The appearance of a menu item can be customized via styles and themes. Therefore each menu item has following 2 optional paramters: +The appearance of a menu item can be customized via styles and themes. Therefore each menu item has following 2 optional parameters: * __style__ - Enables very flexible customization with [QSS](http://doc.qt.io/qt-4.8/stylesheet-syntax.html) syntax * __theme__ - Enables customization using one of the predefined themes. How to define a theme is described in section [Stylesheet](#stylesheet). However we strongly discourage the use of theme on a per menu item basis. @@ -295,6 +331,7 @@ LauncherDetachButton{ } ``` + # Installation ## Anaconda Anaconda comes with all required packages for __pylauncher__. To install the package use @@ -343,3 +380,4 @@ _Note:_ To be able to build the Anaconda package you need to have the `patchelf` conda create -n build_environment python patchelf source activate build_environment ``` + diff --git a/examples/menus2/menu_5.json b/examples/menus2/menu_5.json index 9cd1110..cf1517a 100644 --- a/examples/menus2/menu_5.json +++ b/examples/menus2/menu_5.json @@ -1,24 +1,95 @@ { - "menu-title": - {"text": "F_L1","theme": "green", "style": "color: #FF3388"}, + "password": "5f4dcc3b5aa765d61d8327deb882cf99", + "menu-title": { + "text": "F_L1", + "theme": "green", + "style": "color: #FF3388" + }, "file-choice": [ - {"text": "Load F_L2", "file": "../menus/menu_2.json"} + { + "text": "Load F_L2", + "file": "../menus/menu_2.json" + } ], "menu": [ - {"type": "title", "text": "General"}, - {"type": "cmd", "text": "Who is online", "command": "xeyes", "tip": "List of currently connected users.", "help-link": "http://www.google.com"}, - {"type": "title", "text": "HighLevel Applications", "theme": "green"}, - {"type": "cmd", "text": "ScreenMonitorTool", "command": "ls", "theme": "green", "style": "color: #FF3388"}, - {"type": "cmd", "text": "QE Measurement", "command": "ls -l", "theme": "green"}, - {"type": "separator"}, - {"type": "title", "text": "Utilities", "theme": "green"}, - {"type": "cmd", "text": "Remote network access control by control room", "command": "ls"}, - {"type": "menu", "text": "Strip-tool", "file": "menu_10.json"}, - {"type": "caqtdm", "text": "CA-screen", "macros": "SYS=TEST", "panel": "screen.ui" }, - {"type": "medm", "text": "MEDM-screen", "macros": "SYS=TEST", "panel": "screen.adl" }, - {"type": "cmd", "text": "Test", "command": "pep -mc S10BC02-MBND100:I-SET"}, - {"type": "cmd", "text": "Test 2", "command": "pylauncher -h"}, - {"type": "pep", "text": "Pep type test (.prc)", "panel": "S_TEST_REMOTECTRL_GUDE_SF-CTRL-TEST01.prc"}, - {"type": "pep", "text": "Pep type test (.prc)", "param": "-mc S10BC02-MBND100:I-SET"} + { + "type": "title", + "text": "General" + }, + { + "type": "cmd", + "text": "Who is online", + "command": "xeyes", + "tip": "List of currently connected users.", + "help-link": "http://www.google.com" + }, + { + "type": "title", + "text": "HighLevel Applications", + "theme": "green" + }, + { + "type": "cmd", + "text": "ScreenMonitorTool", + "command": "ls", + "theme": "green", + "style": "color: #FF3388" + }, + { + "type": "cmd", + "text": "QE Measurement", + "command": "ls -l", + "theme": "green" + }, + { + "type": "separator" + }, + { + "type": "title", + "text": "Utilities", + "theme": "green" + }, + { + "type": "cmd", + "text": "Remote network access control by control room", + "command": "ls" + }, + { + "type": "menu", + "text": "Strip-tool", + "file": "menu_10.json" + }, + { + "type": "caqtdm", + "text": "CA-screen", + "macros": "SYS=TEST", + "panel": "screen.ui" + }, + { + "type": "medm", + "text": "MEDM-screen", + "macros": "SYS=TEST", + "panel": "screen.adl" + }, + { + "type": "cmd", + "text": "Test", + "command": "pep -mc S10BC02-MBND100:I-SET" + }, + { + "type": "cmd", + "text": "Test 2", + "command": "pylauncher -h" + }, + { + "type": "pep", + "text": "Pep type test (.prc)", + "panel": "S_TEST_REMOTECTRL_GUDE_SF-CTRL-TEST01.prc" + }, + { + "type": "pep", + "text": "Pep type test (.prc)", + "param": "-mc S10BC02-MBND100:I-SET" + } ] } \ No newline at end of file diff --git a/src/protect.py b/src/protect.py index 51e6225..ba15f9a 100755 --- a/src/protect.py +++ b/src/protect.py @@ -37,7 +37,6 @@ def processFile(filePath, password, recursive): if recursive: files = findAllFiles(data) for file in files: - print(os.path.realpath(os.path.join(dirname, file))) processFile(os.path.join(dirname, file), password, recursive) def findAllFiles(root):