fixed errors

parent 81dfbe88
......@@ -36,9 +36,9 @@ class GitlabClassHelper:
url = self.path + '/groups?name=%s&path=%s&parent_id=%d&visibility=private' % (group_name, group_path, id_of_parent_group)
resp = requests.post(url, headers=self.headers)
if resp.ok:
idx = resp.json()[0]['id']
idx = resp.json()['id']
self.group_id = idx
web_url = resp.json()[0]['web_url']
web_url = resp.json()['web_url']
print('Created the "%s" group in gitlab.' % group_name)
print('web_url to the group: %s' % web_url)
print('Id of the group: %d' % idx)
......@@ -59,7 +59,7 @@ class GitlabClassHelper:
"""
Create a repository in the group with id
"""
url = '/projects?name=%s&namespace_id=%d' % (repo_name, group_id)
url = self.path + '/projects?name=%s&namespace_id=%d' % (repo_name, group_id)
resp = requests.post(url, headers=self.headers)
if resp.ok:
print('Created project "%s" in "%s".' % (repo_name, group_name))
......@@ -112,7 +112,7 @@ class GitlabClassHelper:
"""
Add user to given repository
"""
url = '/projects/%d/members?user_id=%d&access_level=30' % (repo_id, user_id)
url = self.path + '/projects/%d/members?user_id=%d&access_level=30' % (repo_id, user_id)
resp = requests.post(url, headers=self.headers)
if resp.ok:
print('Added "%d" to the project "%s".' % (user_id, repo_name))
......@@ -159,7 +159,7 @@ class GitlabClassHelper:
if len(resp.json()) == 1:
idx = resp.json()[0]['id']
self.group_id = idx
web_url = resp.json()['web_url']
web_url = resp.json()[0]['web_url']
print('Entering the "%s" group in gitlab.' % group_name)
print('web_url to the group: %s' % web_url)
print('Id of the group: %d' % idx)
......@@ -176,9 +176,10 @@ class GitlabClassHelper:
"""
use_group_id, _ = self.check_group_id(group_id)
for repo in repositories:
local_path = os.path.join(local_path_to_fetch_to, repo)
repo_id = self.get_repo_id(repo, use_group_id)
self.clone_repo(local_path_to_fetch_to, repo_id)
print('Cloned the repository "%s" to "%s"' % (repo, local_path_to_fetch_to))
self.clone_repo(local_path, repo_id)
print('Cloned the repository "%s" to "%s"' % (repo, local_path))
def clone_repo(self, local_folder: str, project_id: int):
"""
......
Interactive python interpreter.
$ cat assignment1.csv
repository userid
hw1-adam adam_id
hw1-birger birger_id
repository,userid
hw1-adam,adam_id
hw1-birger,birger_id
# First assignment
......@@ -13,7 +13,7 @@ Python 3.x.x ...
>>> import config
>>> import pandas as pd
>>> from gitlab_class_helper import GitlabClassHelper
>>> class_helper = GitlabClassHelper("http://source.coderefinery.org/api/v4", config.public_access_token)
>>> class_helper = GitlabClassHelper('https://source.coderefinery.org/api/v4', config.PersonalAcessToken)
Initialized connection to gitlab instance.
Personal access token works.
>>> class_helper.create_class(
......@@ -55,7 +55,7 @@ Python 3.x.x ...
>>> class_helper = GitlabClassHelper("source.coderefinery.org", config.public_access_token)
Initialized connection to gitlab instance.
Personal access token works.
>>> class_helper.enter_gitlab_class(
>>> class_helper.enter_class(
group_name = "test-rmurv2",
id_of_parent_group = x)
Entered the "test-rmurv2" group in gitlab.
......@@ -63,14 +63,14 @@ Full path to the group: xxxxxxxxxx.
Id of the group: 123.
>>> list_of_repo_names = pd.read_csv("assignment1.csv")
>>> class_helper.clone_repositories(
repositories = list_of_repo_names['repositories'],
repositories = list_of_repo_names['repository'],
local_path_to_fetch_to = "assignment1/studentresponses/")
Working in group: 123 - "test-rmurv2".
Cloned the repository "hw1-adam" to "assignment1/studentresponses/hw1-adam".
Cloned the repository "hw1-birger" to "assignment1/studentresponses/hw1-birger".
>>> # Grade assignments / provide feedback.
>>> class_helper.push_repositories(
repositories = list_of_repo_names['repositories'],
repositories = list_of_repo_names['repository'],
local_path_to_fetch_to = "assignment1/studentresponses/")
Working in group: 123 - "test-rmurv2".
Pushed the repository "assignment1/studentresponses/hw1-adam" to "hw1-adam".
......@@ -93,7 +93,7 @@ Python 3.x.x ...
>>> class_helper = GitlabClassHelper("source.coderefinery.org", config.public_access_token)
Initialized connection to gitlab instance.
Personal access token works.
>>> class_helper.enter_gitlab_class(
>>> class_helper.enter_class(
group_name = "test-rmurv2",
id_of_parent_group = x)
Entered the "test-rmurv2" group in gitlab.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment