def __init__(self): """ Does the work of reading in basic information from file, creates native Python structures StudentNumber\tHomeroom\tLastFirst\tguardianemails """ self.settings = define_command_line_arguments( 'verbose', 'log_level', 'dry_run', 'teachers', 'courses', 'students', 'email_list', 'families', 'parents', 'automagic_emails', 'profiles', 'input_okay', 'updaters', 'enroll_cohorts', 'enroll_courses', 'remove_enrollments', inspect_student=False) self.logger = logging.getLogger(self.__class__.__name__) self.path_to_powerschool = config_get_section_attribute('DIRECTORIES', 'path_to_powerschool_dump') self.path_to_output = config_get_section_attribute('DIRECTORIES', 'path_to_output') self.student_info_file = AutoSendFile('dist', 'studentinfo') self.student_info_controller = Controller(Student) self.course_info_controller = Controller(Course) self.teacher_info_controller = Controller(Teacher) self.schedule_info_controller = Controller(Schedule) self.allocation_info_controller = Controller(Allocation) self.user_data = ServerInfo().get_student_info() self.read_in() homerooms = None self._secondary_homerooms = None self._elementary_homerooms = None self.get_homerooms() self.get_secondary_homerooms()
def __init__(self): self.logger = logging.getLogger(self.__class__.__name__) self.logger.warn('Started at {}'.format( datetime.datetime.now() ) ) self.arguments = define_command_line_arguments(*self.switches, **self.strings) self.config = config self.tree = InfoController() if 'DEFAULTS' in self.config.sections(): for key in self.config['DEFAULTS']: setattr(self, key, self.config.getboolean('DEFAULTS', key)) self.email_server = None # TODO: Figure out if this is really needed if self.config.has_section("EMAIL"): self.email_server = self.config['EMAIL'].get('domain') if not self.email_server: self.email_server = 'localhost' have_email_section = self.config.has_section('EMAIL') have_moodle_section = self.config.has_section('MOODLE') # moodle link self.server_information = ServerInfo() # required paths self.path_to_powerschool = config_get_section_attribute('DIRECTORIES', 'path_to_powerschool_dump') self.path_to_output = config_get_section_attribute('DIRECTORIES', 'path_to_output') self.path_to_errors = config_get_section_attribute('DIRECTORIES', 'path_to_errors')
from psmdlsyncer.Tree import Tree from psmdlsyncer.utils import NS from psmdlsyncer.settings import define_command_line_arguments args = define_command_line_arguments(format='{lastfirst}{SPACE}({num})') tree = Tree() # TODO: Need to output an example for ease of use def notlegal(psID): if not psID.isdigit(): return True if not len(psID) == 5: return True if int(psID) < 30000: return True return False output = [] for teacher_key in tree.get_teacher_keys(): teacher = tree.get_teacher(teacher_key) ns = NS(teacher) if teacher.status == 1 and notlegal(teacher.num): print(ns('{lastfirst}{TAB}{num}'))
""" """ import re path_to_mail_log = '/var/log/mail.log' from psmdlsyncer.settings import config_get_section_attribute, \ define_command_line_arguments from psmdlsyncer.html_email import Email from psmdlsyncer.utils import NS from collections import defaultdict from xml.sax.saxutils import escape args = define_command_line_arguments('stdout', 'no_emails') output = config_get_section_attribute('DIRECTORIES', 'path_to_output') domain = config_get_section_attribute('EMAIL', 'domain') if not domain: domain = 'localhost' def out(line): with open(output + '/bounce_stats.txt', 'a') as f: f.write(str(line) + '\n') class Bounce: def __init__(self): self.count = 0 self.messages = [] self.key = "" def __repr__(self): return self.key + ': ' + str(self.count) + '\n' + str(self.messages) bounces = defaultdict(Bounce) for line in open(path_to_mail_log): for search_item in ['status=bounced', 'status=deferred']: