-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab-scheduled-when.py
More file actions
executable file
·38 lines (32 loc) · 1.2 KB
/
gitlab-scheduled-when.py
File metadata and controls
executable file
·38 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env python3
import argparse
import gitlab
from cron_descriptor import get_description
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--server", nargs="?")
parser.add_argument("--project", "-p")
parser.add_argument("--use-config", "-c", action="store_true")
args = parser.parse_args()
# If we're using a configuration, load it into args and re-parse to override the settings
if args.use_config:
import configparser, git
repo = git.Repo(search_parent_directories=True)
with repo.config_reader() as config:
for key in ("server", "project"):
try:
value = config.get("ross-tools", key)
setattr(args, key, value)
except configparser.NoOptionError:
pass
args = parser.parse_args(namespace=args)
gl = gitlab.Gitlab.from_config(args.server)
gl.auth()
project = gl.projects.get(args.project)
scheds = project.pipelineschedules.list()
for sched in scheds:
if not sched.active:
continue
print(sched.description)
print(get_description(sched.cron))
print()