示例#1
0
    List Transfers that have been cancelled
'''

import logging
import sys as sys
from datetime import datetime, timedelta
from models import Transfer, configSectionMap, Session
from controllers import SourceController, Gfal2Controller

logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logger = logging.getLogger(__name__)

session = Session()
minutes = 60 * 6
allow_resubmit_before = datetime.now() + timedelta(minutes=-int(minutes))
host = configSectionMap("Default")['host']
logger.info('Running on: ' + host)

records = (session.query(Transfer).filter_by(is_invalid=0).filter_by(
    status='SUBMITTED').filter_by(resubmit_id=None).filter_by(
        src_host=host).filter(
            Transfer.updated_at < allow_resubmit_before).order_by(
                Transfer.transfer_attemp.desc()).limit(10))

resubmit_count = 0
suitable_for_resubmission_count = 0

if records.count() > 0:
    castor = Gfal2Controller()
    for record in records:
        source_path = record.src_path + record.file_name
import gc
import os
import glob
import logging
from datetime import datetime, timedelta
import time
from models import Transfer, configSectionMap, showDatabase, Session
from sqlalchemy import func
from controllers import FtsController, CdrController
from controllers import GracefulInterruptController
from controllers import SourceController


if __name__ == '__main__':
    session = Session()
    host = configSectionMap("Default")['host']
    source_dir = configSectionMap("Default")['file_dir']
    amount = (
        session.query(Transfer)
        .filter_by(is_invalid=0)
        .filter_by(status='FINISHED')
        .filter_by(is_src_deleted=0)
        .filter_by(src_host=host)
        .order_by(None).count()
    )

    source_dir = source_dir + '/'
    files = filter(os.path.isfile, glob.glob(source_dir + "*"))
    source_amount = len(files)
    if amount < source_amount:
示例#3
0
文件: cdr.py 项目: emmayint/CERN-CDR
import sys
import logging
import logging.config
from datetime import datetime
import time
from models import configSectionMap, Session
from controllers import FtsController, CdrController
from controllers import GracefulInterruptController

if __name__ == '__main__':
    logging.config.fileConfig('/etc/na62cdr-logging.ini')
    logger = logging.getLogger(__name__)
    logger.info("Starting cdr")

    session = Session()
    host = configSectionMap("Default")['host']
    fts_instance = FtsController('https://fts3-daq.cern.ch:8446')
    cdr = CdrController(fts_instance, host)
    with GracefulInterruptController() as handler:
        start_date = datetime.now()
        submit_success = 0
        submit_fail = 0
        transfer_finished = 0
        transfer_failed = 0
        files_deleted = 0
        transfer_resubmitted = 0
        #allows to read multiple path (, separation)
        file_dirs = map(str.strip,
                        configSectionMap('Default')['file_dir'].split(','))

        life_in_minutes = int(configSectionMap("Default")['minutes_of_life'])