Beispiel #1
0
            if format:
                os.rename(img_filename, f'{img_filename}.{format}')
        if userAgent:
            scanarium.dump_text(filename_base + '-user-agent.txt', userAgent)
    else:
        raise ScanariumError('SE_UNKNOWN_FEEDBACK_TARGET',
                             'Unknown feedback target "{feedback_target}"',
                             {'feedback_target': target})
    return True


def register_arguments(scanarium, parser):
    parser.add_argument('MESSAGE', help='The textual part of the feedback')
    parser.add_argument('EMAIL', nargs='?',
                        help='The email to send the answer to')
    parser.add_argument('LAST_FAILED_UPLOAD', nargs='?',
                        help='The last failed upload')
    parser.add_argument('USER_AGENT', nargs='?',
                        help='The browser identification')


if __name__ == "__main__":
    scanarium = Scanarium()
    args = scanarium.handle_arguments(
        'Reports feedback',
        register_arguments,
        whitelisted_cgi_fields={
            'message': 1, 'email': 2, 'lastFailedUpload': 3, 'userAgent': 4})
    scanarium.call_guarded(report_feedback, args.MESSAGE, args.EMAIL,
                           args.LAST_FAILED_UPLOAD, args.USER_AGENT)
Beispiel #2
0
import os
import logging
import sys

SCANARIUM_DIR_ABS = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, SCANARIUM_DIR_ABS)
from scanarium import Scanarium
del sys.path[0]

logger = logging.getLogger(__name__)


def reindex(scanarium):
    dynamic_scenes_dir = os.path.join(scanarium.get_dynamic_directory(),
                                      'scenes')
    scenes_dir_abs = scanarium.get_scenes_dir_abs()
    for scene in os.listdir(scenes_dir_abs):
        if os.path.isdir(os.path.join(scenes_dir_abs, scene)):
            logging.debug(f'Reindexing scene "{scene}" ...')
            dynamic_scene_dir = os.path.join(dynamic_scenes_dir, scene)
            if not os.path.isdir(dynamic_scene_dir):
                os.makedirs(dynamic_scene_dir)
            scanarium.reindex_actors_for_scene(scene)


if __name__ == "__main__":
    scanarium = Scanarium()
    scanarium.handle_arguments('Reindexes dynamic content, such as actors')
    scanarium.call_guarded(reindex)
Beispiel #3
0
                                 'Backend failed')

        if e.code == 'SE_TIMEOUT':
            raise ScanariumError('SE_PWD_UPDATE_TIMEOUT',
                                 'Update process timed out')

        raise e
    return {}


def register_arguments(scanarium, parser):
    parser.add_argument('OLD_PASSWORD', help='The current password')
    parser.add_argument('NEW_PASSWORD', help='The new password')


if __name__ == "__main__":
    scanarium = Scanarium()
    args = scanarium.handle_arguments(
        'Updates the password for a user. Do NOT call this script directly in '
        'production, as passing passwords as command-line arguments on '
        'command-line might expose them to other users that can view process '
        'names. Instead, call it through CGI, where parameters are not passed '
        'as command-line arguments.',
        register_arguments,
        whitelisted_cgi_fields={
            'old-password': 1,
            'new-password': 2
        })
    scanarium.call_guarded(update_password, args.OLD_PASSWORD,
                           args.NEW_PASSWORD)