semvec/pypi-packages huggingface dataset:
sermos-utils 0.22.1
Sermos Utilities
License: MIT

# Sermos Utils

Utilities for interacting with Sermos.

## Deployments

### Prerequisites

To deploy your application to Sermos, there are a few prerequisites:

1. Deployment environment created and configured
1. An `access key` has been issued for that deployment
1. Your app is a valid Python package with a standard structure (see below)
1. You have a `sermos.yaml` file written with your defined API endpoints, workers, etc.
1. Your application has `sermos-utils` as a dependency and it's installed.

### Deployment

You can initiate a Sermos deployment in two ways: programmatically or using the
CLI tool.

It is recommended to keep your access key in the environment and to set the
client package directory in the environment as well, for convenience.

    SERMOS_ACCESS_KEY=abc123
    SERMOS_CLIENT_PKG_NAME=your_package

#### Programmatic Deployment

Invoking a pipeline programmatically (e.g. as part of a build pipeline) can
be done similar to below (assumes access key/client package directory
are available in the environment per note above).

    from sermos_utils.deploy import SermosDeploy

    sd = SermosDeploy()
    status = sd.invoke_deployment()
    print(status)

#### CLI Deployment

For a cli-based deployment, there is a `sermos_deploy` command installed
as part of the sermos-utils package.

    honcho run -e .env sermos_deploy

### Deployment Status

Assuming your environment is set up per notes in the `Deployment` section above:

#### Programmatic Status Checks

    from sermos_utils.deploy import SermosDeploy

    sd = SermosDeploy()
    status = sd.get_deployment_status()
    print(status)

#### CLI Status Checks

    honcho run -e .env sermos_status

### Proper Python Package Structure

Assuming your package is called "my_sermos_client":

    /path/to/codebase/
        my-sermos-client/
            setup.py
            my_sermos_client/
                __init__.py
                sermos.yaml

`my_sermos_client/__init__.py` has only one requirement, to contain your
application's version assigned as a variable `__version__`, e.g.:

    __version__ = '0.1.0'

Common practice is to use that value in your `setup.py` file, e.g.

    _version_re = re.compile(r'__version__\s+=\s+(.*)')
    with open('my_sermos_client/__init__.py', 'rb') as f:
        __version__ = str(ast.literal_eval(_version_re.search(
            f.read().decode('utf-8')).group(1)))

## Local Development

Sermos provides a local development environment in two ways:

1. Local 'sandbox' environment
1. Cloud-connected environment that proxies into your deployment's databases

See `sermos-utils/dev/README.md` for more information.

## Testing

To run the tests you need to have `pyenv` running on your system and `tox` in
your environment.

Refer to RhoAI documentation for instructions on installing `pyenv` correctly.

After `pyenv` is intalled, then install `tox`

    $ pip install tox

Then install the different python versions in `pyenv`

    $ pyenv install 3.7.4

Now, run the tests:

    $ tox
cli-cqu 0.5.0
CLI CQU 是重庆大学 jxgl 网站的命令行界面。
License: MIT
Requires Python: >=3.7,<4.0

重庆大学（CQU）的命令行客户端

提供以下功能：

- 下载课表
    -   保存为 JSON，便于后续处理（字段定义参考 ``cli_cqu.model`` 模块）
    -   保存为 ICalendar 日历日程，可导入 Outlook 等日历应用
- 查询成绩
    -   通过老教务网的接口获取成绩单

使用
====

在命令行运行可执行程序 ``cli-cqu`` 即可进入 CLI CQU 的交互式 Shell 中，可以采用类似于命令行的操作方式。
进入 REPL 后，提示符被替换为 ``cli cqu>`` 。

第一次运行时，需要输入用户名与密码，分别需要教学管理（jxgl）和老教务网（oldjw）的两个帐号，两个帐号的密码不一定相同，一般来说，老教务网的密码会是初始密码（身份证后 6 位）。
账户信息会保存到本地（ ``~/.config/cli-cqu/account.toml`` ），之后使用时会直接从文件读取，而无需手动输入。如果有更改，需自行修改文件内容。

1. 退出程序::

    exit

2. 查询帮助::

    help [command_name]

当无参数时，此命令会显示程序整体的帮助信息；当后缀一个命令名时，将显示对应命令的帮助信息。

3. 下载课程表（JSON 格式）::

    courses-json filename

将 **当前学期** 的课程表内容下载为 JSON 文件至 filename 所指定的路径。

4. 下载课程表（Ical 格式）::

    courses-ical filename startdate

将 **当前学期** 的课程表内容下载为 ICalendar 日志格式至 filename 所指定的路径。

5. 下载全部成绩（JSON 格式）::

    assignments-json filename

将 **所有学期的全部科目** 的成绩以 JSON 的格式下载至 filename 指定的路径。

安装
====

你可以使用 pip 安装，由于使用了 f-string，需要 python 3.6 以上::

    pip install cli-cqu

或者使用 pipx ::

    pipx install cli-cqu

贡献
====

此项目基于 MIT 协议发行，你可以在遵守协议的情况下做任何事。

下面是本项目各模块的介绍

- ``cli_cqu`` App 对象和命令行接口
    - ``cli_cqu.login`` 模块是登录功能
    - ``cli_cqu.data`` 模块是需要用到的数据，例如常量、路由、解析规则（函数）等。
        - ``cli_cqu.data.ua`` User-Agent。
        - ``cli_cqu.data.js_equality`` 与 jxgl 网页前端的 js 等效的一些函数。
        - ``cli_cqu.data.route`` 路由，根据 jxgl 的功能模块分类
        - ``cli_cqu.data.schedule`` 日程表
    - ``cli_cqu.model`` 数据模型
    - ``cli_cqu.util`` 其他辅助功能