github-monitor 1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of github-monitor might be problematic. Click here for more details.

@@ -0,0 +1,477 @@
1
+ Metadata-Version: 2.4
2
+ Name: github_monitor
3
+ Version: 1.9
4
+ Summary: Tool implementing real-time tracking of Github users activities including profile and repositories changes
5
+ Author-email: Michal Szymanski <misiektoja-pypi@rm-rf.ninja>
6
+ License-Expression: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/misiektoja/github_monitor
8
+ Project-URL: Source, https://github.com/misiektoja/github_monitor
9
+ Project-URL: Changelog, https://github.com/misiektoja/github_monitor/blob/main/RELEASE_NOTES.md
10
+ Keywords: github,monitoring,tracking,real-time,osint,pygithub
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Operating System :: MacOS :: MacOS X
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: PyGithub>=2.3.0
20
+ Requires-Dist: requests>=2.0
21
+ Requires-Dist: python-dateutil>=2.8
22
+ Requires-Dist: pytz>=2020.1
23
+ Requires-Dist: tzlocal>=4.0
24
+ Requires-Dist: python-dotenv>=0.19
25
+ Dynamic: license-file
26
+
27
+ # github_monitor
28
+
29
+ github_monitor is a tool for real-time monitoring of GitHub users' activities, including profile and repository changes.
30
+
31
+ <a id="features"></a>
32
+ ## Features
33
+
34
+ - Real-time tracking of GitHub users' activities, including profile and repository changes:
35
+ - new GitHub events for the user like new pushes, PRs, issues, forks, releases, reviews etc.
36
+ - repository changes such as updated stargazers, watchers, forks, issues, PRs, description and repo update dates
37
+ - added/removed followings and followers
38
+ - added/removed starred repositories
39
+ - added/removed public repositories
40
+ - changes in user name, email, location, company, bio and blog URL
41
+ - detection of account changes
42
+ - Email notifications for different events (new GitHub events, changed followings, followers, repositories, user name, email, location, company, bio, blog URL etc.)
43
+ - Saving all user activities with timestamps to the CSV file
44
+ - Clickable GitHub URLs printed in the console & included in email notifications (repos, PRs, commits, issues, releases etc.)
45
+ - Possibility to control the running copy of the script via signals
46
+ - Support for Public Web GitHub and GitHub Enterprise
47
+
48
+ <p align="center">
49
+ <img src="https://raw.githubusercontent.com/misiektoja/github_monitor/refs/heads/main/assets/github_monitor.png" alt="github_monitor_screenshot" width="100%"/>
50
+ </p>
51
+
52
+ <a id="table-of-contents"></a>
53
+ ## Table of Contents
54
+
55
+ 1. [Requirements](#requirements)
56
+ 2. [Installation](#installation)
57
+ * [Install from PyPI](#install-from-pypi)
58
+ * [Manual Installation](#manual-installation)
59
+ 3. [Quick Start](#quick-start)
60
+ 4. [Configuration](#configuration)
61
+ * [Configuration File](#configuration-file)
62
+ * [GitHub Personal Access Token](#github-personal-access-token)
63
+ * [GitHub API URL](#github-api-url)
64
+ * [Events to Monitor](#events-to-monitor)
65
+ * [Time Zone](#time-zone)
66
+ * [SMTP Settings](#smtp-settings)
67
+ * [Storing Secrets](#storing-secrets)
68
+ 5. [Usage](#usage)
69
+ * [Monitoring Mode](#monitoring-mode)
70
+ * [Listing Mode](#listing-mode)
71
+ * [Email Notifications](#email-notifications)
72
+ * [CSV Export](#csv-export)
73
+ * [Check Intervals](#check-intervals)
74
+ * [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix)
75
+ * [Coloring Log Output with GRC](#coloring-log-output-with-grc)
76
+ 6. [Change Log](#change-log)
77
+ 7. [License](#license)
78
+
79
+ <a id="requirements"></a>
80
+ ## Requirements
81
+
82
+ * Python 3.10 or higher
83
+ * Libraries: [PyGithub](https://github.com/PyGithub/PyGithub), `requests`, `python-dateutil`, `pytz`, `tzlocal`, `python-dotenv`
84
+
85
+ Tested on:
86
+
87
+ * **macOS**: Ventura, Sonoma, Sequoia
88
+ * **Linux**: Raspberry Pi OS (Bullseye, Bookworm), Ubuntu 24, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
89
+ * **Windows**: 10, 11
90
+
91
+ It should work on other versions of macOS, Linux, Unix and Windows as well.
92
+
93
+ <a id="installation"></a>
94
+ ## Installation
95
+
96
+ <a id="install-from-pypi"></a>
97
+ ### Install from PyPI
98
+
99
+ ```sh
100
+ pip install github_monitor
101
+ ```
102
+
103
+ <a id="manual-installation"></a>
104
+ ### Manual Installation
105
+
106
+ Download the *[github_monitor.py](https://raw.githubusercontent.com/misiektoja/github_monitor/refs/heads/main/github_monitor.py)* file to the desired location.
107
+
108
+ Install dependencies via pip:
109
+
110
+ ```sh
111
+ pip install PyGithub requests python-dateutil pytz tzlocal python-dotenv
112
+ ```
113
+
114
+ Alternatively, from the downloaded *[requirements.txt](https://raw.githubusercontent.com/misiektoja/github_monitor/refs/heads/main/requirements.txt)*:
115
+
116
+ ```sh
117
+ pip install -r requirements.txt
118
+ ```
119
+
120
+ <a id="quick-start"></a>
121
+ ## Quick Start
122
+
123
+ - Grab your [GitHub personal access token](#github-personal-access-token) and track the `github_username` activities:
124
+
125
+
126
+ ```sh
127
+ github_monitor <github_username> -t "your_github_classic_personal_access_token"
128
+ ```
129
+
130
+ Or if you installed [manually](#manual-installation):
131
+
132
+ ```sh
133
+ python3 github_monitor.py <github_username> -t "your_github_classic_personal_access_token"
134
+ ```
135
+
136
+ To get the list of all supported command-line arguments / flags:
137
+
138
+ ```sh
139
+ github_monitor --help
140
+ ```
141
+
142
+ <a id="configuration"></a>
143
+ ## Configuration
144
+
145
+ <a id="configuration-file"></a>
146
+ ### Configuration File
147
+
148
+ Most settings can be configured via command-line arguments.
149
+
150
+ If you want to have it stored persistently, generate a default config template and save it to a file named `github_monitor.conf`:
151
+
152
+ ```sh
153
+ github_monitor --generate-config > github_monitor.conf
154
+
155
+ ```
156
+
157
+ Edit the `github_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
158
+
159
+ <a id="github-personal-access-token"></a>
160
+ ### GitHub Personal Access Token
161
+
162
+ Go to your GitHub Apps settings: [https://github.com/settings/apps](https://github.com/settings/apps)
163
+
164
+ Then click **Personal access tokens → Tokens (classic) → Generate new token (classic)**.
165
+
166
+ Provide the `GITHUB_TOKEN` secret using one of the following methods:
167
+ - Pass it at runtime with `-t` / `--github-token`
168
+ - Set it as an [environment variable](#storing-secrets) (e.g. `export GITHUB_TOKEN=...`)
169
+ - Add it to [.env file](#storing-secrets) (`GITHUB_TOKEN=...`) for persistent use
170
+
171
+ Fallback:
172
+ - Hard-code it in the code or config file
173
+
174
+ If you store the `GITHUB_TOKEN` in a dotenv file you can update its value and send a `SIGHUP` signal to the process to reload the file with the new token without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
175
+
176
+ <a id="github-api-url"></a>
177
+ ### GitHub API URL
178
+
179
+ By default the tool uses Public Web GitHub API URL: [https://api.github.com](https://api.github.com)
180
+
181
+ If you want to use GitHub Enterprise API URL then change `GITHUB_API_URL` (or use `-x` flag) to: https://{your_hostname}/api/v3
182
+
183
+
184
+ <a id="events-to-monitor"></a>
185
+ ### Events to Monitor
186
+
187
+ You can limit the type of events that will be monitored and reported by the tool. You can do it by changing the `EVENTS_TO_MONITOR` configuration option.
188
+
189
+ By default all events are monitored, but if you want to limit it, then remove the `ALL` keyword and leave the events you are interested in, for example:
190
+
191
+ ```
192
+ EVENTS_TO_MONITOR=['PushEvent','PullRequestEvent', 'IssuesEvent', 'ForkEvent', 'ReleaseEvent']
193
+ ```
194
+
195
+ <a id="time-zone"></a>
196
+ ### Time Zone
197
+
198
+ By default, time zone is auto-detected using `tzlocal`. You can set it manually in `github_monitor.conf`:
199
+
200
+ ```ini
201
+ LOCAL_TIMEZONE='Europe/Warsaw'
202
+ ```
203
+
204
+ You can get the list of all time zones supported by pytz like this:
205
+
206
+ ```sh
207
+ python3 -c "import pytz; print('\n'.join(pytz.all_timezones))"
208
+ ```
209
+ <a id="smtp-settings"></a>
210
+ ### SMTP Settings
211
+
212
+ If you want to use email notifications functionality, configure SMTP settings in the `github_monitor.conf` file.
213
+
214
+ Verify your SMTP settings by using `--send-test-email` flag (the tool will try to send a test email notification):
215
+
216
+ ```sh
217
+ github_monitor --send-test-email
218
+ ```
219
+
220
+ <a id="storing-secrets"></a>
221
+ ### Storing Secrets
222
+
223
+ It is recommended to store secrets like `GITHUB_TOKEN` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
224
+
225
+ Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
226
+
227
+ ```sh
228
+ export GITHUB_TOKEN="your_github_classic_personal_access_token"
229
+ export SMTP_PASSWORD="your_smtp_password"
230
+ ```
231
+
232
+ On **Windows Command Prompt** use `set` instead of `export` and on **Windows PowerShell** use `$env`.
233
+
234
+ Alternatively store them persistently in a dotenv file (recommended):
235
+
236
+ ```ini
237
+ GITHUB_TOKEN="your_github_classic_personal_access_token"
238
+ SMTP_PASSWORD="your_smtp_password"
239
+ ```
240
+
241
+ By default the tool will auto-search for dotenv file named `.env` in current directory and then upward from it.
242
+
243
+ You can specify a custom file with `DOTENV_FILE` or `--env-file` flag:
244
+
245
+ ```sh
246
+ github_monitor <github_username> --env-file /path/.env-github_monitor
247
+ ```
248
+
249
+ You can also disable `.env` auto-search with `DOTENV_FILE = "none"` or `--env-file none`:
250
+
251
+ ```sh
252
+ github_monitor <github_username> --env-file none
253
+ ```
254
+
255
+ As a fallback, you can also store secrets in the configuration file or source code.
256
+
257
+ <a id="usage"></a>
258
+ ## Usage
259
+
260
+ <a id="monitoring-mode"></a>
261
+ ### Monitoring Mode
262
+
263
+ To monitor specific user activities and profile changes, simply enter the GitHub username as a command-line argument (`github_username` in the example below):
264
+
265
+ ```sh
266
+ github_monitor github_username
267
+ ```
268
+
269
+ It will track all user profile changes (e.g. changed followers, followings, starred repositories, username, email, bio, location, blog URL, number of repositories) and also all GitHub events (e.g. new pushes, PRs, issues, forks, releases etc.).
270
+
271
+ If you have not set `GITHUB_TOKEN` secret, you can use `-t` flag:
272
+
273
+ ```sh
274
+ github_monitor github_username -t "your_github_classic_personal_access_token"
275
+ ```
276
+
277
+ By default, the tool looks for a configuration file named `github_monitor.conf` in:
278
+ - current directory
279
+ - home directory (`~`)
280
+ - script directory
281
+
282
+ If you generated a configuration file as described in [Configuration](#configuration), but saved it under a different name or in a different directory, you can specify its location using the `--config-file` flag:
283
+
284
+
285
+ ```sh
286
+ github_monitor <github_username> --config-file /path/github_monitor_new.conf
287
+ ```
288
+
289
+ If you want to monitor changes to user's public repositories (e.g. new stargazers, watchers, forks, changed descriptions etc.) then use the `-j` flag:
290
+
291
+ ```sh
292
+ github_monitor github_username -j
293
+ ```
294
+
295
+ If for any reason you do not want to monitor GitHub events for the user (e.g. new pushes, PRs, issues, forks, releases etc.), then use the `-k` flag:
296
+
297
+ ```sh
298
+ github_monitor github_username -k
299
+ ```
300
+
301
+ The tool runs until interrupted (`Ctrl+C`). Use `tmux` or `screen` for persistence.
302
+
303
+ You can monitor multiple GitHub users by running multiple instances of the script.
304
+
305
+ The tool automatically saves its output to `github_monitor_<username>.log` file. It can be changed in the settings via `GITHUB_LOGFILE` configuration option or disabled completely via `DISABLE_LOGGING` / `-d` flag.
306
+
307
+ <a id="listing-mode"></a>
308
+ ### Listing Mode
309
+
310
+ There is another mode of the tool that displays various requested information (`-r`, `-g`, `-f` and `-l` flags).
311
+
312
+ If you want to display a list of public repositories (with some basic statistics) for the user then use the `-r` flag:
313
+
314
+ ```sh
315
+ github_monitor github_username -r
316
+ ```
317
+
318
+ <p align="center">
319
+ <img src="https://raw.githubusercontent.com/misiektoja/github_monitor/refs/heads/main/assets/github_list_of_repos.png" alt="github_list_of_repos" width="90%"/>
320
+ </p>
321
+
322
+ If you want to display a list of repositories starred by the user then use the `-g` flag:
323
+
324
+ ```sh
325
+ github_monitor github_username -g
326
+ ```
327
+
328
+ If you want to display a list of followers and followings for the user then use the `-f` flag.
329
+
330
+ ```sh
331
+ github_monitor github_username -f
332
+ ```
333
+
334
+ If you want to get the list of recent GitHub events for the user then use the `-l` flag. You can also add the `-n` flag to specify how many events should be displayed. By default, it shows the last 5 events.
335
+
336
+ ```sh
337
+ github_monitor github_username -l -n 10
338
+ ```
339
+
340
+ If you want to not only display, but also save the list of recent GitHub events to a CSV file, use the `-l` flag with `-b` indicating the CSV file. As before, you can add the `-n` flag to specify how many events should be displayed/saved:
341
+
342
+ ```sh
343
+ github_monitor github_username -l -n 10 -b github_username.csv
344
+ ```
345
+
346
+ <a id="email-notifications"></a>
347
+ ### Email Notifications
348
+
349
+ To enable email notifications for all user profile changes (e.g. changes in followers, followings, starred repositories, username, email, bio, location, blog URL and number of repositories):
350
+ - set `PROFILE_NOTIFICATION` to `True`
351
+ - or use the `-p` flag
352
+
353
+ ```sh
354
+ github_monitor github_username -p
355
+ ```
356
+
357
+ To receive email notifications when new GitHub events appear for the user (e.g. new pushes, PRs, issues, forks, releases etc.):
358
+ - set `EVENT_NOTIFICATION` to `True`
359
+ - or use the `-s` flag
360
+
361
+ ```sh
362
+ github_monitor github_username -s
363
+ ```
364
+
365
+ To get email notifications when changes in user repositories are detected (e.g. changes in stargazers, watchers, forks, descriptions, etc., except for the update date):
366
+ - set `REPO_NOTIFICATION` to `True`
367
+ - or use the `-q` flag
368
+
369
+ ```sh
370
+ github_monitor github_username -q
371
+ ```
372
+
373
+ To be informed whenever changes in the update date of user repositories are detected:
374
+ - set `REPO_UPDATE_DATE_NOTIFICATION` to `True`
375
+ - or use the `-u` flag
376
+
377
+ ```sh
378
+ github_monitor github_username -u
379
+ ```
380
+
381
+ The last two options (`-q` and `-u`) only work if tracking of repositories changes is enabled (`-j`).
382
+
383
+ To disable sending an email on errors (enabled by default):
384
+ - set `ERROR_NOTIFICATION` to `False`
385
+ - or use the `-e` flag
386
+
387
+ ```sh
388
+ github_monitor github_username -e
389
+ ```
390
+
391
+ You can combine all email notifications flags together if needed.
392
+
393
+ Make sure you defined your SMTP settings earlier (see [SMTP settings](#smtp-settings)).
394
+
395
+ Example email:
396
+
397
+ <p align="center">
398
+ <img src="https://raw.githubusercontent.com/misiektoja/github_monitor/refs/heads/main/assets/github_monitor_email_notifications.png" alt="github_monitor_email_notifications" width="90%"/>
399
+ </p>
400
+
401
+ <a id="csv-export"></a>
402
+ ### CSV Export
403
+
404
+ If you want to save all GitHub user events, profile changes and repository updates to a CSV file, set `CSV_FILE` or use `-b` flag:
405
+
406
+ ```sh
407
+ github_monitor <github_username> -b github_username.csv
408
+ ```
409
+
410
+ The file will be automatically created if it does not exist.
411
+
412
+ <a id="check-intervals"></a>
413
+ ### Check Intervals
414
+
415
+ If you want to customize the polling interval, use `-c` flag (or `GITHUB_CHECK_INTERVAL` configuration option):
416
+
417
+ ```sh
418
+ github_monitor <github_username> -c 900
419
+ ```
420
+
421
+ It is generally not recommended to use values lower than 10 minutes as new events are very often delayed by GitHub API.
422
+
423
+ <a id="signal-controls-macoslinuxunix"></a>
424
+ ### Signal Controls (macOS/Linux/Unix)
425
+
426
+ The tool has several signal handlers implemented which allow to change behavior of the tool without a need to restart it with new configuration options / flags.
427
+
428
+ List of supported signals:
429
+
430
+ | Signal | Description |
431
+ | ----------- | ----------- |
432
+ | USR1 | Toggle email notifications for all user's profile changes (-p) |
433
+ | USR2 | Toggle email notifications for new GitHub events (-s) |
434
+ | CONT | Toggle email notifications for user's repositories changes (except for update date) (-q) |
435
+ | PIPE | Toggle email notifications for user's repositories update date changes (-u) |
436
+ | TRAP | Increase the user check interval (by 1 min) |
437
+ | ABRT | Decrease the user check interval (by 1 min) |
438
+ | HUP | Reload secrets from .env file |
439
+
440
+ Send signals with `kill` or `pkill`, e.g.:
441
+
442
+ ```sh
443
+ pkill -USR1 -f "github_monitor <github_username>"
444
+ ```
445
+
446
+ As Windows supports limited number of signals, this functionality is available only on Linux/Unix/macOS.
447
+
448
+ <a id="coloring-log-output-with-grc"></a>
449
+ ### Coloring Log Output with GRC
450
+
451
+ You can use [GRC](https://github.com/garabik/grc) to color logs.
452
+
453
+ Add to your GRC config (`~/.grc/grc.conf`):
454
+
455
+ ```
456
+ # monitoring log file
457
+ .*_monitor_.*\.log
458
+ conf.monitor_logs
459
+ ```
460
+
461
+ Now copy the [conf.monitor_logs](https://raw.githubusercontent.com/misiektoja/github_monitor/refs/heads/main/grc/conf.monitor_logs) to your `~/.grc/` and log files should be nicely colored when using `grc` tool.
462
+
463
+ Example:
464
+
465
+ ```sh
466
+ grc tail -F -n 100 github_monitor_<username>.log
467
+ ```
468
+
469
+ <a id="change-log"></a>
470
+ ## Change Log
471
+
472
+ See [RELEASE_NOTES.md](https://github.com/misiektoja/github_monitor/blob/main/RELEASE_NOTES.md) for details.
473
+
474
+ <a id="license"></a>
475
+ ## License
476
+
477
+ Licensed under GPLv3. See [LICENSE](https://github.com/misiektoja/github_monitor/blob/main/LICENSE).
@@ -0,0 +1,7 @@
1
+ github_monitor.py,sha256=HF9AUmmKgUHbFOZ2ZALwBmgaYpZtW2O0oZ6COkapDcU,113750
2
+ github_monitor-1.9.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ github_monitor-1.9.dist-info/METADATA,sha256=Bm-ShFGh4fboSEZR_LqiIVLCjPOYhqKrAAZj2g6n2pY,16539
4
+ github_monitor-1.9.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
5
+ github_monitor-1.9.dist-info/entry_points.txt,sha256=hV03y00u1L16S5BwBSLQvFsZcL2WGRtjzlrmu9U9SN0,55
6
+ github_monitor-1.9.dist-info/top_level.txt,sha256=HDN2988ydvH9JZT32PushzqrcD05Q5qg960vgHGIaI8,15
7
+ github_monitor-1.9.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ github_monitor = github_monitor:main