Python web.application() Examples
The following are 30
code examples of web.application().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
web
, or try the search function
.
Example #1
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ List all parents of a data identifier. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 500 InternalError :returns: A list of dictionary containing all dataset information. """ header('Content-Type', 'application/x-json-stream') try: for dataset in list_parent_dids(scope=scope, name=name): yield render_json(**dataset) + "\n" except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
Example #2
Source File: rule.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, rule_id): """ get locks for a given rule_id. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/x-json-stream') try: locks = get_replica_locks_for_rule_id(rule_id) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) for lock in locks: yield dumps(lock, cls=APIEncoder) + '\n'
Example #3
Source File: rule.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, rule_id): """ get analysis for given rule. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/json') try: analysis = examine_replication_rule(rule_id) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) return render_json(**analysis)
Example #4
Source File: lifetime_exception.py From rucio with Apache License 2.0 | 6 votes |
def GET(self): """ Retrieve all exceptions. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 Internal Error """ header('Content-Type', 'application/x-json-stream') try: for exception in list_exceptions(): yield dumps(exception, cls=APIEncoder) + '\n' except LifetimeExceptionNotFound as error: raise generate_http_error(404, 'LifetimeExceptionNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #5
Source File: lifetime_exception.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, exception_id): """ Retrieve an exception. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 Internal Error """ header('Content-Type', 'application/x-json-stream') try: for exception in list_exceptions(exception_id): yield dumps(exception, cls=APIEncoder) + '\n' except LifetimeExceptionNotFound as error: raise generate_http_error(404, 'LifetimeExceptionNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #6
Source File: rule.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ get history for a given DID. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/x-json-stream') try: history = list_replication_rule_full_history(scope, name) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) for hist in history: yield dumps(hist, cls=APIEncoder) + '\n'
Example #7
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, subscription_id): """ Retrieve a subscription matching the given subscription id HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 406 Not Acceptable """ header('Content-Type', 'application/json') try: subscription = get_subscription_by_id(subscription_id) except SubscriptionNotFound as error: raise generate_http_error(404, 'SubscriptionNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) return render_json(**subscription)
Example #8
Source File: heartbeat.py From rucio with Apache License 2.0 | 6 votes |
def GET(self): """ List all heartbeats. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable """ header('Content-Type', 'application/json') return json.dumps(list_heartbeats(issuer=ctx.env.get('issuer')), cls=APIEncoder)
Example #9
Source File: replica.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, rse): """ List dataset replicas replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 500 InternalError :returns: A dictionary containing all replicas on the RSE. """ header('Content-Type', 'application/x-json-stream') try: for row in list_datasets_per_rse(rse=rse): yield dumps(row, cls=APIEncoder) + '\n' except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
Example #10
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, name): """ Retrieve a subscription by name. HTTP Success: 200 OK HTTP Error: 404 Not Found 500 Internal Error 406 Not Acceptable :param name: The subscription name. """ header('Content-Type', 'application/x-json-stream') try: for subscription in list_subscriptions(name=name): yield dumps(subscription, cls=APIEncoder) + '\n' except SubscriptionNotFound as error: raise generate_http_error(404, 'SubscriptionNotFound', error.args[0]) except Exception as error: raise InternalError(error)
Example #11
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, account=None, name=None): """ Retrieve a subscription. HTTP Success: 200 OK HTTP Error: 404 Not Found 500 Internal Error 406 Not Acceptable :param account: The account name. :param name: The subscription name. """ header('Content-Type', 'application/x-json-stream') try: for subscription in list_subscriptions(name=name, account=account): yield dumps(subscription, cls=APIEncoder) + '\n' except SubscriptionNotFound as error: raise generate_http_error(404, 'SubscriptionNotFound', error.args[0]) except Exception as error: raise InternalError(error)
Example #12
Source File: server.py From cassh with Apache License 2.0 | 6 votes |
def POST(self): """ Get client key status. /client/status """ # LDAP authentication is_auth, message = tools.ldap_authentification(SERVER_OPTS) if not is_auth: return tools.response_render(message, http_code='401 Unauthorized') payload, message = tools.data2map() if message: return tools.response_render(message, http_code='400 Bad Request') if 'realname' in payload: realname = unquote_plus(payload['realname']) else: return tools.response_render( 'Error: No realname option given.', http_code='400 Bad Request') return tools.response_render( TOOLS.list_keys(realname=realname), content_type='application/json')
Example #13
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, account, name=None): """ Return a summary of the states of all rules of a given subscription id. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 Internal Error """ header('Content-Type', 'application/x-json-stream') try: for row in list_subscription_rule_states(account=account): yield dumps(row, cls=APIEncoder) + '\n' except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #14
Source File: archive.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ List archive content keys. HTTP Success: 200 Success HTTP Error: 406 Not Acceptable """ header('Content-Type', 'application/x-json-stream') try: for file in list_archive_content(scope=scope, name=name): yield dumps(file) + '\n' except Exception as error: print(format_exc()) raise InternalError(error)
Example #15
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, subscription_id): """ Retrieve a subscription matching the given subscription id HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 406 Not Acceptable """ header('Content-Type', 'application/json') try: subscription = get_subscription_by_id(subscription_id) except SubscriptionNotFound as error: raise generate_http_error(404, 'SubscriptionNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) return render_json(**subscription)
Example #16
Source File: lifetime_exception.py From rucio with Apache License 2.0 | 6 votes |
def GET(self): """ Retrieve all exceptions. HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 Internal Error """ header('Content-Type', 'application/x-json-stream') try: for exception in list_exceptions(): yield dumps(exception, cls=APIEncoder) + '\n' except LifetimeExceptionNotFound as error: raise generate_http_error(404, 'LifetimeExceptionNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #17
Source File: archive.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ List archive content keys. HTTP Success: 200 Success HTTP Error: 406 Not Acceptable """ header('Content-Type', 'application/x-json-stream') try: for file in list_archive_content(scope=scope, name=name): yield dumps(file) + '\n' except Exception as error: print(format_exc()) raise InternalError(error)
Example #18
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, name): """ Retrieve a subscription by name. HTTP Success: 200 OK HTTP Error: 404 Not Found 500 Internal Error 406 Not Acceptable :param name: The subscription name. """ header('Content-Type', 'application/x-json-stream') try: for subscription in list_subscriptions(name=name): yield dumps(subscription, cls=APIEncoder) + '\n' except SubscriptionNotFound as error: raise generate_http_error(404, 'SubscriptionNotFound', error.args[0]) except Exception as error: raise InternalError(error)
Example #19
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ Gets metadata for a did HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 DataIdentifier Not found 406 Not Acceptable 409 NotImplemented """ header('Content-Type', 'application/x-json-stream') try: meta = get_did_meta(scope=scope, name=name) yield dumps(meta, cls=APIEncoder) + "\n" except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except NotImplementedError: raise generate_http_error(409, 'NotImplementedError', 'Feature not in current database') except Exception as error: print(format_exc()) raise InternalError(error)
Example #20
Source File: subscription.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, account=None, name=None): """ Retrieve a subscription. HTTP Success: 200 OK HTTP Error: 404 Not Found 500 Internal Error 406 Not Acceptable :param account: The account name. :param name: The subscription name. """ header('Content-Type', 'application/x-json-stream') try: for subscription in list_subscriptions(name=name, account=account): yield dumps(subscription, cls=APIEncoder) + '\n' except SubscriptionNotFound as error: raise generate_http_error(404, 'SubscriptionNotFound', error.args[0]) except Exception as error: raise InternalError(error)
Example #21
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, guid): """ Return the file associated to a GUID. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 404 Not Found :param scope: The scope name. """ header('Content-Type', 'application/x-json-stream') try: for dataset in get_dataset_by_guid(guid): yield dumps(dataset, cls=APIEncoder) + '\n' except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #22
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ List all parents of a data identifier. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 500 InternalError :returns: A list of dictionary containing all dataset information. """ header('Content-Type', 'application/x-json-stream') try: for dataset in list_parent_dids(scope=scope, name=name): yield render_json(**dataset) + "\n" except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
Example #23
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ Return all associated rules of a file. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 404 Not Found :param scope: The scope name. """ header('Content-Type', 'application/x-json-stream') try: for rule in list_associated_replication_rules_for_file(scope=scope, name=name): yield dumps(rule, cls=APIEncoder) + '\n' except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #24
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ Return all rules of a given DID. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 404 Not Found :param scope: The scope name. """ header('Content-Type', 'application/x-json-stream') try: for rule in list_replication_rules({'scope': scope, 'name': name}): yield dumps(rule, cls=APIEncoder) + '\n' except RuleNotFound as error: raise generate_http_error(404, 'RuleNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #25
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, guid): """ Return the file associated to a GUID. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 404 Not Found :param scope: The scope name. """ header('Content-Type', 'application/x-json-stream') try: for dataset in get_dataset_by_guid(guid): yield dumps(dataset, cls=APIEncoder) + '\n' except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error)
Example #26
Source File: did.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, scope, name): """ Gets metadata for a did HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 DataIdentifier Not found 406 Not Acceptable 409 NotImplemented """ header('Content-Type', 'application/x-json-stream') try: meta = get_did_meta(scope=scope, name=name) yield dumps(meta, cls=APIEncoder) + "\n" except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except NotImplementedError: raise generate_http_error(409, 'NotImplementedError', 'Feature not in current database') except Exception as error: print(format_exc()) raise InternalError(error)
Example #27
Source File: replica.py From rucio with Apache License 2.0 | 6 votes |
def GET(self, rse): """ List dataset replicas replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 500 InternalError :returns: A dictionary containing all replicas on the RSE. """ header('Content-Type', 'application/x-json-stream') try: for row in list_datasets_per_rse(rse=rse): yield dumps(row, cls=APIEncoder) + '\n' except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
Example #28
Source File: replica.py From rucio with Apache License 2.0 | 5 votes |
def GET(self, scope, name): """ List dataset replicas for a DID (scope:name) using the Virtual Placement service. NOTICE: This is an RnD function and might change or go away at any time. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 500 InternalError :returns: If VP exists a list of dicts of sites, otherwise nothing """ header('Content-Type', 'application/x-json-stream') deep = False if ctx.query: try: params = loads(unquote(ctx.query[1:])) except ValueError: params = parse_qs(ctx.query[1:]) if 'deep' in params: deep = params['deep'][0] try: for row in list_dataset_replicas_vp(scope=scope, name=name, deep=deep): yield dumps(row, cls=APIEncoder) + '\n' except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
Example #29
Source File: account.py From rucio with Apache License 2.0 | 5 votes |
def GET(self, account, rse=None): """ get the current limits for an account on a specific RSE HTTP Success: 200 OK HTTP Error: 404 Not Found 406 Not Acceptable 500 InternalError :param X-Rucio-Account: Account identifier. :param X-Rucio-Auth-Token: as an 32 character hex string. :param account: The account name. :param rse: The rse name. :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/json') try: if rse: limits = get_local_account_limit(account=account, rse=rse) else: limits = get_local_account_limits(account=account) except RSENotFound as error: raise generate_http_error(404, 'RSENotFound', error.args[0]) return render_json(**limits)
Example #30
Source File: replica.py From rucio with Apache License 2.0 | 5 votes |
def GET(self, scope, name): """ List dataset replicas replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 500 InternalError :returns: A dictionary containing all replicas information. """ header('Content-Type', 'application/x-json-stream') deep = False if ctx.query: try: params = loads(unquote(ctx.query[1:])) except ValueError: params = parse_qs(ctx.query[1:]) if 'deep' in params: deep = params['deep'][0] try: for row in list_dataset_replicas(scope=scope, name=name, deep=deep): yield dumps(row, cls=APIEncoder) + '\n' except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)