def create_report(): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'Canvas') account_id = getattr(settings, 'RESTCLIENTS_CANVAS_ACCOUNT_ID') term = Terms().get_term_by_sis_id('2013-autumn') report_client = Reports() report = report_client.create_course_sis_export_report( account_id, term.term_id) print('Report created. Report ID: %s, progress: %s%%' % ( report.report_id, report.progress)) # Fetch the report data. This method will poll Canvas until the # report has been generated, and then download the data file data = report_client.get_report_data(report) # Do something with the data... # Delete the report report_client.delete_report(report)
def get_all_terms(): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'Canvas') canvas = Terms() for term in canvas.get_all_terms(): print(term.name)
def get_groups_owned_by(uwnetid): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'GWS') from uw_gws import GWS client = GWS() for group in client.search_groups(owner=uwnetid): print(group)
def get_members(group_id): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'GWS') from uw_gws import GWS client = GWS() for member in client.get_members(group_id): print(member.name)
def get_courses(): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'Canvas') account_id = getattr(settings, 'RESTCLIENTS_CANVAS_ACCOUNT_ID') params = {'per_page': 100} canvas = Courses() for course in canvas.get_courses_in_account(account_id, params): print(course.name)
def test_context(self): use_configparser_backend(config_path, "Section1") self.assertTrue(settings.DEBUG) with self.assertRaises(Exception): settings.OTHER with override_settings(DEBUG="What!", OTHER="Also"): debug = settings.DEBUG other = settings.OTHER self.assertEquals(debug, "What!") self.assertEquals(other, "Also") self.assertTrue(settings.DEBUG) with self.assertRaises(Exception): settings.OTHER
def test_decorator(self): use_configparser_backend(config_path, "Section1") self.assertTrue(settings.DEBUG) with self.assertRaises(Exception): settings.OTHER @override_settings(DEBUG="What!", OTHER="Also") def get_overridden(): return settings.DEBUG, settings.OTHER debug, other = get_overridden() self.assertEquals(debug, "What!") self.assertEquals(other, "Also") self.assertTrue(settings.DEBUG) with self.assertRaises(Exception): settings.OTHER
def update_members(group_id, file_path, act_as=None): try: use_django_backend() except ImportError: settings = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings, 'GWS') members = [] with open(file_path, 'r') as f: for line in f: members.append( GroupEntity(name=line.strip(), type=GroupEntity.UWNETID_TYPE)) client = GWS(act_as=act_as, log_errors=True) errors = client.update_members(group_id, members) if len(errors): print(errors)
def test_invalid(self): use_configparser_backend(config_path, "Section1") with self.assertRaises(Exception): settings.MISSING_KEY_FOR_TESTING
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == "__main__": path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, "MEMCACHED") from nose2 import discover discover()
# This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath( os.path.join(dirname(__file__), "..", "travis-ci", "test.conf")) use_configparser_backend(path, 'ADSEL') from nose2 import discover discover()
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, 'Bridge') from nose2 import discover discover()
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == "__main__": path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, "GCS") from nose2 import discover discover()
# This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath( os.path.join(dirname(__file__), "..", "travis-ci", "test.conf")) use_configparser_backend(path, 'Canvas') from nose2 import discover discover()
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, 'Mailman') from nose2 import discover discover()
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, 'Sdbmyuw') from nose2 import discover discover()
import socketserver import sys from mysql_wire_framework.server import FrameworkServer from commonconf.backends import use_configparser_backend use_configparser_backend("./demo/server.cfg", "server") host = "localhost" port = int(sys.argv[1]) server = socketserver.TCPServer((host, port), FrameworkServer) server.serve_forever()
def test_valid(self): use_configparser_backend(config_path, "Section1") value = settings.DEBUG
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, 'Trumba') from nose2 import discover discover()
# This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath( os.path.join(dirname(__file__), "..", "travis-ci", "test.conf")) use_configparser_backend(path, 'Panopto') from nose2 import discover discover()
# Copyright 2022 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, 'GWS') from nose2 import discover discover()
def test_default_value(self): use_configparser_backend(config_path, "Section1") value = getattr(settings, "MISSING_KEY_FOR_TESTING", "OK") self.assertEquals(value, "OK")
# This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "travis-ci", "test.conf")) use_configparser_backend(path, 'R25') from nose2 import discover discover()
# Copyright 2022 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath( os.path.join(dirname(__file__), "..", "travis-ci", "test.conf")) use_configparser_backend(path, 'accountsynchr') from nose2 import discover discover()
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 # This is just a test runner for coverage from commonconf.backends import use_configparser_backend from os.path import abspath, dirname import os if __name__ == '__main__': path = abspath(os.path.join(dirname(__file__), "..", "conf", "test.conf")) use_configparser_backend(path, 'AWS_SQS') from nose2 import discover discover()
def run(update): message = '' changed = reconcile_account_users(update=update) # Main account if len(changed): message += make_message('UW Zoom Main', changed) for account in get_sub_accounts(): changed = reconcile_account_users(account, update=update) if len(changed): message += make_message(account.account_name, changed) if len(message): message = ('\nThese Zoom users have been downgraded from ' 'Pro to Basic:{}\n\n').format(message) if update: notify_admins(message) else: print(message) if __name__ == '__main__': settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'ZOOM') parser = ArgumentParser() parser.add_argument( '--update', action='store_true', default=False, help='Updates users') args = parser.parse_args() run(args.update)