Esempio n. 1
0
if option_helpers == 'use':
    b_option_use_helper_numbers = True
else:
    b_option_use_helper_numbers = False

try:
    wl = WaitList(shotdb)
    count = 0
    for row in wl.get_sorted(limit, b_option_use_helper_numbers):
        if Numbers(shotdb, wl.eid).b_numbers_available():
            if count > 0:
                # wait before sending next mail
                sleep(float(config.bulk_email_delay))
            
            count += 1
            logger_bg.debug('Start with row number %d' % count)
            
            msg = '#%d, id: %d\t%s, %s' % (count, row.person.id, row.person.name, row.person.forename)
            sid = NumberAssignment(shotdb, row.person.id, b_option_use_helper_numbers).assign_number()
            
            logger_bg.debug('Sale number has been determined successfully! sid = %d' %sid)
            
            if sid > 0:
                shotdb.commit()
                logger_bg.debug('Database has been commited.')
                
                msg = msg + ', sale id: ' + str(sid)
                
                if row.wait.denial_sent:
                    m = NumberFromWaitlistMailSuccession(auth, row.person.id, mass = True)
                    m.set_error_handling_parameters(number_attempts = config.bulk_email_number_attempts,
Esempio n. 2
0
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'):
            if s:
                logger_bg.debug('shell used: ' + s)
        for s in err.split('\n'):
            if s:
                logger_bg.error(s)
                

    cmd = config.db_backup_command % {'timestamp': datetime.datetime.now().strftime("%Y-%m-%d_%H_%M_%S")}