global session global shotdb global auth from shotdbutil import Reminder from shotmail import AfterMarketMail from time import sleep from shotlogging import logger_bg from shotconfig import * ''' This function sends an email with thanks and after market information to each person who partizipates in the current event. Note: The receivers are the same as for the reminder email. ''' logger_bg.info('start with script "send_after_market_mail" ...') try: count = 0 for row in Reminder(shotdb).get_all_persons(): m = AfterMarketMail(auth, row.person.id, mass = True) m.set_error_handling_parameters(number_attempts = config.bulk_email_number_attempts, delay_next_attempt = config.bulk_email_number_delay_next_attempt) if count == 0: # output account settings logger_bg.info('The following account settings are used:') logger_bg.info('server: %s, sender: %s' % (m.account.server, m.account.sender)) else: sleep(float(config.bulk_email_delay)) m.send()
global shotdb global auth from shotdbutil import WaitList, Numbers from shotmail import WaitDenialMail from time import sleep from shotlogging import logger_bg from shotconfig import * import sys ''' This function goes through the sorted wait list after its resolution. An denial email is sent to each person who did not get a sale number. ''' logger_bg.info('start with script "send_waitlist_denial_mail.py" ...') logger_bg.info('command line arguments: ' + str(sys.argv)) # extract limit from parameter if len(sys.argv) > 1: limit = int(sys.argv[1]) else: limit = 0 try: wl = WaitList(shotdb) if Numbers(shotdb, wl.eid).b_numbers_available(): logger_bg.warning('There are still sale numbers available! Nothing is done.') else: count = 0 for row in wl.get_denials(limit):
global shotdb global auth from shotdbutil import * from shotmail import NumberFromWaitlistMail, NumberFromWaitlistMailSuccession from time import sleep from shotlogging import logger_bg from shotconfig import * import sys ''' This function goes through the sorted wait list and assigns sale numbers as long as there are numbers left. An email is sent to each person who got a sale number this way. ''' logger_bg.info('start with script "resolve_waitlist" ...') logger_bg.info('command line arguments: ' + str(sys.argv)) # extract limit from parameter # The code below relies on a matching implementation of the task parameterization in the controller function. limit = int(sys.argv[1]) option_helpers = sys.argv[2] logger_bg.info(' limit = %d' % limit) logger_bg.info(' option_helpers = %s' % option_helpers) b_log_account_number_mail = True b_log_account_number_mail_succ = True if option_helpers == 'use': b_option_use_helper_numbers = True
This background task is to regularize person names, street names etc. according to the same rules applied at form level. ''' if 0: from gluon.languages import translator as T from gluon import * import gluon global request global response global session global shotdbold global shotdb from shotlogging import logger_bg from formutils import regularizeName logger_bg.info('start with script "resolve_waitlist" ...') try: count = 0 for row in shotdb(shotdb.person.id > 0).select(): count += 1 msg = '#%d, id: %d\t%s, %s' % (count, row.id, row.name, row.forename) logger_bg.info(msg) new = { 'forename' : regularizeName(row.forename), 'name' : regularizeName(row.name), 'place' : regularizeName(row.place), 'street' : regularizeName(row.street) }
global auth from time import sleep from shotlogging import logger_bg from shotconfig import * from shotdbutil import Team from shotmail import AppropriationRequestTeamInfoMail import sys ''' This function is invoked immediately after a new appropriation request has been submitted. It loops through all active team members for which this email type is configured. For each an email with a direct link to the new request is sent. ''' logger_bg.info('start with script "send_team_info_new_request.py" ...') logger_bg.info('command line arguments: ' + str(sys.argv)) try: # extract id of the appropriation request from parameters if len(sys.argv) > 1: aid = int(sys.argv[1]) else: aid = None if not aid: logger_bg.info('There is no proper request ID, abort!') else: logger_bg.info('ID of the appropriation request: %d' % aid)
from gluon import * import gluon global request global response global session global shotdb from shotlogging import logger_bg from shotconfig import config import datetime import subprocess ''' This function generates a backup dump of the complete shot database. ''' logger_bg.info('start with script "backup_db" ...') try: if config.enable_debug: p = subprocess.Popen(['whoami'], shell = True, stdout=subprocess.PIPE, stderr = subprocess.PIPE) out, err = p.communicate() for s in out.split('\n'): if s: logger_bg.debug('user obtained by whoami: ' + s) for s in err.split('\n'): if s: logger_bg.error(s) p = subprocess.Popen('echo $SHELL', shell = True, executable = '/bin/bash', stdout = subprocess.PIPE, stderr = subprocess.PIPE) out, err = p.communicate() for s in out.split('\n'):