From face943d0fd9c13b3ab699f9dddf6f099cd80d48 Mon Sep 17 00:00:00 2001 From: saadkhi Date: Thu, 31 Oct 2024 01:17:12 +0500 Subject: [PATCH] Refactor code base Signed-off-by: saadkhi --- ganga-env/bin/Activate.ps1 | 247 ------------------ ganga-env/bin/activate | 69 ----- ganga-env/bin/activate.csh | 26 -- ganga-env/bin/activate.fish | 69 ----- ganga-env/bin/flake8 | 8 - ganga-env/bin/ganga | 7 - ganga-env/bin/gdown | 8 - ganga-env/bin/google-oauthlib-tool | 8 - ganga-env/bin/ipython | 8 - ganga-env/bin/ipython3 | 8 - ganga-env/bin/normalizer | 8 - ganga-env/bin/pip | 8 - ganga-env/bin/pip3 | 8 - ganga-env/bin/pip3.10 | 8 - ganga-env/bin/py.test | 8 - ganga-env/bin/pycodestyle | 8 - ganga-env/bin/pyflakes | 8 - ganga-env/bin/pygmentize | 8 - ganga-env/bin/pyrsa-decrypt | 8 - ganga-env/bin/pyrsa-encrypt | 8 - ganga-env/bin/pyrsa-keygen | 8 - ganga-env/bin/pyrsa-priv2pub | 8 - ganga-env/bin/pyrsa-sign | 8 - ganga-env/bin/pyrsa-verify | 8 - ganga-env/bin/pytest | 8 - ganga-env/bin/python | 1 - ganga-env/bin/python3 | 1 - ganga-env/bin/python3.10 | 1 - ganga-env/bin/tqdm | 8 - ganga-env/lib64 | 1 - ganga-env/pyvenv.cfg | 3 - ganga-env/share/man/man1/ipython.1 | 60 ----- .../Local_GangaMC_Service.py | 38 +-- .../test/GPI/Monitoring/TestMonitoring.py | 102 +++++--- 34 files changed, 88 insertions(+), 705 deletions(-) delete mode 100644 ganga-env/bin/Activate.ps1 delete mode 100644 ganga-env/bin/activate delete mode 100644 ganga-env/bin/activate.csh delete mode 100644 ganga-env/bin/activate.fish delete mode 100755 ganga-env/bin/flake8 delete mode 100755 ganga-env/bin/ganga delete mode 100755 ganga-env/bin/gdown delete mode 100755 ganga-env/bin/google-oauthlib-tool delete mode 100755 ganga-env/bin/ipython delete mode 100755 ganga-env/bin/ipython3 delete mode 100755 ganga-env/bin/normalizer delete mode 100755 ganga-env/bin/pip delete mode 100755 ganga-env/bin/pip3 delete mode 100755 ganga-env/bin/pip3.10 delete mode 100755 ganga-env/bin/py.test delete mode 100755 ganga-env/bin/pycodestyle delete mode 100755 ganga-env/bin/pyflakes delete mode 100755 ganga-env/bin/pygmentize delete mode 100755 ganga-env/bin/pyrsa-decrypt delete mode 100755 ganga-env/bin/pyrsa-encrypt delete mode 100755 ganga-env/bin/pyrsa-keygen delete mode 100755 ganga-env/bin/pyrsa-priv2pub delete mode 100755 ganga-env/bin/pyrsa-sign delete mode 100755 ganga-env/bin/pyrsa-verify delete mode 100755 ganga-env/bin/pytest delete mode 120000 ganga-env/bin/python delete mode 120000 ganga-env/bin/python3 delete mode 120000 ganga-env/bin/python3.10 delete mode 100755 ganga-env/bin/tqdm delete mode 120000 ganga-env/lib64 delete mode 100644 ganga-env/pyvenv.cfg delete mode 100644 ganga-env/share/man/man1/ipython.1 diff --git a/ganga-env/bin/Activate.ps1 b/ganga-env/bin/Activate.ps1 deleted file mode 100644 index b49d77ba44..0000000000 --- a/ganga-env/bin/Activate.ps1 +++ /dev/null @@ -1,247 +0,0 @@ -<# -.Synopsis -Activate a Python virtual environment for the current PowerShell session. - -.Description -Pushes the python executable for a virtual environment to the front of the -$Env:PATH environment variable and sets the prompt to signify that you are -in a Python virtual environment. Makes use of the command line switches as -well as the `pyvenv.cfg` file values present in the virtual environment. - -.Parameter VenvDir -Path to the directory that contains the virtual environment to activate. The -default value for this is the parent of the directory that the Activate.ps1 -script is located within. - -.Parameter Prompt -The prompt prefix to display when this virtual environment is activated. By -default, this prompt is the name of the virtual environment folder (VenvDir) -surrounded by parentheses and followed by a single space (ie. '(.venv) '). - -.Example -Activate.ps1 -Activates the Python virtual environment that contains the Activate.ps1 script. - -.Example -Activate.ps1 -Verbose -Activates the Python virtual environment that contains the Activate.ps1 script, -and shows extra information about the activation as it executes. - -.Example -Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv -Activates the Python virtual environment located in the specified location. - -.Example -Activate.ps1 -Prompt "MyPython" -Activates the Python virtual environment that contains the Activate.ps1 script, -and prefixes the current prompt with the specified string (surrounded in -parentheses) while the virtual environment is active. - -.Notes -On Windows, it may be required to enable this Activate.ps1 script by setting the -execution policy for the user. You can do this by issuing the following PowerShell -command: - -PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - -For more information on Execution Policies: -https://go.microsoft.com/fwlink/?LinkID=135170 - -#> -Param( - [Parameter(Mandatory = $false)] - [String] - $VenvDir, - [Parameter(Mandatory = $false)] - [String] - $Prompt -) - -<# Function declarations --------------------------------------------------- #> - -<# -.Synopsis -Remove all shell session elements added by the Activate script, including the -addition of the virtual environment's Python executable from the beginning of -the PATH variable. - -.Parameter NonDestructive -If present, do not remove this function from the global namespace for the -session. - -#> -function global:deactivate ([switch]$NonDestructive) { - # Revert to original values - - # The prior prompt: - if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { - Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt - Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT - } - - # The prior PYTHONHOME: - if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { - Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME - Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME - } - - # The prior PATH: - if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { - Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH - Remove-Item -Path Env:_OLD_VIRTUAL_PATH - } - - # Just remove the VIRTUAL_ENV altogether: - if (Test-Path -Path Env:VIRTUAL_ENV) { - Remove-Item -Path env:VIRTUAL_ENV - } - - # Just remove VIRTUAL_ENV_PROMPT altogether. - if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { - Remove-Item -Path env:VIRTUAL_ENV_PROMPT - } - - # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: - if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { - Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force - } - - # Leave deactivate function in the global namespace if requested: - if (-not $NonDestructive) { - Remove-Item -Path function:deactivate - } -} - -<# -.Description -Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the -given folder, and returns them in a map. - -For each line in the pyvenv.cfg file, if that line can be parsed into exactly -two strings separated by `=` (with any amount of whitespace surrounding the =) -then it is considered a `key = value` line. The left hand string is the key, -the right hand is the value. - -If the value starts with a `'` or a `"` then the first and last character is -stripped from the value before being captured. - -.Parameter ConfigDir -Path to the directory that contains the `pyvenv.cfg` file. -#> -function Get-PyVenvConfig( - [String] - $ConfigDir -) { - Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" - - # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). - $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue - - # An empty map will be returned if no config file is found. - $pyvenvConfig = @{ } - - if ($pyvenvConfigPath) { - - Write-Verbose "File exists, parse `key = value` lines" - $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath - - $pyvenvConfigContent | ForEach-Object { - $keyval = $PSItem -split "\s*=\s*", 2 - if ($keyval[0] -and $keyval[1]) { - $val = $keyval[1] - - # Remove extraneous quotations around a string value. - if ("'""".Contains($val.Substring(0, 1))) { - $val = $val.Substring(1, $val.Length - 2) - } - - $pyvenvConfig[$keyval[0]] = $val - Write-Verbose "Adding Key: '$($keyval[0])'='$val'" - } - } - } - return $pyvenvConfig -} - - -<# Begin Activate script --------------------------------------------------- #> - -# Determine the containing directory of this script -$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition -$VenvExecDir = Get-Item -Path $VenvExecPath - -Write-Verbose "Activation script is located in path: '$VenvExecPath'" -Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" -Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" - -# Set values required in priority: CmdLine, ConfigFile, Default -# First, get the location of the virtual environment, it might not be -# VenvExecDir if specified on the command line. -if ($VenvDir) { - Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" -} -else { - Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." - $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") - Write-Verbose "VenvDir=$VenvDir" -} - -# Next, read the `pyvenv.cfg` file to determine any required value such -# as `prompt`. -$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir - -# Next, set the prompt from the command line, or the config file, or -# just use the name of the virtual environment folder. -if ($Prompt) { - Write-Verbose "Prompt specified as argument, using '$Prompt'" -} -else { - Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" - if ($pyvenvCfg -and $pyvenvCfg['prompt']) { - Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" - $Prompt = $pyvenvCfg['prompt']; - } - else { - Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)" - Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" - $Prompt = Split-Path -Path $venvDir -Leaf - } -} - -Write-Verbose "Prompt = '$Prompt'" -Write-Verbose "VenvDir='$VenvDir'" - -# Deactivate any currently active virtual environment, but leave the -# deactivate function in place. -deactivate -nondestructive - -# Now set the environment variable VIRTUAL_ENV, used by many tools to determine -# that there is an activated venv. -$env:VIRTUAL_ENV = $VenvDir - -if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { - - Write-Verbose "Setting prompt to '$Prompt'" - - # Set the prompt to include the env name - # Make sure _OLD_VIRTUAL_PROMPT is global - function global:_OLD_VIRTUAL_PROMPT { "" } - Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT - New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt - - function global:prompt { - Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " - _OLD_VIRTUAL_PROMPT - } - $env:VIRTUAL_ENV_PROMPT = $Prompt -} - -# Clear PYTHONHOME -if (Test-Path -Path Env:PYTHONHOME) { - Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME - Remove-Item -Path Env:PYTHONHOME -} - -# Add the venv to the PATH -Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH -$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/ganga-env/bin/activate b/ganga-env/bin/activate deleted file mode 100644 index fe97e869d9..0000000000 --- a/ganga-env/bin/activate +++ /dev/null @@ -1,69 +0,0 @@ -# This file must be used with "source bin/activate" *from bash* -# you cannot run it directly - -deactivate () { - # reset old environment variables - if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then - PATH="${_OLD_VIRTUAL_PATH:-}" - export PATH - unset _OLD_VIRTUAL_PATH - fi - if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then - PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" - export PYTHONHOME - unset _OLD_VIRTUAL_PYTHONHOME - fi - - # This should detect bash and zsh, which have a hash command that must - # be called to get it to forget past commands. Without forgetting - # past commands the $PATH changes we made may not be respected - if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then - hash -r 2> /dev/null - fi - - if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then - PS1="${_OLD_VIRTUAL_PS1:-}" - export PS1 - unset _OLD_VIRTUAL_PS1 - fi - - unset VIRTUAL_ENV - unset VIRTUAL_ENV_PROMPT - if [ ! "${1:-}" = "nondestructive" ] ; then - # Self destruct! - unset -f deactivate - fi -} - -# unset irrelevant variables -deactivate nondestructive - -VIRTUAL_ENV="/home/saad/Documents/Github/ganga/ganga-env" -export VIRTUAL_ENV - -_OLD_VIRTUAL_PATH="$PATH" -PATH="$VIRTUAL_ENV/bin:$PATH" -export PATH - -# unset PYTHONHOME if set -# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) -# could use `if (set -u; : $PYTHONHOME) ;` in bash -if [ -n "${PYTHONHOME:-}" ] ; then - _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" - unset PYTHONHOME -fi - -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then - _OLD_VIRTUAL_PS1="${PS1:-}" - PS1="(ganga-env) ${PS1:-}" - export PS1 - VIRTUAL_ENV_PROMPT="(ganga-env) " - export VIRTUAL_ENV_PROMPT -fi - -# This should detect bash and zsh, which have a hash command that must -# be called to get it to forget past commands. Without forgetting -# past commands the $PATH changes we made may not be respected -if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then - hash -r 2> /dev/null -fi diff --git a/ganga-env/bin/activate.csh b/ganga-env/bin/activate.csh deleted file mode 100644 index 58c2055d0c..0000000000 --- a/ganga-env/bin/activate.csh +++ /dev/null @@ -1,26 +0,0 @@ -# This file must be used with "source bin/activate.csh" *from csh*. -# You cannot run it directly. -# Created by Davide Di Blasi . -# Ported to Python 3.3 venv by Andrew Svetlov - -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' - -# Unset irrelevant variables. -deactivate nondestructive - -setenv VIRTUAL_ENV "/home/saad/Documents/Github/ganga/ganga-env" - -set _OLD_VIRTUAL_PATH="$PATH" -setenv PATH "$VIRTUAL_ENV/bin:$PATH" - - -set _OLD_VIRTUAL_PROMPT="$prompt" - -if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then - set prompt = "(ganga-env) $prompt" - setenv VIRTUAL_ENV_PROMPT "(ganga-env) " -endif - -alias pydoc python -m pydoc - -rehash diff --git a/ganga-env/bin/activate.fish b/ganga-env/bin/activate.fish deleted file mode 100644 index 765439460b..0000000000 --- a/ganga-env/bin/activate.fish +++ /dev/null @@ -1,69 +0,0 @@ -# This file must be used with "source /bin/activate.fish" *from fish* -# (https://fishshell.com/); you cannot run it directly. - -function deactivate -d "Exit virtual environment and return to normal shell environment" - # reset old environment variables - if test -n "$_OLD_VIRTUAL_PATH" - set -gx PATH $_OLD_VIRTUAL_PATH - set -e _OLD_VIRTUAL_PATH - end - if test -n "$_OLD_VIRTUAL_PYTHONHOME" - set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME - set -e _OLD_VIRTUAL_PYTHONHOME - end - - if test -n "$_OLD_FISH_PROMPT_OVERRIDE" - set -e _OLD_FISH_PROMPT_OVERRIDE - # prevents error when using nested fish instances (Issue #93858) - if functions -q _old_fish_prompt - functions -e fish_prompt - functions -c _old_fish_prompt fish_prompt - functions -e _old_fish_prompt - end - end - - set -e VIRTUAL_ENV - set -e VIRTUAL_ENV_PROMPT - if test "$argv[1]" != "nondestructive" - # Self-destruct! - functions -e deactivate - end -end - -# Unset irrelevant variables. -deactivate nondestructive - -set -gx VIRTUAL_ENV "/home/saad/Documents/Github/ganga/ganga-env" - -set -gx _OLD_VIRTUAL_PATH $PATH -set -gx PATH "$VIRTUAL_ENV/bin" $PATH - -# Unset PYTHONHOME if set. -if set -q PYTHONHOME - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME - set -e PYTHONHOME -end - -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" - # fish uses a function instead of an env var to generate the prompt. - - # Save the current fish_prompt function as the function _old_fish_prompt. - functions -c fish_prompt _old_fish_prompt - - # With the original prompt function renamed, we can override with our own. - function fish_prompt - # Save the return status of the last command. - set -l old_status $status - - # Output the venv prompt; color taken from the blue of the Python logo. - printf "%s%s%s" (set_color 4B8BBE) "(ganga-env) " (set_color normal) - - # Restore the return status of the previous command. - echo "exit $old_status" | . - # Output the original/"old" prompt. - _old_fish_prompt - end - - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" - set -gx VIRTUAL_ENV_PROMPT "(ganga-env) " -end diff --git a/ganga-env/bin/flake8 b/ganga-env/bin/flake8 deleted file mode 100755 index 4f1ba5b47b..0000000000 --- a/ganga-env/bin/flake8 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from flake8.main.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/ganga b/ganga-env/bin/ganga deleted file mode 100755 index ef064db09c..0000000000 --- a/ganga-env/bin/ganga +++ /dev/null @@ -1,7 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# EASY-INSTALL-DEV-SCRIPT: 'ganga==8.4.2','ganga' -__requires__ = 'ganga==8.4.2' -__import__('pkg_resources').require('ganga==8.4.2') -__file__ = '/home/saad/Documents/Github/ganga/bin/ganga' -with open(__file__) as f: - exec(compile(f.read(), __file__, 'exec')) diff --git a/ganga-env/bin/gdown b/ganga-env/bin/gdown deleted file mode 100755 index fc8090f388..0000000000 --- a/ganga-env/bin/gdown +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from gdown.__main__ import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/google-oauthlib-tool b/ganga-env/bin/google-oauthlib-tool deleted file mode 100755 index 0eb6f93a56..0000000000 --- a/ganga-env/bin/google-oauthlib-tool +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from google_auth_oauthlib.tool.__main__ import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/ipython b/ganga-env/bin/ipython deleted file mode 100755 index bb35ca6e84..0000000000 --- a/ganga-env/bin/ipython +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from IPython import start_ipython -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(start_ipython()) diff --git a/ganga-env/bin/ipython3 b/ganga-env/bin/ipython3 deleted file mode 100755 index bb35ca6e84..0000000000 --- a/ganga-env/bin/ipython3 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from IPython import start_ipython -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(start_ipython()) diff --git a/ganga-env/bin/normalizer b/ganga-env/bin/normalizer deleted file mode 100755 index 9c4a25d5a0..0000000000 --- a/ganga-env/bin/normalizer +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from charset_normalizer.cli import cli_detect -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(cli_detect()) diff --git a/ganga-env/bin/pip b/ganga-env/bin/pip deleted file mode 100755 index 945f259d41..0000000000 --- a/ganga-env/bin/pip +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/pip3 b/ganga-env/bin/pip3 deleted file mode 100755 index 945f259d41..0000000000 --- a/ganga-env/bin/pip3 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/pip3.10 b/ganga-env/bin/pip3.10 deleted file mode 100755 index 945f259d41..0000000000 --- a/ganga-env/bin/pip3.10 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/py.test b/ganga-env/bin/py.test deleted file mode 100755 index f4d3f80e9e..0000000000 --- a/ganga-env/bin/py.test +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pytest import console_main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(console_main()) diff --git a/ganga-env/bin/pycodestyle b/ganga-env/bin/pycodestyle deleted file mode 100755 index 61fdccf86f..0000000000 --- a/ganga-env/bin/pycodestyle +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pycodestyle import _main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(_main()) diff --git a/ganga-env/bin/pyflakes b/ganga-env/bin/pyflakes deleted file mode 100755 index 556c1346fa..0000000000 --- a/ganga-env/bin/pyflakes +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pyflakes.api import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/pygmentize b/ganga-env/bin/pygmentize deleted file mode 100755 index 48ba5da9f2..0000000000 --- a/ganga-env/bin/pygmentize +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pygments.cmdline import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/bin/pyrsa-decrypt b/ganga-env/bin/pyrsa-decrypt deleted file mode 100755 index ffb7a61994..0000000000 --- a/ganga-env/bin/pyrsa-decrypt +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import decrypt -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(decrypt()) diff --git a/ganga-env/bin/pyrsa-encrypt b/ganga-env/bin/pyrsa-encrypt deleted file mode 100755 index 09355af58f..0000000000 --- a/ganga-env/bin/pyrsa-encrypt +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import encrypt -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(encrypt()) diff --git a/ganga-env/bin/pyrsa-keygen b/ganga-env/bin/pyrsa-keygen deleted file mode 100755 index 8a4d077f7c..0000000000 --- a/ganga-env/bin/pyrsa-keygen +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import keygen -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(keygen()) diff --git a/ganga-env/bin/pyrsa-priv2pub b/ganga-env/bin/pyrsa-priv2pub deleted file mode 100755 index b5bdd88c17..0000000000 --- a/ganga-env/bin/pyrsa-priv2pub +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.util import private_to_public -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(private_to_public()) diff --git a/ganga-env/bin/pyrsa-sign b/ganga-env/bin/pyrsa-sign deleted file mode 100755 index 1d41f8df17..0000000000 --- a/ganga-env/bin/pyrsa-sign +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import sign -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(sign()) diff --git a/ganga-env/bin/pyrsa-verify b/ganga-env/bin/pyrsa-verify deleted file mode 100755 index b2093e3942..0000000000 --- a/ganga-env/bin/pyrsa-verify +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import verify -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(verify()) diff --git a/ganga-env/bin/pytest b/ganga-env/bin/pytest deleted file mode 100755 index f4d3f80e9e..0000000000 --- a/ganga-env/bin/pytest +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pytest import console_main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(console_main()) diff --git a/ganga-env/bin/python b/ganga-env/bin/python deleted file mode 120000 index b8a0adbbb9..0000000000 --- a/ganga-env/bin/python +++ /dev/null @@ -1 +0,0 @@ -python3 \ No newline at end of file diff --git a/ganga-env/bin/python3 b/ganga-env/bin/python3 deleted file mode 120000 index ae65fdaa12..0000000000 --- a/ganga-env/bin/python3 +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/python3 \ No newline at end of file diff --git a/ganga-env/bin/python3.10 b/ganga-env/bin/python3.10 deleted file mode 120000 index b8a0adbbb9..0000000000 --- a/ganga-env/bin/python3.10 +++ /dev/null @@ -1 +0,0 @@ -python3 \ No newline at end of file diff --git a/ganga-env/bin/tqdm b/ganga-env/bin/tqdm deleted file mode 100755 index 1a33007860..0000000000 --- a/ganga-env/bin/tqdm +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/saad/Documents/Github/ganga/ganga-env/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from tqdm.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/ganga-env/lib64 b/ganga-env/lib64 deleted file mode 120000 index 7951405f85..0000000000 --- a/ganga-env/lib64 +++ /dev/null @@ -1 +0,0 @@ -lib \ No newline at end of file diff --git a/ganga-env/pyvenv.cfg b/ganga-env/pyvenv.cfg deleted file mode 100644 index 0537ffc00b..0000000000 --- a/ganga-env/pyvenv.cfg +++ /dev/null @@ -1,3 +0,0 @@ -home = /usr/bin -include-system-site-packages = false -version = 3.10.12 diff --git a/ganga-env/share/man/man1/ipython.1 b/ganga-env/share/man/man1/ipython.1 deleted file mode 100644 index 0f4a191f3f..0000000000 --- a/ganga-env/share/man/man1/ipython.1 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH IPYTHON 1 "July 15, 2011" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) and groff_man(7) -.\" .SH section heading -.\" .SS secondary section heading -.\" -.\" -.\" To preview this page as plain text: nroff -man ipython.1 -.\" -.SH NAME -ipython \- Tools for Interactive Computing in Python. -.SH SYNOPSIS -.B ipython -.RI [ options ] " files" ... - -.B ipython subcommand -.RI [ options ] ... - -.SH DESCRIPTION -An interactive Python shell with automatic history (input and output), dynamic -object introspection, easier configuration, command completion, access to the -system shell, integration with numerical and scientific computing tools, -web notebook, Qt console, and more. - -For more information on how to use IPython, see 'ipython \-\-help', -or 'ipython \-\-help\-all' for all available command\(hyline options. - -.SH "ENVIRONMENT VARIABLES" -.sp -.PP -\fIIPYTHONDIR\fR -.RS 4 -This is the location where IPython stores all its configuration files. The default -is $HOME/.ipython if IPYTHONDIR is not defined. - -You can see the computed value of IPYTHONDIR with `ipython locate`. - -.SH FILES - -IPython uses various configuration files stored in profiles within IPYTHONDIR. -To generate the default configuration files and start configuring IPython, -do 'ipython profile create', and edit '*_config.py' files located in -IPYTHONDIR/profile_default. - -.SH AUTHORS -IPython is written by the IPython Development Team . diff --git a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py index 447c65c8a7..9bca79a70f 100755 --- a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py +++ b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py @@ -706,52 +706,59 @@ def reloadJob(self, i): stripProxy(self.registry_slice).objects.repository.load([i]) return True - def runMonitoring(self, steps, timeout, jobs=None): + def runMonitoring(self, jobs=None, steps=1, timeout=300): """ Enable/Run the monitoring loop and wait for the monitoring steps completion. - Parameters: - steps: number of monitoring steps to run - timeout: how long to wait for monitor steps termination (seconds) - jobs: a registry slice to be monitored (None -> all jobs), or an int, list of int, or job object - + steps: number of monitoring steps to run + timeout: how long to wait for monitor steps termination (seconds) + jobs: a registry slice to be monitored (None -> all jobs), it may be passed by the user so ._impl is stripped if needed Return: - False, if the loop cannot be started or the timeout occurred while waiting for monitoring termination - True, if the monitoring steps were successfully executed + False, if the loop cannot be started or the timeout occured while waiting for monitoring termination + True, if the monitoring steps were successfully executed + Note: + This method is meant to be used in Ganga scripts to request monitoring on demand. """ - + log.debug("runMonitoring") if GANGA_SWAN_INTEGRATION: - # (Existing logic) + # Detect New Jobs from other sessions. new_jobs = stripProxy(self.registry_slice).objects.repository.update_index(True, True) self.newly_discovered_jobs = list(set(self.newly_discovered_jobs) | set(new_jobs)) for i in self.newly_discovered_jobs: j = stripProxy(self.registry_slice(i)) job_status = lazyLoadJobStatus(j) - if job_status == 'new': + if job_status in ['new']: stripProxy(self.registry_slice).objects.repository.load([i]) - # Validate `steps` if not isType(steps, int) or steps <= 0: log.warning("The number of monitor steps should be a positive (non-zero) integer") return False - # Check if the monitoring loop is alive and services are enabled if not self.alive: log.error("Cannot run the monitoring loop. It has already been stopped") return False + # we don not allow the user's request the monitoring loop while the + # internal services are stopped if not Coordinator.servicesEnabled: - log.error("Cannot run the monitoring loop. The internal services are disabled (check your credentials or available disk space)") + log.error("Cannot run the monitoring loop." + "The internal services are disabled (check your credentials or available disk space)") return False + # if the monitoring is disabled (e.g. scripts) if not self.enabled: + # and there are some required cred which are missing + # (the monitoring loop does not monitor the credentials so we need to check 'by hand' here) _missingCreds = get_needed_credentials() if _missingCreds: - log.error(f"Cannot run the monitoring loop. The following credentials are required: {_missingCreds}") + log.error("Cannot run the monitoring loop. The following credentials are required: %s" % _missingCreds) return False + #log.debug("jobs: %s" % str(jobs)) + #log.debug("self.__mainLoopCond: %s" % str(self.__mainLoopCond)) + # Handle the `jobs` input (new logic to handle int, list, job object) if jobs is not None: if isinstance(jobs, int): @@ -777,7 +784,6 @@ def runMonitoring(self, steps, timeout, jobs=None): log.warning('jobs argument must be a registry slice, int, list of int, or job object') return False m_jobs = jobs - # Pass the new `m_jobs` (registry slice) for further processing self.makeUpdateJobStatusFunction(jobSlice=m_jobs) diff --git a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py index 50c5e253e2..fc4632c1b6 100644 --- a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py +++ b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py @@ -1,95 +1,125 @@ + + import time + from GangaCore.testlib.GangaUnitTest import GangaUnitTest master_timeout = 300. + def dummySleep(someJob): my_timeout = 0. while someJob.status not in ['completed', 'failed', 'killed', 'removed'] and my_timeout < master_timeout: time.sleep(1.) my_timeout += 1. + class TestMonitoring(GangaUnitTest): def setUp(self): - """Set up configurations for monitoring tests.""" + """Make sure that the Job object isn't destroyed between tests""" extra_opts = [('PollThread', 'autostart', 'False'), ('PollThread', 'base_poll_rate', 1)] super(TestMonitoring, self).setUp(extra_opts=extra_opts) def tearDown(self): + from GangaCore.Utility.Config import getConfig super(TestMonitoring, self).tearDown() - def test_a_runMonitoring_withJobSlice(self): - from GangaCore.GPI import enableMonitoring, Job, jobs, runMonitoring - - enableMonitoring() + def test_a_JobConstruction(self): + from GangaCore.GPI import Job, jobs, disableMonitoring + j = Job() + + self.assertEqual(len(jobs), 1) + j.submit() - dummySleep(j) - result = runMonitoring(steps=3, jobs=jobs[:]) - self.assertTrue(result, "runMonitoring with job slice failed to execute successfully.") + self.assertNotEqual(j.status, 'new') - def test_b_runMonitoring_withJobID(self): + def test_b_EnableMonitoring(self): from GangaCore.GPI import enableMonitoring, Job, jobs, runMonitoring enableMonitoring() + j = Job() j.submit() + dummySleep(j) job_id = j.id result = runMonitoring(steps=3, jobs=job_id) - self.assertTrue(result, "runMonitoring with job ID failed to execute successfully.") + self.assertTrue(result, + "runMonitoring with job ID failed to execute successfully.") - def test_c_runMonitoring_withJobIDList(self): - from GangaCore.GPI import enableMonitoring, Job, runMonitoring - enableMonitoring() - job_ids = [] - for _ in range(2): - j = Job() - j.submit() - dummySleep(j) - job_ids.append(j.id) - - result = runMonitoring(steps=3, jobs=job_ids) - self.assertTrue(result, "runMonitoring with list of job IDs failed to execute successfully.") + def test_c_disableMonitoring(self): - def test_d_runMonitoring_withJobObject(self): - from GangaCore.GPI import enableMonitoring, Job, runMonitoring + from GangaCore.GPI import disableMonitoring + + disableMonitoring() + + def test_d_anotherNewJob(self): + + from GangaCore.GPI import Job, jobs - enableMonitoring() j = Job() + j.submit() - dummySleep(j) + self.assertNotEqual(j.status, 'new') - result = runMonitoring(steps=3, jobs=j) - self.assertTrue(result, "runMonitoring with job object failed to execute successfully.") + def test_e_reEnableMon(self): - def test_e_disableAndEnableMonitoring(self): - from GangaCore.GPI import disableMonitoring, enableMonitoring, Job, runMonitoring + from GangaCore.GPI import disableMonitoring, enableMonitoring, Job, jobs disableMonitoring() enableMonitoring() - + disableMonitoring() + enableMonitoring() + j = Job() j.submit() + dummySleep(j) - result = runMonitoring(steps=3, jobs=j) - self.assertTrue(result, "Re-enabling monitoring and running on a job object failed.") + self.assertEqual(j.status, 'completed') + + def test_f_reallyDisabled(self): - def test_f_monitoringLoopStatus(self): - from GangaCore.GPI import disableMonitoring, enableMonitoring, Job, runMonitoring + from GangaCore.GPI import disableMonitoring, enableMonitoring, Job disableMonitoring() j = Job() j.submit() + self.assertEqual(j.status, 'submitted') enableMonitoring() + + dummySleep(j) + + self.assertEqual(j.status, 'completed') + + def test_g_runMonitoring_withJobIDList(self): + from GangaCore.GPI import enableMonitoring, Job, runMonitoring + + enableMonitoring() + job_ids = [] + for _ in range(2): + j = Job() + j.submit() + dummySleep(j) + job_ids.append(j.id) + + result = runMonitoring(steps=3, jobs=job_ids) + self.assertTrue(result, "runMonitoring with list of job IDs failed to execute successfully.") + + def test_h_runMonitoring_withJobObject(self): + from GangaCore.GPI import enableMonitoring, Job, runMonitoring + + enableMonitoring() + j = Job() + j.submit() dummySleep(j) result = runMonitoring(steps=3, jobs=j) - self.assertTrue(result, "Final monitoring loop status check failed.") + self.assertTrue(result, "runMonitoring with job object failed to execute successfully.") \ No newline at end of file