Loading bin/cso −x+109 −95 Changes for bin/cso: 109 added lines, 95 removed lines. Original line number Diff line number Diff line #! /usr/bin/env python3 """ CSO - CAMS Satellite Operator Pre-proocessor script. For arguments, see: cso --help History 2020-05, Arjo Segers Initital version. 2023-08, Arjo Segers Define 'CSO_PREFIX' environment variable for use in rcfile settings. 2023-11, Arjo Segers Reformatted using 'black'. 2023-08, Arjo Segers Define environment variables 'CSO_RCFILE' and 'CSO_RCDIR'. #! /bin/bash # # CSO - CAMS Satellite Operator # # Driver script to setup python virtural environment, managed by UV. # # # CHANGES # # 2029-09, Arjo Segers # Renewed from original python script to use uv package manager. # # script name: name=`basename $0` ## info ... #echo "${name} - " #echo "${name} - ** CSO **" #echo "${name} - " # # location # # full path to this script: script=`realpath $0` # 'bin' directory: bindir=`dirname ${script}` # installation prefix: prefix=`dirname ${bindir}` ## info .. #echo "${name} - locations:" #echo "${name} - script: ${script}" #echo "${name} - bindir: ${bindir}" #echo "${name} - prefix: ${prefix}" #echo "${name} - " # # uv package mananager # ## info ... #echo "${name} - check if uv package manager exist ..." # already present? if ( uv --version > /dev/null ); then # call directly: uv='uv' else # destination for uv installation: local="${HOME}/.local" # info ... echo "${name} - install uv package manager in ${local}/bin ..." # from: # https://docs.astral.sh/uv/ # local copy of installation script: script="install-uv.sh" # download: curl --location --silent --show-error --fail \ --output ${script} \ https://astral.sh/uv/install.sh # make executable: chmod u+x ${script} # settings: export UV_NO_MODIFY_PATH=1 # no changes to ~/.bashrc etc # run: ./${script} # cleanup: rm -f ${script} # store location: uv="${local}/bin/uv" fi # # run # """ # set environment: export CSO_PREFIX=${prefix} ## info .. #echo "${name} - activate virtural environment ..." # setup venv: source ${prefix}/.venv/bin/activate # ------------------------------------------------- # modules # ------------------------------------------------- ## info .. #echo "${name} - start 'cso' ..." # modules: import sys import os import logging # run 'cso' script, the 'pyproject.toml' file defines # that this should import the `cso` module and run method `main`: # # [project.scripts] # cso = "cso:main" # # run: ${uv} run cso $* # prefix of CSO installation: prefix = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)) # extend path: sys.path.insert(0, os.path.join(prefix, "src")) sys.path.insert(0, os.path.join(prefix, "src", "utopya")) sys.path.insert(0, os.path.join(prefix, "src", "cso")) ## info .. #echo "${name} - leaving virtual environment ..." # done: deactivate # tools: import utopya # # end # # ------------------------------------------------- # begin # ------------------------------------------------- ## info ... #echo "${name} - " #echo "${name} - ** end **" #echo "${name} - " # set environment: os.environ["CSO_PREFIX"] = prefix # dummy values to ensure that settings could be read first to setup logging: os.environ['CSO_RCFILE'] = 'None' os.environ['CSO_RCDIR'] = 'None' # init script: utos = utopya.UtopyaRunScriptRc() # setup standard command line arguments, and also enable rcfile arguments: utos.ArgumentsSetup(description="CAMS Satellite Operator", rcbase="cso") # evaluate known arguments, store the other ; # might show help text and exit: args, xargs = utos.ArgumentsParse() # store full path to settings: os.environ['CSO_RCFILE'] = os.path.abspath( args.rcfile ) # location of settings file: os.environ['CSO_RCDIR'] = os.path.dirname( os.path.abspath( args.rcfile ) ) # start, shout info: logging.info(f"") logging.info(f"** CSO - CAMS Satellite Operator **") logging.info(f"") logging.info(f"installation prefix : {prefix}") logging.info(f"input rcfile : {args.rcfile}") logging.info(f"settings base : {args.rcbase}") logging.info(f"") logging.info(f"environment:") for key in ["CSO_PREFIX","CSO_RCFILE","CSO_RCDIR"]: logging.info(f" {key} = {os.environ[key]}") # endfor logging.info(f"") # info ... logging.info(f"start job tree ...") # import class as defined in settings by 'cso.class' key; # should be (derived from) 'utopya.JobStep' : jbs_cls = utos.ImportClass("class") # init job step object, use the 'rcbase' as name: jbs = jbs_cls(args.rcbase, args.rcfile) # start first: jbs.Start(single=args.single) # info: logging.info(f"") logging.info(f"** end **") logging.info(f"") # ------------------------------------------------- # end # ------------------------------------------------- pyproject.toml +2 −1 Changes for pyproject.toml: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59,4 +59,5 @@ docs = [ ] [project.scripts] cso = "cso.scripts.cli:main" cso = "cso:main" src/cso/__init__.py +62 Changes for src/cso/__init__.py: 62 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -166,6 +166,68 @@ from .cso_catalogue import * from .cso_tools import * # ------------------------------------------------- # main # ------------------------------------------------- def main(): # modules: import sys import os # info ... #print(f"version: {__version__}") # testing ... #print(f"arguments:") #for arg in sys.argv: #s print(f" {arg}") # init script: utos = utopya.UtopyaRunScriptRc() # setup standard command line arguments, and also enable rcfile arguments: utos.ArgumentsSetup(description="CAMS Satellite Operator", rcbase="cso") # evaluate known arguments, store the other ; # might show help text and exit: args, xargs = utos.ArgumentsParse() # installation prefix: prefix = os.environ["CSO_PREFIX"] # store full path to settings: os.environ['CSO_RCFILE'] = os.path.abspath( args.rcfile ) # location of settings file: os.environ['CSO_RCDIR'] = os.path.dirname( os.path.abspath( args.rcfile ) ) # start, show info: logging.info(f"") logging.info(f"** CSO - CAMS Satellite Operator **") logging.info(f"") logging.info(f"installation prefix : {prefix}") logging.info(f"input rcfile : {args.rcfile}") logging.info(f"settings base : {args.rcbase}") logging.info(f"") logging.info(f"environment:") for key in ["CSO_PREFIX","CSO_RCFILE","CSO_RCDIR"]: logging.info(f" {key} = {os.environ[key]}") # endfor logging.info(f"") # info ... logging.info(f"start job tree ...") # import class as defined in settings by 'cso.class' key; # should be (derived from) 'utopya.JobStep' : jbs_cls = utos.ImportClass("class") # init job step object, use the 'rcbase' as name: jbs = jbs_cls(args.rcbase, args.rcfile) # start first: jbs.Start(single=args.single) #endif # ------------------------------------------------- # end # ------------------------------------------------- src/cso/scripts/__init__.py Empty file deleted. src/cso/scripts/cli.py −97 File deleted. Show changes Loading
bin/cso −x+109 −95 Changes for bin/cso: 109 added lines, 95 removed lines. Original line number Diff line number Diff line #! /usr/bin/env python3 """ CSO - CAMS Satellite Operator Pre-proocessor script. For arguments, see: cso --help History 2020-05, Arjo Segers Initital version. 2023-08, Arjo Segers Define 'CSO_PREFIX' environment variable for use in rcfile settings. 2023-11, Arjo Segers Reformatted using 'black'. 2023-08, Arjo Segers Define environment variables 'CSO_RCFILE' and 'CSO_RCDIR'. #! /bin/bash # # CSO - CAMS Satellite Operator # # Driver script to setup python virtural environment, managed by UV. # # # CHANGES # # 2029-09, Arjo Segers # Renewed from original python script to use uv package manager. # # script name: name=`basename $0` ## info ... #echo "${name} - " #echo "${name} - ** CSO **" #echo "${name} - " # # location # # full path to this script: script=`realpath $0` # 'bin' directory: bindir=`dirname ${script}` # installation prefix: prefix=`dirname ${bindir}` ## info .. #echo "${name} - locations:" #echo "${name} - script: ${script}" #echo "${name} - bindir: ${bindir}" #echo "${name} - prefix: ${prefix}" #echo "${name} - " # # uv package mananager # ## info ... #echo "${name} - check if uv package manager exist ..." # already present? if ( uv --version > /dev/null ); then # call directly: uv='uv' else # destination for uv installation: local="${HOME}/.local" # info ... echo "${name} - install uv package manager in ${local}/bin ..." # from: # https://docs.astral.sh/uv/ # local copy of installation script: script="install-uv.sh" # download: curl --location --silent --show-error --fail \ --output ${script} \ https://astral.sh/uv/install.sh # make executable: chmod u+x ${script} # settings: export UV_NO_MODIFY_PATH=1 # no changes to ~/.bashrc etc # run: ./${script} # cleanup: rm -f ${script} # store location: uv="${local}/bin/uv" fi # # run # """ # set environment: export CSO_PREFIX=${prefix} ## info .. #echo "${name} - activate virtural environment ..." # setup venv: source ${prefix}/.venv/bin/activate # ------------------------------------------------- # modules # ------------------------------------------------- ## info .. #echo "${name} - start 'cso' ..." # modules: import sys import os import logging # run 'cso' script, the 'pyproject.toml' file defines # that this should import the `cso` module and run method `main`: # # [project.scripts] # cso = "cso:main" # # run: ${uv} run cso $* # prefix of CSO installation: prefix = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)) # extend path: sys.path.insert(0, os.path.join(prefix, "src")) sys.path.insert(0, os.path.join(prefix, "src", "utopya")) sys.path.insert(0, os.path.join(prefix, "src", "cso")) ## info .. #echo "${name} - leaving virtual environment ..." # done: deactivate # tools: import utopya # # end # # ------------------------------------------------- # begin # ------------------------------------------------- ## info ... #echo "${name} - " #echo "${name} - ** end **" #echo "${name} - " # set environment: os.environ["CSO_PREFIX"] = prefix # dummy values to ensure that settings could be read first to setup logging: os.environ['CSO_RCFILE'] = 'None' os.environ['CSO_RCDIR'] = 'None' # init script: utos = utopya.UtopyaRunScriptRc() # setup standard command line arguments, and also enable rcfile arguments: utos.ArgumentsSetup(description="CAMS Satellite Operator", rcbase="cso") # evaluate known arguments, store the other ; # might show help text and exit: args, xargs = utos.ArgumentsParse() # store full path to settings: os.environ['CSO_RCFILE'] = os.path.abspath( args.rcfile ) # location of settings file: os.environ['CSO_RCDIR'] = os.path.dirname( os.path.abspath( args.rcfile ) ) # start, shout info: logging.info(f"") logging.info(f"** CSO - CAMS Satellite Operator **") logging.info(f"") logging.info(f"installation prefix : {prefix}") logging.info(f"input rcfile : {args.rcfile}") logging.info(f"settings base : {args.rcbase}") logging.info(f"") logging.info(f"environment:") for key in ["CSO_PREFIX","CSO_RCFILE","CSO_RCDIR"]: logging.info(f" {key} = {os.environ[key]}") # endfor logging.info(f"") # info ... logging.info(f"start job tree ...") # import class as defined in settings by 'cso.class' key; # should be (derived from) 'utopya.JobStep' : jbs_cls = utos.ImportClass("class") # init job step object, use the 'rcbase' as name: jbs = jbs_cls(args.rcbase, args.rcfile) # start first: jbs.Start(single=args.single) # info: logging.info(f"") logging.info(f"** end **") logging.info(f"") # ------------------------------------------------- # end # -------------------------------------------------
pyproject.toml +2 −1 Changes for pyproject.toml: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59,4 +59,5 @@ docs = [ ] [project.scripts] cso = "cso.scripts.cli:main" cso = "cso:main"
src/cso/__init__.py +62 Changes for src/cso/__init__.py: 62 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -166,6 +166,68 @@ from .cso_catalogue import * from .cso_tools import * # ------------------------------------------------- # main # ------------------------------------------------- def main(): # modules: import sys import os # info ... #print(f"version: {__version__}") # testing ... #print(f"arguments:") #for arg in sys.argv: #s print(f" {arg}") # init script: utos = utopya.UtopyaRunScriptRc() # setup standard command line arguments, and also enable rcfile arguments: utos.ArgumentsSetup(description="CAMS Satellite Operator", rcbase="cso") # evaluate known arguments, store the other ; # might show help text and exit: args, xargs = utos.ArgumentsParse() # installation prefix: prefix = os.environ["CSO_PREFIX"] # store full path to settings: os.environ['CSO_RCFILE'] = os.path.abspath( args.rcfile ) # location of settings file: os.environ['CSO_RCDIR'] = os.path.dirname( os.path.abspath( args.rcfile ) ) # start, show info: logging.info(f"") logging.info(f"** CSO - CAMS Satellite Operator **") logging.info(f"") logging.info(f"installation prefix : {prefix}") logging.info(f"input rcfile : {args.rcfile}") logging.info(f"settings base : {args.rcbase}") logging.info(f"") logging.info(f"environment:") for key in ["CSO_PREFIX","CSO_RCFILE","CSO_RCDIR"]: logging.info(f" {key} = {os.environ[key]}") # endfor logging.info(f"") # info ... logging.info(f"start job tree ...") # import class as defined in settings by 'cso.class' key; # should be (derived from) 'utopya.JobStep' : jbs_cls = utos.ImportClass("class") # init job step object, use the 'rcbase' as name: jbs = jbs_cls(args.rcbase, args.rcfile) # start first: jbs.Start(single=args.single) #endif # ------------------------------------------------- # end # -------------------------------------------------