Esempio n. 1
0
def launch(obj, inspect=False, output=None, analyze=False, teachersonly=False, studentsonly=False):
    """
    Launch syncer stuff
    """
    import socket
    hostname = socket.gethostname()
    if 'dragonnet' in hostname:
        from psmdlsyncer.models.datastores.moodle import MoodleTree
        from psmdlsyncer.models.datastores.autosend import AutoSendTree
        from psmdlsyncer.syncing.templates import MoodleTemplate
        from psmdlsyncer.syncing.differences import DetermineChanges

        # To get the groups right we need to process AutosendTree first and send it over to Moodle

        right = AutoSendTree()
        right.process()
        left = MoodleTree()
        #left.groups.section_maps = {v:k for k, v in right.groups.section_maps.items()}  # items become the keys
        left.process()

        d = DetermineChanges(left, right, MoodleTemplate, teachersonly, studentsonly)

        if output:
            for item in d.subtract():
                output.write(str(item))
                output.write('\n')
            exit()
        if inspect:
            from IPython import embed
            embed()
            exit()
        if analyze:
            keys = list(left.groups.section_maps.keys)
            print(keys)
            from IPython import embed;embed()
            ss = [k for k in keys if left.groups.get_key(k).idnumber.endswith('S')]
            for s in ss:
                swa = s + 'WA1'
                swas1 = [k for k in keys if swa in keys[k]]
                print(swas1)
                swa = s + 'WA2'
                swas2 = [k for k in keys if swa in keys[k]]
                print(swas2)
            exit()
        d.go()

    elif 'student' in hostname:
        from psmdlsyncer.models.datastores.autosend import AutoSendTree
        autosend = AutoSendTree()
        autosend.process()
        autosend.build_automagic_emails(make_new_students=True)
        autosend.output_all_aliases()
        autosend.run_newaliases()

    else:
        print("Can't run, is the hostname wrong?")
Esempio n. 2
0
def output_bulk_email_json():
    from psmdlsyncer.models.datastores.autosend import AutoSendTree
    autosend = AutoSendTree()
    autosend.process()
    autosend.build_automagic_emails()
    autosend.output_json()
from psmdlsyncer.settings import config,  config_get_section_attribute

from psmdlsyncer.models.datastores.autosend import AutoSendTree

if __name__ == "__main__":

		autosend = AutoSendTree()
		autosend.process()
		autosend.build_automagic_emails()