Services#

Submodules#

Git#

exception GitError(error: str)[source]#

Bases: Exception

class GitService(**kwargs: Any)[source]#

Bases: traitlets.config.configurable.Configurable

check_remote_status(origin: str, branch: str) grader_labextension.services.git.RemoteStatus[source]#
clone(origin: str, force=False)[source]#

Clones the repository

Args:

origin (str): the remote force (bool, optional): states if the operation should be forced. Defaults to False.

commit(m='2022-05-25 11:06:35.424568')[source]#

Commits the staged changes

Args:

m (str, optional): the commit message. Defaults to str(datetime.now()).

copy_repo_contents(src: str)[source]#

copies repo contents from src to the git path

Args:

src (str): path where the to be copied files reside

delete_remote(origin: str)[source]#
delete_repo_contents(include_git=False)[source]#

Deletes the contents of the git service

Args:

include_git (bool, optional): states if the .git directory should also be deleted. Defaults to False.

fetch_all()[source]#
get_log(history_count=10) List[Dict[str, str]][source]#

Execute git log command & return the result.

git_access_token#

A trait for unicode strings.

git_service_url#

A trait for unicode strings.

git_status(hidden_files: bool = False) Tuple[List[str], List[str], List[str]][source]#
property git_version#

Return the git version

Returns:

tuple: the git version

init(force=False)[source]#

Initiates a local repository

Args:

force (bool, optional): states if the operation should be forced. Defaults to False.

is_git()[source]#

Checks if the directory is a local repository

Returns:

bool: states if the directory is a repository

local_branch_exists(branch: str) bool[source]#
pull(origin: str, branch='main', force=False)[source]#

Pulls a repository

Args:

origin (str): the remote branch (str, optional): the branch name. Defaults to “main”. force (bool, optional): states if the operation should be forced. Defaults to False.

push(origin: str, force=False)[source]#

Pushes commits on the remote

Args:

origin (str): the remote force (bool, optional): states if the operation should be forced. Defaults to False.

remote_branch_exists(origin: str, branch: str) bool[source]#
set_author(author='docs')[source]#
set_remote(origin: str, sub_id=None)[source]#

Set a remote in the local repository

Args:

origin (str): the remote sub_id ([type], optional): a query param for the feedback pull. Defaults to None.

switch_branch(branch: str)[source]#

Switches into another branch

Args:

branch (str): the branch name

class RemoteStatus(value)[source]#

Bases: enum.Enum

An enumeration.

divergent = 4#
pull_needed = 2#
push_needed = 3#
up_to_date = 1#

Request#

class RequestService(**kwargs: Any)[source]#

Bases: traitlets.config.configurable.LoggingConfigurable

static get_query_string(params: dict) dict[source]#
async request(method: str, endpoint: str, body: Optional[Union[dict, str]] = None, header: Optional[Dict[str, str]] = None, decode_response: bool = True) Union[dict, list, tornado.httpclient.HTTPResponse][source]#
url#

A trait for unicode strings.