From 232a60ac7d43d4e75bc16fb14f229f0ef918a955 Mon Sep 17 00:00:00 2001 From: saadkhi Date: Tue, 29 Oct 2024 22:55:36 +0500 Subject: [PATCH 1/5] Make runMonitoring take more types --- 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 | 95 ++++--- .../test/GPI/Monitoring/TestMonitoring.py | 83 +++--- 34 files changed, 740 insertions(+), 91 deletions(-) create mode 100644 ganga-env/bin/Activate.ps1 create mode 100644 ganga-env/bin/activate create mode 100644 ganga-env/bin/activate.csh create mode 100644 ganga-env/bin/activate.fish create mode 100755 ganga-env/bin/flake8 create mode 100755 ganga-env/bin/ganga create mode 100755 ganga-env/bin/gdown create mode 100755 ganga-env/bin/google-oauthlib-tool create mode 100755 ganga-env/bin/ipython create mode 100755 ganga-env/bin/ipython3 create mode 100755 ganga-env/bin/normalizer create mode 100755 ganga-env/bin/pip create mode 100755 ganga-env/bin/pip3 create mode 100755 ganga-env/bin/pip3.10 create mode 100755 ganga-env/bin/py.test create mode 100755 ganga-env/bin/pycodestyle create mode 100755 ganga-env/bin/pyflakes create mode 100755 ganga-env/bin/pygmentize create mode 100755 ganga-env/bin/pyrsa-decrypt create mode 100755 ganga-env/bin/pyrsa-encrypt create mode 100755 ganga-env/bin/pyrsa-keygen create mode 100755 ganga-env/bin/pyrsa-priv2pub create mode 100755 ganga-env/bin/pyrsa-sign create mode 100755 ganga-env/bin/pyrsa-verify create mode 100755 ganga-env/bin/pytest create mode 120000 ganga-env/bin/python create mode 120000 ganga-env/bin/python3 create mode 120000 ganga-env/bin/python3.10 create mode 100755 ganga-env/bin/tqdm create mode 120000 ganga-env/lib64 create mode 100644 ganga-env/pyvenv.cfg create mode 100644 ganga-env/share/man/man1/ipython.1 diff --git a/ganga-env/bin/Activate.ps1 b/ganga-env/bin/Activate.ps1 new file mode 100644 index 0000000000..b49d77ba44 --- /dev/null +++ b/ganga-env/bin/Activate.ps1 @@ -0,0 +1,247 @@ +<# +.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 new file mode 100644 index 0000000000..fe97e869d9 --- /dev/null +++ b/ganga-env/bin/activate @@ -0,0 +1,69 @@ +# 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 new file mode 100644 index 0000000000..58c2055d0c --- /dev/null +++ b/ganga-env/bin/activate.csh @@ -0,0 +1,26 @@ +# 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 new file mode 100644 index 0000000000..765439460b --- /dev/null +++ b/ganga-env/bin/activate.fish @@ -0,0 +1,69 @@ +# 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 new file mode 100755 index 0000000000..4f1ba5b47b --- /dev/null +++ b/ganga-env/bin/flake8 @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..ef064db09c --- /dev/null +++ b/ganga-env/bin/ganga @@ -0,0 +1,7 @@ +#!/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 new file mode 100755 index 0000000000..fc8090f388 --- /dev/null +++ b/ganga-env/bin/gdown @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..0eb6f93a56 --- /dev/null +++ b/ganga-env/bin/google-oauthlib-tool @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..bb35ca6e84 --- /dev/null +++ b/ganga-env/bin/ipython @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..bb35ca6e84 --- /dev/null +++ b/ganga-env/bin/ipython3 @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..9c4a25d5a0 --- /dev/null +++ b/ganga-env/bin/normalizer @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..945f259d41 --- /dev/null +++ b/ganga-env/bin/pip @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..945f259d41 --- /dev/null +++ b/ganga-env/bin/pip3 @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..945f259d41 --- /dev/null +++ b/ganga-env/bin/pip3.10 @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..f4d3f80e9e --- /dev/null +++ b/ganga-env/bin/py.test @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..61fdccf86f --- /dev/null +++ b/ganga-env/bin/pycodestyle @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..556c1346fa --- /dev/null +++ b/ganga-env/bin/pyflakes @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..48ba5da9f2 --- /dev/null +++ b/ganga-env/bin/pygmentize @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..ffb7a61994 --- /dev/null +++ b/ganga-env/bin/pyrsa-decrypt @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..09355af58f --- /dev/null +++ b/ganga-env/bin/pyrsa-encrypt @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..8a4d077f7c --- /dev/null +++ b/ganga-env/bin/pyrsa-keygen @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..b5bdd88c17 --- /dev/null +++ b/ganga-env/bin/pyrsa-priv2pub @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..1d41f8df17 --- /dev/null +++ b/ganga-env/bin/pyrsa-sign @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..b2093e3942 --- /dev/null +++ b/ganga-env/bin/pyrsa-verify @@ -0,0 +1,8 @@ +#!/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 new file mode 100755 index 0000000000..f4d3f80e9e --- /dev/null +++ b/ganga-env/bin/pytest @@ -0,0 +1,8 @@ +#!/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 new file mode 120000 index 0000000000..b8a0adbbb9 --- /dev/null +++ b/ganga-env/bin/python @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/ganga-env/bin/python3 b/ganga-env/bin/python3 new file mode 120000 index 0000000000..ae65fdaa12 --- /dev/null +++ b/ganga-env/bin/python3 @@ -0,0 +1 @@ +/usr/bin/python3 \ No newline at end of file diff --git a/ganga-env/bin/python3.10 b/ganga-env/bin/python3.10 new file mode 120000 index 0000000000..b8a0adbbb9 --- /dev/null +++ b/ganga-env/bin/python3.10 @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/ganga-env/bin/tqdm b/ganga-env/bin/tqdm new file mode 100755 index 0000000000..1a33007860 --- /dev/null +++ b/ganga-env/bin/tqdm @@ -0,0 +1,8 @@ +#!/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 new file mode 120000 index 0000000000..7951405f85 --- /dev/null +++ b/ganga-env/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/ganga-env/pyvenv.cfg b/ganga-env/pyvenv.cfg new file mode 100644 index 0000000000..0537ffc00b --- /dev/null +++ b/ganga-env/pyvenv.cfg @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000000..0f4a191f3f --- /dev/null +++ b/ganga-env/share/man/man1/ipython.1 @@ -0,0 +1,60 @@ +.\" 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 5ab32b59ce..447c65c8a7 100755 --- a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py +++ b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py @@ -706,59 +706,80 @@ def reloadJob(self, i): stripProxy(self.registry_slice).objects.repository.load([i]) return True - def runMonitoring(self, jobs=None, steps=1, timeout=300): + def runMonitoring(self, steps, timeout, jobs=None): """ 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), it may be passed by the user so ._impl is stripped if needed + 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 + Return: - 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. + False, if the loop cannot be started or the timeout occurred while waiting for monitoring termination + True, if the monitoring steps were successfully executed """ - + log.debug("runMonitoring") if GANGA_SWAN_INTEGRATION: - # Detect New Jobs from other sessions. + # (Existing logic) 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)) - # Only load jobs from disk which are in new state currently. for i in self.newly_discovered_jobs: j = stripProxy(self.registry_slice(i)) job_status = lazyLoadJobStatus(j) - if job_status in ['new']: + if job_status == 'new': stripProxy(self.registry_slice).objects.repository.load([i]) - if not isType(steps, int) and steps < 0: + # 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("Cannot run the monitoring loop. The following credentials are required: %s" % _missingCreds) + log.error(f"Cannot run the monitoring loop. The following credentials are required: {_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): + # If jobs is a single int, convert it to a slice (equivalent to one job) + log.debug(f"Converting job ID {jobs} to a registry slice") + m_jobs = self.registry_slice(jobs) + elif isinstance(jobs, list): + # If jobs is a list of int, ensure all elements are int and convert to registry slice + if all(isinstance(job, int) for job in jobs): + log.debug(f"Converting job IDs {jobs} to a registry slice") + m_jobs = [self.registry_slice(job) for job in jobs] + else: + log.warning("List must contain integers representing job IDs") + return False + elif isinstance(jobs, jobs): + # If jobs is a job object, directly assign it + log.debug(f"Using job object {jobs}") + m_jobs = jobs + else: + # Handle job slices (existing behavior) + from GangaCore.GPIDev.Lib.Registry.RegistrySlice import RegistrySlice + if not isinstance(jobs, RegistrySlice): + 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) with self.__mainLoopCond: log.debug('Monitoring loop lock acquired. Enabling mon loop') @@ -766,50 +787,26 @@ def runMonitoring(self, jobs=None, steps=1, timeout=300): log.error("The monitoring loop is already running.") return False - if jobs is not None: - m_jobs = jobs - - # additional check if m_jobs is really a registry slice - # the underlying code is not prepared to handle correctly the - # situation if it is not - from GangaCore.GPIDev.Lib.Registry.RegistrySlice import RegistrySlice - if not isType(m_jobs, RegistrySlice): - log.warning( - 'runMonitoring: jobs argument must be a registry slice such as a result of jobs.select() or jobs[i1:i2]') - return False - - #self.registry_slice = m_jobs - #log.debug("m_jobs: %s" % str(m_jobs)) - self.makeUpdateJobStatusFunction(jobSlice=m_jobs) - - log.debug("Enable Loop, Clear Iterators and setCallbackHook") - # enable mon loop + log.debug("Enable Loop, Clear Iterators, and setCallbackHook") self.enabled = True - # set how many steps to run self.steps = steps - # enable job list iterators self.stopIter.clear() - # Start backend update timeout checking. self.setCallbackHook(UpdateDict.timeoutCheck, {'thisDict': self.updateDict_ts}, True) - log.debug("Waking up Main Loop") - # wake up the mon loop self.__mainLoopCond.notify_all() log.debug("Waiting to execute steps") - # wait to execute the steps self.__monStepsTerminatedEvent.wait() self.__monStepsTerminatedEvent.clear() log.debug("Test for timeout") - # wait the steps to be executed or timeout to occur if not self.__awaitTermination(timeout): log.warning("Monitoring loop started but did not complete in the given timeout.") - # force loops termination self.stopIter.set() return False return True + def enableMonitoring(self): """ Run the monitoring loop continuously diff --git a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py index 96f0dd6edf..50c5e253e2 100644 --- a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py +++ b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py @@ -1,96 +1,95 @@ - - 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): - """Make sure that the Job object isn't destroyed between tests""" + """Set up configurations for monitoring 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_JobConstruction(self): - from GangaCore.GPI import Job, jobs, disableMonitoring - + def test_a_runMonitoring_withJobSlice(self): + from GangaCore.GPI import enableMonitoring, Job, jobs, runMonitoring + + enableMonitoring() j = Job() - - self.assertEqual(len(jobs), 1) - j.submit() + dummySleep(j) - self.assertNotEqual(j.status, 'new') + result = runMonitoring(steps=3, jobs=jobs[:]) + self.assertTrue(result, "runMonitoring with job slice failed to execute successfully.") - def test_b_EnableMonitoring(self): - from GangaCore.GPI import enableMonitoring, Job, jobs + def test_b_runMonitoring_withJobID(self): + from GangaCore.GPI import enableMonitoring, Job, jobs, runMonitoring enableMonitoring() - j = Job() j.submit() - dummySleep(j) - self.assertNotEqual(jobs(0).status, 'submitted') - - def test_c_disableMonitoring(self): + job_id = j.id + result = runMonitoring(steps=3, jobs=job_id) + self.assertTrue(result, "runMonitoring with job ID failed to execute successfully.") - from GangaCore.GPI import disableMonitoring + def test_c_runMonitoring_withJobIDList(self): + from GangaCore.GPI import enableMonitoring, Job, runMonitoring - disableMonitoring() - - def test_d_anotherNewJob(self): - - from GangaCore.GPI import Job, jobs + 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_d_runMonitoring_withJobObject(self): + from GangaCore.GPI import enableMonitoring, Job, runMonitoring + enableMonitoring() j = Job() - j.submit() - self.assertNotEqual(j.status, 'new') + dummySleep(j) - def test_e_reEnableMon(self): + result = runMonitoring(steps=3, jobs=j) + self.assertTrue(result, "runMonitoring with job object failed to execute successfully.") - from GangaCore.GPI import disableMonitoring, enableMonitoring, Job, jobs + def test_e_disableAndEnableMonitoring(self): + from GangaCore.GPI import disableMonitoring, enableMonitoring, Job, runMonitoring disableMonitoring() enableMonitoring() - disableMonitoring() - enableMonitoring() - + j = Job() j.submit() - dummySleep(j) - self.assertEqual(j.status, 'completed') + result = runMonitoring(steps=3, jobs=j) + self.assertTrue(result, "Re-enabling monitoring and running on a job object failed.") - def test_f_reallyDisabled(self): - - from GangaCore.GPI import disableMonitoring, enableMonitoring, Job + def test_f_monitoringLoopStatus(self): + from GangaCore.GPI import disableMonitoring, enableMonitoring, Job, runMonitoring disableMonitoring() j = Job() j.submit() - self.assertEqual(j.status, 'submitted') enableMonitoring() - dummySleep(j) - self.assertEqual(j.status, 'completed') + result = runMonitoring(steps=3, jobs=j) + self.assertTrue(result, "Final monitoring loop status check failed.") From 8d8202881097f979dbe3ff26446742e05353e5d7 Mon Sep 17 00:00:00 2001 From: saadkhi Date: Tue, 29 Oct 2024 23:43:46 +0500 Subject: [PATCH 2/5] new branch for issue sol From 4c2e73847960ab053eca9a083f1838667b3ca836 Mon Sep 17 00:00:00 2001 From: saadkhi Date: Thu, 31 Oct 2024 01:17:12 +0500 Subject: [PATCH 3/5] 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, 87 insertions(+), 706 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..c5e4feaeec 100644 --- a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py +++ b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py @@ -1,95 +1,123 @@ + + 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) + result = runMonitoring(jobs=job_id) self.assertTrue(result, "runMonitoring with job ID failed to execute successfully.") - def test_c_runMonitoring_withJobIDList(self): - from GangaCore.GPI import enableMonitoring, Job, runMonitoring + def test_c_disableMonitoring(self): - 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.") + from GangaCore.GPI import disableMonitoring - def test_d_runMonitoring_withJobObject(self): - from GangaCore.GPI import enableMonitoring, Job, runMonitoring + 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(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.") + result = runMonitoring(jobs=j) + self.assertTrue(result, "runMonitoring with job object failed to execute successfully.") \ No newline at end of file From 49693169a9c4ac77fc3da79341ddecd3f15f4e8f Mon Sep 17 00:00:00 2001 From: saadkhi Date: Mon, 4 Nov 2024 23:24:02 +0500 Subject: [PATCH 4/5] Refactored code --- .../Core/MonitoringComponent/Local_GangaMC_Service.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py index 9bca79a70f..9c606feb06 100755 --- a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py +++ b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py @@ -773,10 +773,6 @@ def runMonitoring(self, jobs=None, steps=1, timeout=300): else: log.warning("List must contain integers representing job IDs") return False - elif isinstance(jobs, jobs): - # If jobs is a job object, directly assign it - log.debug(f"Using job object {jobs}") - m_jobs = jobs else: # Handle job slices (existing behavior) from GangaCore.GPIDev.Lib.Registry.RegistrySlice import RegistrySlice From e1433c4271712b2a8200a3269ee0bd0da9976ef7 Mon Sep 17 00:00:00 2001 From: saadkhi Date: Tue, 12 Nov 2024 21:45:29 +0500 Subject: [PATCH 5/5] refactored base --- .../Core/MonitoringComponent/Local_GangaMC_Service.py | 3 ++- ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py index 9c606feb06..19c70f1559 100755 --- a/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py +++ b/ganga/GangaCore/Core/MonitoringComponent/Local_GangaMC_Service.py @@ -781,7 +781,7 @@ def runMonitoring(self, jobs=None, steps=1, timeout=300): return False m_jobs = jobs # Pass the new `m_jobs` (registry slice) for further processing - self.makeUpdateJobStatusFunction(jobSlice=m_jobs) + self.makeUpdateJobStatusFunction(jobSlice=m_jobs) with self.__mainLoopCond: log.debug('Monitoring loop lock acquired. Enabling mon loop') @@ -791,6 +791,7 @@ def runMonitoring(self, jobs=None, steps=1, timeout=300): log.debug("Enable Loop, Clear Iterators, and setCallbackHook") self.enabled = True + # set how many steps to run self.steps = steps self.stopIter.clear() self.setCallbackHook(UpdateDict.timeoutCheck, {'thisDict': self.updateDict_ts}, True) diff --git a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py index c5e4feaeec..2b23ec8ad7 100644 --- a/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py +++ b/ganga/GangaCore/test/GPI/Monitoring/TestMonitoring.py @@ -37,7 +37,7 @@ def test_a_JobConstruction(self): self.assertNotEqual(j.status, 'new') def test_b_EnableMonitoring(self): - from GangaCore.GPI import enableMonitoring, Job, jobs, runMonitoring + from GangaCore.GPI import enableMonitoring, Job, jobs enableMonitoring() @@ -46,9 +46,7 @@ def test_b_EnableMonitoring(self): dummySleep(j) - job_id = j.id - result = runMonitoring(jobs=job_id) - self.assertTrue(result, "runMonitoring with job ID failed to execute successfully.") + self.assertNotEqual(jobs(0).status, 'submitted') def test_c_disableMonitoring(self):