def wrapper(request, *args, **kwargs): """Wrapper for custom endpoints with boilerplate code.""" # Check HTTP verb if request.method not in expected_methods: return django.http.HttpResponseNotAllowed( expected_methods) # 405 # Disable CSRF protection when Shibboleth is enabled. # This is necessary when we're authenticating the user with # `SessionAuthentication` because in a Shibboleth-enabled # environment the `csrftoken` cookie is never set. This is likely # not a problem since Shibboleth provides equivalent protections. if django_settings.SHIBBOLETH_AUTHENTICATION: request._dont_enforce_csrf_checks = True # Auth auth_error = authenticate_request(request) if auth_error is not None: response = {"message": auth_error, "error": True} return django.http.HttpResponseForbidden( # 403 json.dumps(response), content_type="application/json") # Call the decorated method result = func(request, *args, **kwargs) result["X-Archivematica-Version"] = get_full_version() try: result["X-Archivematica-ID"] = request.dashboard_uuid except AttributeError: pass return result
def start_prometheus_server(): init_counter_labels() archivematica_info.info({"version": get_full_version()}) environment_info.info(os.environ) return start_http_server( settings.PROMETHEUS_BIND_PORT, addr=settings.PROMETHEUS_BIND_ADDRESS )
def _run_or_rebot_from_cli(method, cliargs, usage, **argparser_config): LOGGER.register_file_logger() ap = utils.ArgumentParser(usage, get_full_version()) try: options, datasources = \ ap.parse_args(cliargs, argfile='argumentfile', unescape='escape', help='help', version='version', check_args=True, **argparser_config) except Information, msg: _exit(INFO_PRINTED, utils.unic(msg))
def get_system_info(): import sys import version text = "System information:\n" text += " Archy version: %s\n" % str(version.get_full_version()) text += " Command-line arguments: %s\n" % str(sys.argv) if sys.platform == 'win32': text += " Platform: %s\n" % _get_windows_version() else: text += " Platform: %s\n" % str(sys.platform) text += " Python version: %s\n" % str(sys.version) return text
def rebot_from_cli(args, usage): LOGGER.info(get_full_version('Rebot')) _run_or_rebot_from_cli(run_rebot, args, usage)
def run_from_cli(args, usage): LOGGER.info(get_full_version('Robot Framework')) _run_or_rebot_from_cli(run, args, usage, pythonpath='pythonpath')
def _parse_arguments(cliargs, usage, **argparser_config): ap = utils.ArgumentParser(usage, get_full_version()) return ap.parse_args(cliargs, argfile='argumentfile', unescape='escape', help='help', version='version', check_args=True, **argparser_config)
def rebot_from_cli(args, usage): LOGGER.info(get_full_version('Rebot')) return _run_or_rebot_from_cli(run_rebot, args, usage)
def run_from_cli(args, usage): LOGGER.info(get_full_version('Robot Framework')) return _run_or_rebot_from_cli(run, args, usage, pythonpath='pythonpath')
# Base setup initialization # -------------------------- setupParams = SetupParams() setupParams.name = 'Archy' setupParams.options = {} setupParams.data_files = BASE_DATA_FILES setupParams.scripts = BASE_SCRIPTS # -------------------------- # Determine and write version information # -------------------------- import version version.write_build_file() print "Operating on Archy version %s." % version.get_full_version() print "Wrote build information file (%s)." % version.BUILD_FILE print setupParams.data_files.append(("", [version.BUILD_FILE])) setupParams.version = version.get_version() # -------------------------- # command 'py2exe': # Build a Windows Executable # -------------------------- # # Note that py2exe is required to run this target. It can be # retrieved from http://py2exe.sourceforge.net/. # # The windows executable version of Archy will be placed in the 'dist'
# Base setup initialization # -------------------------- setupParams = SetupParams() setupParams.name = 'Archy' setupParams.options = {} setupParams.data_files = BASE_DATA_FILES setupParams.scripts = BASE_SCRIPTS # -------------------------- # Determine and write version information # -------------------------- import version version.write_build_file() print "Operating on Archy version %s." % version.get_full_version() print "Wrote build information file (%s)." % version.BUILD_FILE print setupParams.data_files.append( ("", [version.BUILD_FILE]) ) setupParams.version = version.get_version() # -------------------------- # command 'py2exe': # Build a Windows Executable # -------------------------- # # Note that py2exe is required to run this target. It can be # retrieved from http://py2exe.sourceforge.net/. # # The windows executable version of Archy will be placed in the 'dist'
def test_headers(self): resp = self.client.get("/api/v2beta/package/") assert resp.get("X-Archivematica-Version") == get_full_version() assert resp.get("X-Archivematica-ID") == "test-uuid"
def version(request): version = get_full_version() agent_code = models.Agent.objects.get( identifiertype="preservation system").identifiervalue return render(request, 'administration/version.html', locals())