Ejemplo n.º 1
0
def unset_maintenance(ctx):
    from website.app import setup_django
    setup_django()
    from website.maintenance import unset_maintenance
    print('Taking down maintenance notice...')
    unset_maintenance()
    print('...Done.')
Ejemplo n.º 2
0
def unset_maintenance(ctx):
    from website.app import setup_django
    setup_django()
    from website.maintenance import unset_maintenance
    print('Taking down maintenance notice...')
    unset_maintenance()
    print('...Done.')
Ejemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser(
        description='Changes the provider of specified Preprint objects')

    parser.add_argument(
        '--targets',
        action='store',
        dest='targets',
        help='List of targets, of form ["registration_id", ...]',
    )
    pargs = parser.parse_args()
    script_utils.add_file_logger(logger, __file__)
    setup_django()
    migrate(json.loads(pargs.targets))
def main():
    parser = argparse.ArgumentParser(
        description='Changes the provider of specified PreprintService objects'
    )

    parser.add_argument(
        '--targets',
        action='store',
        dest='targets',
        help='List of targets, of form ["registration_id", ...]',
    )
    pargs = parser.parse_args()
    script_utils.add_file_logger(logger, __file__)
    setup_django()
    migrate(json.loads(pargs.targets))
Ejemplo n.º 5
0
def set_maintenance(ctx, start=None, end=None):
    from website.app import setup_django
    setup_django()
    from website.maintenance import set_maintenance
    """Set the time period for the maintenance notice to be displayed.
    If no start or end values are displayed, default to starting now
    and ending 24 hours from now. If no timezone info is passed along,
    everything will be converted to UTC.

    If a given end time results in a start that is after the end, start
    will be changed to be 24 hours before the end time.

    Examples:
        invoke set_maintenance
        invoke set_maintenance --start 2016-03-16T15:41:00-04:00
        invoke set_maintenance --end 2016-03-16T15:41:00-04:00
    """
    state = set_maintenance(start, end)
    print('Maintenance notice up for {} to {}.'.format(state['start'], state['end']))
Ejemplo n.º 6
0
def set_maintenance(ctx, message='', level=1, start=None, end=None):
    from website.app import setup_django
    setup_django()
    from website.maintenance import set_maintenance
    """Display maintenance notice across OSF applications (incl. preprints, registries, etc.)

    start - Start time for the maintenance period
    end - End time for the mainteance period
        NOTE: If no start or end values are provided, default to starting now
        and ending 24 hours from now.
    message - Message to display. If omitted, will be:
        "The site will undergo maintenance between <localized start time> and <localized end time>. Thank you
        for your patience."
    level - Severity level. Modifies the color of the displayed notice. Must be one of 1 (info), 2 (warning), 3 (danger).

    Examples:
        invoke set_maintenance --start 2016-03-16T15:41:00-04:00 --end 2016-03-16T15:42:00-04:00
        invoke set_maintenance --message 'The OSF is experiencing issues connecting to a 3rd party service' --level 2 --start 2016-03-16T15:41:00-04:00 --end 2016-03-16T15:42:00-04:00
    """
    state = set_maintenance(message, level, start, end)
    print('Maintenance notice up {} to {}.'.format(state['start'], state['end']))
Ejemplo n.º 7
0
def set_maintenance(ctx, message='', level=1, start=None, end=None):
    from website.app import setup_django
    setup_django()
    from website.maintenance import set_maintenance
    """Display maintenance notice across OSF applications (incl. preprints, registries, etc.)

    start - Start time for the maintenance period
    end - End time for the mainteance period
        NOTE: If no start or end values are provided, default to starting now
        and ending 24 hours from now.
    message - Message to display. If omitted, will be:
        "The site will undergo maintenance between <localized start time> and <localized end time>. Thank you
        for your patience."
    level - Severity level. Modifies the color of the displayed notice. Must be one of 1 (info), 2 (warning), 3 (danger).

    Examples:
        invoke set_maintenance --start 2016-03-16T15:41:00-04:00 --end 2016-03-16T15:42:00-04:00
        invoke set_maintenance --message 'The OSF is experiencing issues connecting to a 3rd party service' --level 2 --start 2016-03-16T15:41:00-04:00 --end 2016-03-16T15:42:00-04:00
    """
    state = set_maintenance(message, level, start, end)
    print('Maintenance notice up {} to {}.'.format(state['start'], state['end']))
Ejemplo n.º 8
0
def set_maintenance(ctx, message='', level=1, start=None, end=None):
    from website.app import setup_django
    setup_django()
    from website.maintenance import set_maintenance
    """Creates a maintenance notice.

    Message is required.
    Level defaults to 1. Valid levels are 1 (info), 2 (warning), and 3 (danger).

    Set the time period for the maintenance notice to be displayed.
    If no start or end values are displayed, default to starting now
    and ending 24 hours from now. If no timezone info is passed along,
    everything will be converted to UTC.

    If a given end time results in a start that is after the end, start
    will be changed to be 24 hours before the end time.

    Examples:
        invoke set_maintenance --message 'OSF down for scheduled maintenance.' --start 2016-03-16T15:41:00-04:00
        invoke set_maintenance --message 'Apocalypse' --level 3 --end 2016-03-16T15:41:00-04:00
    """
    state = set_maintenance(message, level, start, end)
    print('Maintenance notice up {} to {}.'.format(state['start'],
                                                   state['end']))
import logging

from framework.celery_tasks import app as celery_app
from osf.models import Registration
from django.core.management.base import BaseCommand
from osf.utils.workflows import RegistrationModerationStates
from website.settings import STUCK_FILES_DELETE_TIMEOUT
from django.db.models import Count
from website.app import setup_django
setup_django()

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)


def mark_withdrawn_files_as_deleted(batch_size, dry_run=False):

    withdrawn_registrations = Registration.objects.filter(
        moderation_state=RegistrationModerationStates.WITHDRAWN.db_name)
    logger.info(
        f'{"[DRY-RUN]" if dry_run else ""} There are {withdrawn_registrations.count()} registrations that are stuck'
    )

    for node in withdrawn_registrations.annotate(fc=Count('files')).filter(
            fc__gte=1)[:batch_size]:
        files_to_be_deleted = node.files.all()
        logger.info(
            f'{"[DRY-RUN]" if dry_run else ""} There are {files_to_be_deleted.count()} files deleted from withrawn node ({node._id})'
        )
        for file in files_to_be_deleted:
            if not dry_run:
Ejemplo n.º 10
0
# -*- coding: utf-8 -*-
import io
import os
import csv
import logging
from datetime import datetime

from website.app import setup_django
setup_django()

from django.utils import timezone

from website import mails
from website import settings

from framework.auth import Auth
from framework.celery_tasks import app as celery_app
from osf.management.commands import force_archive as fa
from osf.models import ArchiveJob, Registration
from website.archiver import ARCHIVER_INITIATED
from website.settings import ARCHIVE_TIMEOUT_TIMEDELTA, ADDONS_REQUESTED

from scripts import utils as scripts_utils

logger = logging.getLogger(__name__)

HERE = os.path.dirname(os.path.abspath(__file__))

def find_failed_registrations():
    expired_if_before = datetime.utcnow() - ARCHIVE_TIMEOUT_TIMEDELTA
    jobs = ArchiveJob.objects.filter(sent=False, datetime_initiated__lt=expired_if_before, status=ARCHIVER_INITIATED).prefetch_related('dst_node')
def main():
    dry_run = '--dry' in sys.argv
    if not dry_run:
        script_utils.add_file_logger(logger, __file__)
    setup_django()
    migrate(dry=dry_run)
Ejemplo n.º 12
0
def main():
    dry_run = '--dry' in sys.argv
    if not dry_run:
        script_utils.add_file_logger(logger, __file__)
    setup_django()
    migrate(dry=dry_run)