diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f14d685 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "elisa_client_api"] + path = elisa_client_api + url = https://gitlab.cern.ch/atlas-tdaq-software/elisa_client_api.git diff --git a/doc/.conf.py.swp b/doc/.conf.py.swp deleted file mode 100644 index 81e629d..0000000 Binary files a/doc/.conf.py.swp and /dev/null differ diff --git a/doc/README b/doc/README deleted file mode 100644 index d1111cd..0000000 --- a/doc/README +++ /dev/null @@ -1,7 +0,0 @@ -How to build the documentation - -1) cd DAQ/online/elisa_client_api/python -2) Temporarily comment out in elisa.py - #from core.restServer import RestServer - #from core.authentication import Authentication -3) sphinx-build -b html -d doctrees . html diff --git a/doc/conf.py b/doc/conf.py deleted file mode 100644 index 914de90..0000000 --- a/doc/conf.py +++ /dev/null @@ -1,242 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Python Elisa client API documentation build configuration file, created by -# sphinx-quickstart on Tue Feb 19 15:24:35 2013. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc'] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Python Elisa client API' -copyright = u'2013, Raul Murillo Garcia' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = 'V00-00-09' -# The full version, including alpha/beta/rc tags. -release = 'V00-00-09' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'PythonElisaclientAPIdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'PythonElisaclientAPI.tex', u'Python Elisa client API Documentation', - u'Raul Murillo Garcia', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'pythonelisaclientapi', u'Python Elisa client API Documentation', - [u'Raul Murillo Garcia'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'PythonElisaclientAPI', u'Python Elisa client API Documentation', - u'Raul Murillo Garcia', 'PythonElisaclientAPI', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' diff --git a/doc/doctrees/elisa_client_api.doctree b/doc/doctrees/elisa_client_api.doctree deleted file mode 100644 index ff6e81b..0000000 Binary files a/doc/doctrees/elisa_client_api.doctree and /dev/null differ diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle deleted file mode 100644 index 70c82b8..0000000 Binary files a/doc/doctrees/environment.pickle and /dev/null differ diff --git a/doc/doctrees/index.doctree b/doc/doctrees/index.doctree deleted file mode 100644 index 4469d71..0000000 Binary files a/doc/doctrees/index.doctree and /dev/null differ diff --git a/doc/doctrees/modules.doctree b/doc/doctrees/modules.doctree deleted file mode 100644 index 03a5913..0000000 Binary files a/doc/doctrees/modules.doctree and /dev/null differ diff --git a/doc/doctrees/utilities.doctree b/doc/doctrees/utilities.doctree deleted file mode 100644 index def89d2..0000000 Binary files a/doc/doctrees/utilities.doctree and /dev/null differ diff --git a/doc/elisa_client_api.rst b/doc/elisa_client_api.rst deleted file mode 100644 index bed240c..0000000 --- a/doc/elisa_client_api.rst +++ /dev/null @@ -1,59 +0,0 @@ -Elisa client API -================ - - -:mod:`Elisa` ------------- -.. autoclass:: src.elisa.Elisa - :members: - :show-inheritance: - -:mod:`MessageRead` -------------------------- - -.. autoclass:: src.messageRead.MessageRead - :members: id, logbook, userName, author, date, subject, type, options, systemsAffected, body, host, hasReplies, replyTo, hasAttachments, attachments, status, threadHead, valid, encoding - :show-inheritance: - -:mod:`MessageInsert` ---------------------------- - -.. autoclass:: src.messageInsert.MessageInsert - :members: author, subject, type, options, systemsAffected, body, attachments, status - :show-inheritance: - -:mod:`MessageReply` --------------------------- - -.. autoclass:: src.messageReply.MessageReply - :members: author, subject, options, systemsAffected, body, attachments, status - :show-inheritance: - -:mod:`MessageUpdate` ---------------------------- - -.. autoclass:: src.messageUpdate.MessageUpdate - :members: body, attachments - :show-inheritance: - -:mod:`OptionsBuilder` ----------------------------- - -.. autoclass:: src.optionsBuilder.OptionsBuilder - :members: - :show-inheritance: - -:mod:`SearchCriteria` ----------------------------- - -.. autoclass:: src.searchCriteria.SearchCriteria - :members: - :show-inheritance: - -:mod:`exception` ------------------------ - -.. automodule:: src.exception - :members: - :show-inheritance: - diff --git a/doc/index.rst b/doc/index.rst deleted file mode 100644 index d78259b..0000000 --- a/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -.. Python Elisa client API documentation master file, created by - sphinx-quickstart on Tue Feb 19 15:24:35 2013. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Python Elisa client API's documentation! -=================================================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - modules - elisa_client_api - utilities - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/doc/modules.rst b/doc/modules.rst deleted file mode 100644 index 49b7636..0000000 --- a/doc/modules.rst +++ /dev/null @@ -1,8 +0,0 @@ -elisa_client_api -================ - -.. toctree:: - :maxdepth: 4 - - elisa_client_api - utilities diff --git a/doc/utilities.rst b/doc/utilities.rst deleted file mode 100644 index 1e52329..0000000 --- a/doc/utilities.rst +++ /dev/null @@ -1,275 +0,0 @@ -Utilities -========= - -elisa_get ---------- -Usage: :: - - elisa_get [options] args - -Options: :: - - -h, --help show this help message and exit - --version print information about program name, version, etc - -v LEVEL, --verbose=LEVEL - sets the verbosity level [0-4] - -s SERVER, --server=SERVER - URL of the EliSA REST server ( i.e. - https://elisa.cern.ch or - http://elisatest.cern.ch:8080). If not specified, the - mainEliSA server in P1 or GPN depending on user - location. - -o SSO, --sso-credential=SSO - path to a COOKIE file with the user credentials, as - generated by the CERN SSO cookie tool (http://linux.we - b.cern.ch/linux/docs/cernssocookie.shtml). MANDATORY - when interacting with the GPN EliSA instance. - -c USERNAME:PASSWORD, --ldap-credential=USERNAME:PASSWORD - user credential in the form USERNAME:PASSWORD or - USERNAME. If only the username is provided, the - password will be asked interactively. - -i ID, --id=ID message unique ID - -u USER, --username=USER - message user name - -a AUTHOR, --author=AUTHOR - message author. If the author string is missing the - author is evinced by user credential. N.B. space - handling works both as: -a Jhon\ Do or -a "Jhon Do" - -j SUBJECT, --subject=SUBJECT - message subject - -y TYPE, --type=TYPE message type. - -e SYSTEMS, --systems-affected=SYSTEMS - message systems affected. - -p OPTIONS, --options=OPTIONS - option value in a key-value form (i.e. -o "Trigger - Area=Trigger Group"). Inner options can be expressed - with a '.' notation between parent and inner option - name: -o "Trigger Area.Trigger Group=VALUE". This - option can be used multiple times. - -b BODY, --body=BODY string with the message body. - -x STATUS, --status=STATUS - message status (closed or open). Default value: open. - -f FROM, --date-from=FROM - initial date of the search. Format: DD/MM/YYYY - HH:MM:ss. - -t TO, --date-to=TO end date of the search. Format: DD/MM/YYYY HH:MM:ss. - -n Nm, --interval=Nm time interval. Current Server implementation only - support month interval. Format: NumberUnit: i.e. 3m = - 3 months, 12m = 12 months, etc. Could be evolved to - support different time units (7 days = 7d, 3 weeks = - 3w). If not specified, the search is done on the last - 3 months. - -l COUNT, --limit=COUNT - maximum number of messages retrieved. By default 10. - -m PATH, --attachment-path=PATH - path to download the attachments to. If this option is - not specified, the attachments are not downloaded. If - a value is not provided for this option, the - attachments are stored in the current path - - -elisa_insert ------------- -Usage: :: - - elisa_insert [options] args - -Options: :: - - -h, --help show this help message and exit - --version print information about program name, version, etc - -v LEVEL, --verbose=LEVEL - sets the verbosity level [0-4] - -s SERVER, --server=SERVER - URL of the EliSA REST server ( i.e. - https://elisa.cern.ch or - http://elisatest.cern.ch:8080). If not specified, the - mainEliSA server in P1 or GPN depending on user - location. - -o SSO, --sso-credential=SSO - path to a COOKIE file with the user credentials, as - generated by the CERN SSO cookie tool (http://linux.we - b.cern.ch/linux/docs/cernssocookie.shtml). MANDATORY - when interacting with the GPN EliSA instance. - -c USERNAME:PASSWORD, --ldap-credential=USERNAME:PASSWORD - user credential in the form USERNAME:PASSWORD or - USERNAME. If only the username is provided, the - password will be asked interactively. - -a AUTHOR, --author=AUTHOR - message author. If the author string is missing the - author is evinced by user credential. N.B. space - handling works both as: -a Jhon\ Do or -a "Jhon Do" - -j SUBJECT, --subject=SUBJECT - message subject - -y TYPE, --type=TYPE message type. - -e SYSTEMS, --systems-affected=SYSTEMS - message systems affected. - -p OPTIONS, --options=OPTIONS - option value in a key-value form (i.e. -o "Trigger - Area=Trigger Group"). Inner options can be expressed - with a '.' notation between parent and inner option - name: -o "Trigger Area.Trigger Group=VALUE". This - option can be used multiple times. - -b BODY, --body=BODY string with the message body. - -z BODY, --body-file=BODY - path to a file with a text representation of the - message body. - -x STATUS, --status=STATUS - message status (closed or open). Default value: open. - -m PATH, --attachment-file=PATH - path to a file to be attached to the messages. This - option can be used multiple times. - - -elisa_reply ------------ -Usage: :: - - elisa_reply [options] args - -Options: :: - - -h, --help show this help message and exit - --version print information about program name, version, etc - -v LEVEL, --verbose=LEVEL - sets the verbosity level [0-4] - -s SERVER, --server=SERVER - URL of the EliSA REST server ( i.e. - https://elisa.cern.ch or - http://elisatest.cern.ch:8080). If not specified, the - mainEliSA server in P1 or GPN depending on user - location. - -o SSO, --sso-credential=SSO - path to a COOKIE file with the user credentials, as - generated by the CERN SSO cookie tool (http://linux.we - b.cern.ch/linux/docs/cernssocookie.shtml). MANDATORY - when interacting with the GPN EliSA instance. - -c USERNAME:PASSWORD, --ldap-credential=USERNAME:PASSWORD - user credential in the form USERNAME:PASSWORD or - USERNAME. If only the username is provided, the - password will be asked interactively. - -i ID, --id=ID message unique ID - -a AUTHOR, --author=AUTHOR - message author. If the author string is missing the - author is evinced by user credential. N.B. space - handling works both as: -a Jhon\ Do or -a "Jhon Do" - -e SYSTEMS, --systems-affected=SYSTEMS - message systems affected. - -p OPTIONS, --options=OPTIONS - option value in a key-value form (i.e. -o "Trigger - Area=Trigger Group"). Inner options can be expressed - with a '.' notation between parent and inner option - name: -o "Trigger Area.Trigger Group=VALUE". This - option can be used multiple times. - -b BODY, --body=BODY string with the message body. - -z BODY, --body-file=BODY - path to a file with a text representation of the - message body. - -x STATUS, --status=STATUS - message status (closed or open). Default value: open. - -m PATH, --attachment-file=PATH - path to a file to be attached to the messages. This - option can be used multiple times. - - -elisa_update ------------- -Usage: :: - - elisa_update [options] args - -Options: :: - - -h, --help show this help message and exit - --version print information about program name, version, etc - -v LEVEL, --verbose=LEVEL - sets the verbosity level [0-4] - -s SERVER, --server=SERVER - URL of the EliSA REST server ( i.e. - https://elisa.cern.ch or - http://elisatest.cern.ch:8080). If not specified, the - mainEliSA server in P1 or GPN depending on user - location. - -o SSO, --sso-credential=SSO - path to a COOKIE file with the user credentials, as - generated by the CERN SSO cookie tool (http://linux.we - b.cern.ch/linux/docs/cernssocookie.shtml). MANDATORY - when interacting with the GPN EliSA instance. - -c USERNAME:PASSWORD, --ldap-credential=USERNAME:PASSWORD - user credential in the form USERNAME:PASSWORD or - USERNAME. If only the username is provided, the - password will be asked interactively. - -i ID, --id=ID message unique ID - -b BODY, --body=BODY string with the message body. - -z BODY, --body-file=BODY - path to a file with a text representation of the - message body. - -m PATH, --attachment-file=PATH - path to a file to be attached to the messages. This - option can be used multiple times. - - -elisa_config ------------- -Usage: :: - - elisa_config [options] args - -Options: :: - - -h, --help show this help message and exit - --version print information about program name, version, etc - -v LEVEL, --verbose=LEVEL - sets the verbosity level [0-4] - -s SERVER, --server=SERVER - URL of the EliSA REST server ( i.e. - https://elisa.cern.ch or - http://elisatest.cern.ch:8080). If not specified, the - mainEliSA server in P1 or GPN depending on user - location. - -o SSO, --sso-credential=SSO - path to a COOKIE file with the user credentials, as - generated by the CERN SSO cookie tool (http://linux.we - b.cern.ch/linux/docs/cernssocookie.shtml). MANDATORY - when interacting with the GPN EliSA instance. - -c USERNAME:PASSWORD, --ldap-credential=USERNAME:PASSWORD - user credential in the form USERNAME:PASSWORD or - USERNAME. If only the username is provided, the - password will be asked interactively. - -y TYPE, --type=TYPE message type. - - -examples --------- -First of all, source the latest TDAQ release. - -By default, the utilities connect to the REST server running on pc-atd-elisa.cern.ch, so the -s or --server option does not need to be specified. What you need to provide however, is the SSO credentials used for user authentication. Provided you have a valid kerberos token, the SSO credentials can be created with the CERN SSO cookie tool: -cern-get-sso-cookie --krb -u https://pc-atd-elisa.cern.ch/elisa.api/api -o ~/private/ssocookie.txt - -For further information on the tool, check this link http://linux.web.cern.ch/linux/docs/cernssocookie.shtml - -**elisa_insert** :: - - elisa_insert -o ~/private/ssocookie.txt -a "Raul" -j "Testing elisa_insert" -y "Trigger" -e "SCT, CSC, Pixel, DAQ" -p "Trigger_Area=Trigger Group" -p "Trigger_Area.Trigger_Group=MinBiass" -p "Trigger_Area.Trigger_Group=Calo" -b "Regression test of utility elisa_insert" -x "closed" -v 4 - elisa_insert -o ~/private/ssocookie.txt -a "Raul" -j "Testing elisa_insert with attachment" -y "Run Control" -e "Cryo, Other, RPC, DSS" -p "RunControl_MessageType=problem" -b "Regression test of utility elisa_insert with attachment" -x "open" -m /afs/cern.ch/user/r/rmurillo/public/barcelona.jpg -v 4 - -**elisa_reply** :: - - elisa_reply -o ~/private/ssocookie.txt -i 133036 -a "Raul" -e "SCT, CSC, Pixel, DAQ" -b "Regression test of utility elisa_reply" -x "closed" -v 4 - elisa_reply -o ~/private/ssocookie.txt -i 133037 -a "Raul" -e "Pixel, CSC" -b "Regression test of utility elisa_reply with attachment" -x "open" -m /afs/cern.ch/user/r/rmurillo/public/barcelona.jpg -v 4 - -**elisa_update** :: - - elisa_update -o ~/private/ssocookie.txt -i 133036 -b "Regression test of utility elisa_update" -v 4 - elisa_update -o ~/private/ssocookie.txt -i 133037 -b "Regression test of utility elisa_update with attachment" -m /afs/cern.ch/user/r/rmurillo/public/barcelona.jpg -v 4 - -**elisa_get** :: - - elisa_get -o ~/private/ssocookie.txt -i 133045 -v 4 - elisa_get -o ~/private/ssocookie.txt -v 4 -a "Alina Corso Radu" -l 10 -j "Summary" -e "DAQ" - -**elisa_config** :: - - elisa_config -o ~/private/ssocookie.txt -v 4 - elisa_config -o ~/private/ssocookie.txt -y Trigger -v 4 - elisa_config -o ~/private/ssocookie.txt -y Online -v 4 \ No newline at end of file diff --git a/elisa_client_api b/elisa_client_api new file mode 160000 index 0000000..ea8a7a3 --- /dev/null +++ b/elisa_client_api @@ -0,0 +1 @@ +Subproject commit ea8a7a3f9e0581b67297f8a1dbee3f265f542ed6 diff --git a/pymain/main.py b/pymain/main.py new file mode 100644 index 0000000..9917df2 --- /dev/null +++ b/pymain/main.py @@ -0,0 +1,33 @@ + +def execute_elisa_config_script(): + from elisa_client_api_script import elisa_config + import runpy + runpy.run_module(elisa_config, run_name="__main__") + + +def execute_elisa_get_script(): + from elisa_client_api.bin import elisa_get + import runpy + runpy.run_module(elisa_get, run_name="__main__") + +def execute_elisa_insert_script(): + import elisa_client_api_script + # from elisa_client_api_script import elisa_insert + import runpy + runpy.run_module(elisa_client_api_script.elisa_insert, run_name="__main__") + +def execute_elisa_reply_script(): + from elisa_client_api_script import elisa_reply + import sys + print(sys.path) + import runpy + runpy.run_module(elisa_reply, run_name="__main__") + +def execute_elisa_update_script(): + from elisa_client_api_script import elisa_update + import sys + print(sys.path) + import runpy + runpy.run_module(elisa_update, run_name="__main__") + + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b5dbf4e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "elisa_client_api" +version = "1.0.0" + +[tool.setuptools] +package-dirs = {elisa_client_api_main="pymain", elisa_client_api= "elisa_client_api/python/src", elisa_client_api_scripts= "elisa_client_api/python/bin"} + + +[project.scripts] +elisa_config = "elisa_client_api.main:execute_elisa_config_script" # ... and refer to here. +elisa_get = "elisa_client_api.main:execute_elisa_get_script" +elisa_insert = "elisa_client_api.main:execute_elisa_insert_script" +elisa_reply = "elisa_client_api.main:execute_elisa_reply_script" +elisa_update = "elisa_client_api.main:execute_elisa_update_script" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7c7a05f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,24 +0,0 @@ -[metadata] -name = elisa_client_api -version = attr: elisa_client_api.__version__ -url = https://github.com/DUNE-DAQ/elisa_client_api -# long_description = file: docs/README.md -# long_description_content_type = text/markdown - -[options] -packages = find: -package_dir = =src -include_package_data = true -python_requires = >= 3.6 -# Dependencies are in setup.py for GitHub's dependency graph. - -[options.packages.find] -where = src - -[options.entry_points] -console_scripts = - elisa_config = elisa_client_api.scripts.elisa_config:main - elisa_get = elisa_client_api.scripts.elisa_get:main - elisa_insert = elisa_client_api.scripts.elisa_insert:main - elisa_reply = elisa_client_api.scripts.elisa_reply:main - elisa_update = elisa_client_api.scripts.elisa_update:main diff --git a/setup.py b/setup.py index b657379..fc1f76c 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,3 @@ from setuptools import setup -# Metadata goes in setup.cfg. These are here for GitHub's dependency graph. -setup( - name="elisa_client_api", - install_requires=[ - "requests", - # "urllib", - # "mimetypes", - # "xml", - # "http" - ] -) +setup() \ No newline at end of file diff --git a/src/elisa_client_api/__init__.py b/src/elisa_client_api/__init__.py deleted file mode 100644 index d3ec452..0000000 --- a/src/elisa_client_api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.2.0" diff --git a/src/elisa_client_api/core/__init__.py b/src/elisa_client_api/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/elisa_client_api/core/authentication.py b/src/elisa_client_api/core/authentication.py deleted file mode 100644 index eff3768..0000000 --- a/src/elisa_client_api/core/authentication.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -#-------------------------------------------------------------------------------------- -# Title : ELisA authentication. -# Project : ATLAS, TDAQ, ELisA -#-------------------------------------------------------------------------------------- -# File : authentication.py -# Author : Raul Murillo Garcia, raul.murillo.garcia@cern.ch -# Created : 18/Dec/2012 -# Revision : 0 $ -#-------------------------------------------------------------------------------------- -# Class : Authentication -# Description : Class providing the functionality to perform user authentication -# either using LDAP or SSO. -#-------------------------------------------------------------------------------------- -# Copyright (c) 2012 by University of California, Irvine. All rights reserved. -#-------------------------------------------------------------------------------------- -# Modification history: -# 18/Dec/2012: created. -#-------------------------------------------------------------------------------------- - -from elisa_client_api.exception import ArgumentError - - -class Authentication(object): - """ Interface to the ELisA logbook database. - """ - def __init__(self, username=None, password=None, ssocookie=None): - """ Constructor - - username: user name. - password: password - type: authentication type; either 'ldap' or 'sso'. - ssocookie: file with the sso-cookie created by auth-get-sso-cookie - """ - self.__username = username - self.__password = password - self.__ssocookie = None - - if ssocookie != None: - try: - f = open(ssocookie) - self.__ssocookie = f.read() - f.close() - except IOError as ex: - raise ArgumentError("The cookie containing the sso authentication could not be read: " + str(ex)) - - # Load the cookie - import http.cookiejar - cj = http.cookiejar.MozillaCookieJar() - cj.load(filename=ssocookie, ignore_discard=True, ignore_expires=True) - for cookie in cj: - if cookie.name.startswith('_shibsession'): - self.__ssocookie = cookie.name + '=' + cookie.value - - # ------------------ - # - Public methods - - # ------------------ - def addAuthentication(self, req): - """ Adds the appropriate authentication header in the http request. - """ - if self.__ssocookie != None: - req.add_header('Cookie', self.__ssocookie) - else: - req.add_header("Authorization", "Basic %s" % self._getEncodedCredentials().decode()) - - def addAuthenticationPy3(self, req): - """ Adds the appropriate authentication header in the http request. - """ - if self.__ssocookie != None: - req.headers['Cookie'] = self.__ssocookie - else: - req.headers['Authorization'] = "Basic %s" % self._getEncodedCredentials().decode() - - def addAuthenticationToDict(self, d): - """ Adds the appropriate authentication header in the http request. - """ - - if self.__ssocookie != None: - d['Cookie'] = self.__ssocookie - else: - d['Authorization'] = "Basic %s" % self._getEncodedCredentials().decode() - - - # ------------------- - # - Private methods - - # ------------------- - def _getEncodedCredentials(self): - """ Encodes the string username:password with basic 64 - """ - import base64 - return base64.encodestring(('%s:%s' % (self.__username, self.__password)).encode())[:-1] diff --git a/src/elisa_client_api/core/message.py b/src/elisa_client_api/core/message.py deleted file mode 100644 index 40c96d0..0000000 --- a/src/elisa_client_api/core/message.py +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env python -#-------------------------------------------------------------------------------------- -# Title : Logbook message -# Project : ATLAS, TDAQ, ELisA -#-------------------------------------------------------------------------------------- -# File : message.py -# Author : Raul Murillo Garcia, raul.murillo.garcia@cern.ch -# Created : 27/Nov/2012 -# Revision : 0 $ -#-------------------------------------------------------------------------------------- -# Class : Message -# Description : Class encapsulating all the fields that describe a logbook message. -#-------------------------------------------------------------------------------------- -# Copyright (c) 2012 by University of California, Irvine. All rights reserved. -#-------------------------------------------------------------------------------------- -# Modification history: -# 05/Dec/2012: created. -#-------------------------------------------------------------------------------------- - -from .messageField import SimpleField, AttachmentField, SystemsAffectedField, OptionField - -class Status(object): - """ Helper class to specify the status field. - """ - OPEN = 'open' - CLOSED = 'closed' - - -class Message(object): - """ Class with all the fields of a logbook message. - - Accessors will be provided as needed in derived classes. - """ - # ------------------ - # - Public methods - - # ------------------ - def __init__(self, id): - # --------------------------- - # - Private data attributes - - # --------------------------- - - # The field name parameter is the same as those use in the ELisA server. - # This schema allows for generic code when serializing, deserializing - # and printing the fields. - self._id = SimpleField('id', id) - self._logbook = SimpleField('logbook') - self._username = SimpleField('username') - self._author = SimpleField('author') - self._date = SimpleField('date') - self._subject = SimpleField('subject') - self._message_type = SimpleField('message_type') - self._systems_affected = SystemsAffectedField('systems_affected') - self._options = OptionField('options') - self._body = SimpleField('body') - self._host = SimpleField('host') - self._has_replies = SimpleField('has_replies') - self._reply_to = SimpleField('reply_to') - self._has_attachments = SimpleField('has_attachments') - self._attachments = AttachmentField('attachments') - self._status = SimpleField('status') - self._thread_head = SimpleField('thread_head') - self._valid = SimpleField('valid') - self._encoding = SimpleField('encoding') - - - def __str__(self): - dump = "" - fields = self.getFieldNames() - for field in fields: - dump += str(getattr(self, field)) + '\n' - return dump - - - def getFieldNames(self): - return [attr for attr in dir(self) if getattr(self, attr).__class__.__name__ == "SimpleField" \ - or getattr(self, attr).__class__.__name__ == "AttachmentField" \ - or getattr(self, attr).__class__.__name__ == "OptionField" \ - or getattr(self, attr).__class__.__name__ == "SystemsAffectedField"] - - - def getTag(self): - return "_" - - - # -------------------- - # - Property methods - - # -------------------- - @property - def id(self): - """ Message ID field. """ - return self._id.value - - @property - def logbook(self): - """ Message logbook field. """ - return self._logbook.value - - @property - def userName(self): - """ Message user name field. """ - return self._username.value - - @property - def author(self): - """ Message author field. """ - return self._author.value - - @property - def date(self): - """ Message date field. """ - return self._date.value - - @property - def subject(self): - """ Message subject field. """ - return self._subject.value - - @property - def type(self): - """ Message type field. """ - return self._message_type.value - - @property - def options(self): - """ Message options field. """ - return self._options .value - - @property - def systemsAffected(self): - """ Message systems affected field. """ - return self._systems_affected.value - - @property - def body(self): - """ Message body field. """ - return self._body.value - - @property - def host(self): - """ Message host field. """ - return self._host.value - - @property - def hasReplies(self): - """ Message has replies field. """ - return self._has_replies.value - - @property - def replyTo(self): - """ Message reply to field. """ - return self._reply_to.value - - @property - def hasAttachments(self): - """ Message has attachments field. """ - return self._has_attachments.value - - @property - def attachments(self): - """ Message attachments field. """ - return self._attachments.value - - @property - def status(self): - """ Message status field. """ - return self._status.value - - @property - def threadHead(self): - """ Message thread head field. """ - return self._thread_head.value - - @property - def valid(self): - """ Message valid field. """ - return self._valid.value - - @property - def encoding(self): - """ Message encoding field. """ - return self._encoding.value - - diff --git a/src/elisa_client_api/core/messageField.py b/src/elisa_client_api/core/messageField.py deleted file mode 100644 index 5599174..0000000 --- a/src/elisa_client_api/core/messageField.py +++ /dev/null @@ -1,307 +0,0 @@ -#!/usr/bin/env python -#-------------------------------------------------------------------------------------- -# Title : Logbook message fields -# Project : ATLAS, TDAQ, ELisA -#-------------------------------------------------------------------------------------- -# File : messageField.py -# Author : Raul Murillo Garcia, raul.murillo.garcia@cern.ch -# Created : 05/Dec/2012 -# Revision : 0 $ -#-------------------------------------------------------------------------------------- -# Class : SimpleField, AttachmentField, SystemsAffectedField, OptionField -# Description : Classes providing accessors, serializers, and deserializers for the -# logbook message. -#-------------------------------------------------------------------------------------- -# Copyright (c) 2012 by University of California, Irvine. All rights reserved. -#-------------------------------------------------------------------------------------- -# Modification history: -# 05/Dec/2012: created. -# 23/Jan/2013: use UTF8 for the name and value of the message fields. -#-------------------------------------------------------------------------------------- - -import xml.etree.ElementTree as ET - - -class SimpleField(object): - """ Class providing functionality to define a simple message field. - - Simple message fields are those that only contain the field value - but no nested fields. - - Assume all fields are string type even those that only have numbers - """ - # ------------------ - # - Public methods - - # ------------------ - def __init__(self, name, value = None): - self.__name = name.encode('utf-8') - self.__value = str(value) if value != None else None - - def __str__(self): - return '{0:19}: {1}'.format(self.name.decode('utf-8'), self.value) - - def serialize(self, parentNode): - if self.value: - node = ET.SubElement(parentNode, self.name.decode('utf-8')) - node.text = str(self.value) - - def deserialize(self, node): - self.value = node.text.encode('utf-8').decode('utf-8') - - - # -------------------- - # - Property methods - - # -------------------- - @property - def name(self): - return self.__name - - @property - def value(self): - return self.__value - @value.setter - def value(self, value): - self.__value = value - - # --------------------------- - # - Private data attributes - - # --------------------------- - __name = None - __value = None - - -class SystemsAffectedField(object): - """ Class providing functionality to define the message systems - affected field. - - This field contains a list with the systems affected names. - """ - # Format: - # - # 2 - # DAQ - # HLT - # - - # ------------------ - # - Public methods - - # ------------------ - def __init__(self, name): - # --------------------------- - # - Private data attributes - - # --------------------------- - self.__name = name.encode('utf-8') - self.__value = list() - - def __str__(self): - return '{0:19}: {1}'.format(self.name.decode('utf-8'), self.value) - - def serialize(self, parentNode): - if not self.value: - return - - if len(self.value) > 0: - rootNode = ET.SubElement(parentNode, self.name.decode('utf-8')) - countNode = ET.SubElement(rootNode, 'count') - countNode.text = str(len(self.value)) - for system in self.value: - sysNode = ET.SubElement(rootNode, 'system_affected') - sysNode.text = system - - - def deserialize(self, node): - [self.value.append(child.text.encode('utf-8').decode('utf-8')) for child in node.findall('system_affected')] - - # -------------------- - # - Property methods - - # -------------------- - @property - def name(self): - return self.__name - - @property - def value(self): - return self.__value - @value.setter - def value(self, value): - self.__value = value - - -class AttachmentField(object): - """ Class providing functionality to define the message attachment field. - - This field contains a list of tuples with the following simple fields: - filename, ID and link - """ - # Format: - # - # 1 - # - # foto.jpg - # 0 - # http://example.com/elisa.api/api/messages/200006/attachment/0 - # - # - - # ------------------ - # - Public methods - - # ------------------ - def __init__(self, name): - # --------------------------- - # - Private data attributes - - # --------------------------- - self.__name = name.encode('utf-8') - self.__value = None - - def __str__(self): - if not self.value: - return '{0:19}: 0'.format(self.name.decode('utf-8')) - - dump = '{0:19}: {1}'.format(self.name.decode('utf-8'), len(self.value)) - # Message insertion encapsulates attachments as a list of strings. - # Message retrieval encapsulates attachments as a list of tuples. - if isinstance(self.value[0], str): - for attach in self.value: - dump += '\n |---- {0}'.format(attach) - else: - for attach in self.value: - dump += '\n |---- {0:4}: {1}'.format("ID", attach[0]) - dump += '\n |---- {0:4}: {1}'.format("Name", attach[1]) - dump += '\n |---- {0:4}: {1}'.format("Link", attach[2]) - return dump - - def serialize(self, parentNode): - # Attachments are never serialized because its insertion follows - # a different path. - pass - - def deserialize(self, node): - self.value = list() - [self.__value.append((child.find('ID').text.encode('utf-8').decode('utf-8'), - child.find('filename').text.encode('utf-8').decode('utf-8'), - child.find('link').text.encode('utf-8').decode('utf-8'))) - for child in node.findall('attachment')] - - - # -------------------- - # - Property methods - - # -------------------- - @property - def name(self): - return self.__name - - @property - def value(self): - return self.__value - @value.setter - def value(self, value): - self.__value = value - - -class OptionField(object): - """ Class providing functionality to define the message option field. - - This field contains a list of tuples with the following fields: - name, value, list of OptionField - """ - # Format: - # - # 1 - #