Skip to content

Commit 727c833

Browse files
Docker implementation and small fixes (#59)
+ add Dockerfile and build instruction + add example files for `--list` flag + update requirements.txt for Docker + fix errors in invites_parser.py
1 parent 5f3028e commit 727c833

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.10-slim
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
6+
7+
COPY . /app
8+
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
ENV GIT_PYTHON_GIT_EXECUTABLE=/usr/bin/git
12+
13+
ENTRYPOINT ["python", "main.py"]

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
pip install -r requirements.txt
1010
```
1111

12+
## Docker run
13+
1. Build via:
14+
``` bash
15+
docker build -t checking_repo .
16+
```
17+
18+
2. Run via:
19+
``` bash
20+
docker run -v $(pwd)/output:/app/output checking_repo [--invites] [--commites] [--etc...] -t <insert_token> -l <insert_list> -o ./output/res.csv
21+
```
22+
23+
1224
## Запуск приложения:
1325
1. Логирование commits
1426
```commandline
@@ -32,6 +44,7 @@ python3 main.py [-w, --wikis] [-t, --token] token (github токен вмест
3244
```
3345

3446

47+
3548
## Получение токена для работы с Google таблицей:
3649
Сначала нужно создать проект на сайте [Google Cloud](https://console.cloud.google.com/). Выбираем название проекта, жмем на кнопку "Create".
3750

invites_parser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
import json
55
from time import sleep
66
from github import Github, Repository, GithubException, PullRequest
7+
import csv
78

89
FIELDNAMES = ('repository name', 'invited login', 'invite creation date', 'invitation url')
910

10-
def log_inviter(repo, invite):
11+
def log_inviter(repo, invite, writer):
1112
invite_info = [repo.full_name, invite.invitee.login, invite.created_at.strftime("%d/%m/%Y, %H:%M:%S"), invite.html_url]
1213
writer.writerow(invite_info)
1314
print(invite_info)
1415

1516

16-
def log_invitations(client: Github, working_repos, csv_name):
17+
def log_invitations(client: Github, working_repos, csv_name, timedelta=1):
1718
with open(csv_name, 'w', newline='') as file:
1819
writer = csv.writer(file)
1920
writer.writerow(FIELDNAMES)
@@ -22,7 +23,7 @@ def log_invitations(client: Github, working_repos, csv_name):
2223
invitations = repo.get_pending_invitations()
2324
for invite in invitations:
2425
try:
25-
log_inviter(repo, invite)
26+
log_inviter(repo, invite, writer)
2627
sleep(timedelta)
2728
except Exception as e:
2829
print(e)

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def parse_args():
2020
parser.add_argument("--forks_include", help="logging data from forks", action="store_true")
2121
parser.add_argument("-e", "--export_google_sheets", help="export table to google sheets", action="store_true")
2222
parser.add_argument('-t', '--token', type=str, required=True, help='token github account')
23-
parser.add_argument('-l', '--list', type=str, required=True, help='repos names file')
23+
parser.add_argument('-l', '--list', type=str, required=True, help='Path to the file containing the list of repositories. Repositories should be separated by a line break. Names should be in the format <organization or owner>/<name> ')
2424
parser.add_argument("--download_repos", type=str, help="path to downloaded repositories", default='./')
2525
parser.add_argument('-o', '--out', type=str, required=True, help='output filename')
2626
parser.add_argument('-s', '--start', type=str, required=False, help='start time', default='2000/01/01-00:00:00')

requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GitPython==3.1.41
2-
PyGithub~=1.55
3-
pygsheets==2.0.5
4-
pandas==1.4.3
5-
pytz~=2023.3
6-
requests~=2.31.0
2+
PyGithub==2.4.0
3+
pygsheets==2.0.6
4+
pandas==2.2.3
5+
pytz==2024.2
6+
requests==2.32.3

0 commit comments

Comments
 (0)