Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 5c9d156c authored by Paul Arthur's avatar Paul Arthur
Browse files

Clean up packaging

* Remove autotools packaging
* Actually put things in a package
* Fix package name
* Fix package version
* Install scripts using entry points
* Remove google_check_status
* Fix tests
parent 0303f645
__pycache__
*.pyc
venv
.eggs
Collab_Admin_Kit.egg-info
*.egg-info
VERSION
......@@ -9,6 +9,6 @@ test:
before_script:
- pip install virtualenv
- ./init.sh
- export PATH=$PATH:./tests
- export PATH=./tests:$PATH
script:
- ./venv/bin/python setup.py pytest
- ./venv/bin/python setup.py test
dist_bin_SCRIPTS = collab_create_shared.py collab_reset_shared.py discussions_create_group.py google_archive_data.py google_build_fitbitstudy.py google_sift_drive.py google_transfer_drive.py google_sift_labels.py google_transfer_mail.py google_check_status.py
EXTRA_DIST = packaging/rpm/collab-admin-kit.spec
rpm: dist-xz
rpmbuild -ta $(distdir).tar.xz
......@@ -3,4 +3,4 @@
hacking_dir=$(readlink -fn $(dirname "$BASH_SOURCE"))
VIRTUAL_ENV_DISABLE_PROMPT=1
. $hacking_dir/venv/bin/activate
PATH=$PATH:`pwd`/tests
PATH=$hacking_dir/tests:$PATH
#!/usr/bin/env python3
import argparse
import json
import re
import requests
import sys
def main():
helptext = '''examples:
google-check-status
google-check-status --json {json}
'''
parser = argparse.ArgumentParser(
description='Checks status of Google services.',
epilog=helptext,
formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument(
'--json',
'-j',
help='JSON to use in place of that fetched from Google. '
'Useful for testing.',
default=False
)
args = parser.parse_args()
if args.json:
statusJSON = json.loads(args.json)
else:
fails = 0
for n in range(3):
try:
r = requests.get(
'http://www.google.com/appsstatus/json/en'
)
if r.status_code == 200:
pageData = r.text
break
else:
continue
except HTTPError as e:
print(e.text)
continue
else:
print('Unable to fetch data from Google Status page.')
exit(3)
# Build a regex object to 'convert' the returned JSONP to JSON.
regex = re.compile("\((.+)\);$")
search = regex.search(pageData)
statusJSON = json.loads(search.groups()[0])
# Create a dictionary of available service names
services = {}
for service in statusJSON['services']:
services[service['id']] = service['name']
# Iterate through ['messages'] and see if there's an outage.
disruptions = False
for message in statusJSON['messages']:
if message['resolved'] == 'false':
print("[{}] {}".format(
services[message['service']],
message['message']
)
)
disruptions = True
if disruptions:
sys.exit(1)
else:
print('No issues reported for GSuite services.')
sys.exit(0)
if __name__ == '__main__':
main()
Summary: Administrative scripts for Collaboration Services at UM
Name: @PACKAGE_NAME@
Version: @PACKAGE_VERSION@
Release: 0%{?dist}
License: MIT
Group: Applications/Internet
URL: https://gitlab.umich.edu/carleski/collab-admin-kit
Source0: %{name}-%{version}.tar.xz
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: setup
%description
Collab Admin Kit is a package of python scripts for performing various adminstrative actions in the University of Michigan collaboration space.
%prep
%setup
%build
%configure
%install
make DESTDIR=%{buildroot} install
%files
%defattr(-,root,root,-)
%{_bindir}/*
%changelog
* %(date "+%a %b %d %Y") (Automated RPM build) - %{version}-%{release}
- See git log for actual changes.
[aliases]
test=pytest
[tool:pytest]
addopts=-v --pep8
pep8maxlinelength=160
......@@ -23,7 +23,7 @@ test_deps = [
]
setup(
name='Collab Admin Kit',
name='collab_admin_kit',
version=version,
description='Administrative scripts for GSuite, Box, and others.',
long_description=long_description,
......@@ -33,7 +33,22 @@ setup(
author_email='carleski@umich.edu',
license='MIT',
python_requires='>=3',
packages=find_packages(),
packages=[
'collab_admin_kit',
],
entry_points={
'console_scripts': [
'collab_create_shared=collab_admin_kit.create_shared:main',
'collab_reset_shared=collab_admin_kit.reset_shared:main',
'discussions_create_group=collab_admin_kit.create_group:main',
'google_archive_data=collab_admin_kit.archive_data:main',
'google_build_fitbitstudy=collab_admin_kit.fitbit:main',
'google_sift_drive=collab_admin_kit.sift_drive:main',
'google_sift_labels=collab_admin_kit.sift_labels:main',
'google_transfer_drive=collab_admin_kit.transfer_drive:main',
'google_transfer_mail=collab_admin_kit.transfer_mail:main',
],
},
install_requires=[
'boxsdk[jwt]',
'kadmin',
......
import google_archive_data
from collab_admin_kit import archive_data
import os
import yaml
......@@ -8,7 +8,7 @@ args = {
'lookback': 2,
'drive_folder': 'Google Domain Reports'
}
archiver = google_archive_data.Archiver(
archiver = archive_data.Archiver(
args,
yaml.load(open(config), Loader=yaml.BaseLoader)
)
......@@ -55,7 +55,7 @@ def test_log_logins_custom_lookback():
'lookback': 10,
'drive_folder': 'Google Domain Reports'
}
archiver = google_archive_data.Archiver(
archiver = archive_data.Archiver(
args,
yaml.load(open(config), Loader=yaml.BaseLoader)
)
......@@ -69,7 +69,7 @@ def test_log_new_log_dir():
'lookback': 2,
'drive_folder': 'New Log Folder'
}
google_archive_data.Archiver(
archive_data.Archiver(
args,
yaml.load(open(config), Loader=yaml.BaseLoader)
)
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