コード例 #1
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title. Set to None if you wish Falcon
                to return an empty response body (all remaining args will
                be ignored except for headers.) Do this only when you don't
                wish to disclose sensitive information about why a request was
                refused, or if the status and headers are self-descriptive.
            description: Human-friendly description of the error, along with a
                helpful suggestion or two (default None).
            retry_after: Value for the Retry-After header. If a date object,
                will serialize as an HTTP date. Otherwise, a non-negative int
                is expected, representing the number of seconds to wait. See
                also: http://goo.gl/DIrWr
            headers: A dictionary of extra headers to return in the
                response to the client (default None).
            href: A URL someone can visit to find out more information
                (default None).
            href_rel: If href is given, use this value for the rel
                attribute (default 'doc').
            href_text: If href is given, use this as the friendly
                title/description for the link (defaults to "API documentation
                for this error").
            code: An internal code that customers can reference in their
                support request or to help them when searching for knowledge
                base articles related to this error.
        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
コード例 #2
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title. Set to None if you wish Falcon
                to return an empty response body (all remaining args will
                be ignored except for headers.) Do this only when you don't
                wish to disclose sensitive information about why a request was
                refused, or if the status and headers are self-descriptive.
            description: Human-friendly description of the error, along with a
                helpful suggestion or two (default None).
            retry_after: Value for the Retry-After header. If a date object,
                will serialize as an HTTP date. Otherwise, a non-negative int
                is expected, representing the number of seconds to wait. See
                also: http://goo.gl/DIrWr
            headers: A dictionary of extra headers to return in the
                response to the client (default None).
            href: A URL someone can visit to find out more information
                (default None).
            href_rel: If href is given, use this value for the rel
                attribute (default 'doc').
            href_text: If href is given, use this as the friendly
                title/description for the link (defaults to "API documentation
                for this error").
            code: An internal code that customers can reference in their
                support request or to help them when searching for knowledge
                base articles related to this error.
        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
コード例 #3
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self, title, description, **kwargs):
        """Initialize

        Args:
            Same as for HTTPError, except status is set for you.

        """
        HTTPError.__init__(self, status.HTTP_400, title, description, **kwargs)
コード例 #4
0
ファイル: errors.py プロジェクト: eerwitt/falcon
    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault('headers', {})

        scheme = kwargs.pop('scheme', None)
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
コード例 #5
0
ファイル: errors.py プロジェクト: willingc/falcon
    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault('headers', {})

        scheme = kwargs.pop('scheme', None)
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
コード例 #6
0
ファイル: errors.py プロジェクト: ealogar/falcon
    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault("headers", {})

        scheme = kwargs.pop("scheme", None)
        if scheme is not None:
            headers["WWW-Authenticate"] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
コード例 #7
0
ファイル: exceptions.py プロジェクト: julosaure/falcon
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
コード例 #8
0
ファイル: exceptions.py プロジェクト: TinBane/falcon
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
コード例 #9
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self, title, description, **kwargs):
        """Initialize

        Args:
            Same as for HTTPError, except status is set for you.

        """
        HTTPError.__init__(self, status.HTTP_400, title, description, **kwargs)
コード例 #10
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self, description, **kwargs):
        """Initialize

        Args:
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.

        The remaining (optional) args are the same as for HTTPError.

        """

        HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                           description, **kwargs)
コード例 #11
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self, description, **kwargs):
        """Initialize

        Args:
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.

        The remaining (optional) args are the same as for HTTPError.

        """

        HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                           description, **kwargs)
コード例 #12
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self, allowed_methods, **kwargs):
        """Initilize with allowed methods

        Args:
            allowed_methods: A list of allowed HTTP methods for this resource,
                such as ['GET', 'POST', 'HEAD'].

        The remaining (optional) args are the same as for HTTPError.

        """
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
コード例 #13
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self, allowed_methods, **kwargs):
        """Initilize with allowed methods

        Args:
            allowed_methods: A list of allowed HTTP methods for this resource,
                such as ['GET', 'POST', 'HEAD'].

        The remaining (optional) args are the same as for HTTPError.

        """
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
コード例 #14
0
def update_items(raw_data, session):
    item_number = raw_data['item_number']
    inventoryItems = session.query(InventoryItems).filter_by(
        item_number=item_number).first()
    if inventoryItems is None:
        raise HTTPError(status=status_codes.HTTP_404,
                        errors="Item Details does not exist")

    if 'item_number' in raw_data:
        inventoryItems.item_number = raw_data['item_number']
    if 'item_type' in raw_data:
        inventoryItems.item_type = raw_data['item_type']
    if 'description' in raw_data:
        inventoryItems.description = raw_data['description']
    if 'long_description' in raw_data:
        inventoryItems.long_description = raw_data['long_description']
    if 'transaction_uom' in raw_data:
        inventoryItems.remarks = raw_data['transaction_uom']
    if 'conversion' in raw_data:
        inventoryItems.conversion = raw_data['conversion']
    if 'base_uom' in raw_data:
        inventoryItems.base_uom = raw_data['base_uom']
    if 'enabled_flag' in raw_data:
        inventoryItems.enabled_flag = raw_data['enabled_flag']
    inventoryItems.last_updated_by = raw_data['last_updated_by']
コード例 #15
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self, resource_length, media_type=None):
        """Initialize

        Args:
            resource_length: The maximum value for the last-byte-pos of a
                range request. Used to set the Content-Range header.
            media_type: Media type to use as the value of the Content-Type
                header, or None to use the default passed to the API
                initializer.

        """

        headers = {'Content-Range': 'bytes */' + str(resource_length)}
        if media_type is not None:
            headers['Content-Type'] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
コード例 #16
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self, resource_length, media_type=None):
        """Initialize

        Args:
            resource_length: The maximum value for the last-byte-pos of a
                range request. Used to set the Content-Range header.
            media_type: Media type to use as the value of the Content-Type
                header, or None to use the default passed to the API
                initializer.

        """

        headers = {'Content-Range': 'bytes */' + str(resource_length)}
        if media_type is not None:
            headers['Content-Type'] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
コード例 #17
0
def update_purchase_trx(raw_data, session):
    purchase_trx_number = raw_data['purchase_trx_number']
    purchasetrxheader = session.query(PurchaseTrxHeader).filter_by(
        purchase_trx_number=purchase_trx_number).first()
    if purchasetrxheader is None:
        raise HTTPError(status=status_codes.HTTP_404,
                        errors="Purchase Transaction number does not exist")
    if 'transaction_date' in raw_data.keys():
        purchasetrxheader.transaction_date = raw_data['transaction_date']
    if 'order_status' in raw_data.keys():
        purchasetrxheader.order_status = raw_data['order_status']
    if 'buyer_id' in raw_data.keys():
        purchasetrxheader.buyer_id = raw_data['buyer_id']
    if 'supplier_id' in raw_data.keys():
        purchasetrxheader.supplier_id = raw_data['supplier_id']
    if 'last_updated_by' in raw_data.keys():
        purchasetrxheader.last_updated_by = get_user_id_by_user_name(
            raw_data['last_updated_by'])

    purchasetrxLines = []

    if 'purchase_trx_lines' in raw_data.keys():
        for purchase_trx_line in raw_data['purchase_trx_lines']:
            if 'transaction_line_id' in purchase_trx_line.keys():
                for trx_line in purchasetrxheader.purchase_trx_lines:
                    if purchase_trx_line[
                            "transaction_line_id"] == trx_line.transaction_line_id:
                        trx_line.item_id = purchase_trx_line['item_id']
                        #trx_line.line_number = purchase_trx_line['line_number']
                        trx_line.booking_unit_price = purchase_trx_line[
                            'booking_unit_price']
                        trx_line.booking_quantity = purchase_trx_line[
                            'booking_quantity']
                        trx_line.unit_of_measure = purchase_trx_line[
                            'unit_of_measure']
                        #trx_line.created_by = purchase_trx_line['created_by']
                        trx_line.last_updated_by = get_user_id_by_user_name(
                            purchase_trx_line['last_updated_by'])
                        break
            else:
                purchasetrxLine = PurchaseTrxLines()
                purchasetrxLine.item_id = purchase_trx_line['item_id']
                purchasetrxLine.line_number = purchase_trx_line['line_number']
                purchasetrxLine.booking_unit_price = purchase_trx_line[
                    'booking_unit_price']
                purchasetrxLine.booking_quantity = purchase_trx_line[
                    'booking_quantity']
                purchasetrxLine.unit_of_measure = purchase_trx_line[
                    'unit_of_measure']
                purchasetrxLine.created_by = get_user_id_by_user_name(
                    purchase_trx_line['created_by'])
                purchasetrxLine.last_updated_by = get_user_id_by_user_name(
                    purchase_trx_line['last_updated_by'])
                purchasetrxLines.append(purchasetrxLine)

        if len(purchasetrxLines) > 0:
            purchasetrxheader.purchase_trx_lines.extend(purchasetrxLines)
コード例 #18
0
ファイル: exceptions.py プロジェクト: warsaw/falcon
    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        if kwargs:
            title = 'Method not allowed'
        else:
            # NOTE(kgriffs): Trigger an empty body in the response; 405
            # responses don't usually have bodies, so we only send one
            # if the caller indicates they want one, by way of specifying
            # a description, href, and/or other details.
            title = None

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title, **kwargs)
コード例 #19
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self, title, description, scheme=None, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.
            scheme: Authentication scheme to use as the value of the
                WWW-Authenticate header in the response (default None).

        The remaining (optional) args are the same as for HTTPError.


        """
        headers = kwargs.setdefault('headers', {})
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
コード例 #20
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self, title, description, scheme=None, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.
            scheme: Authentication scheme to use as the value of the
                WWW-Authenticate header in the response (default None).

        The remaining (optional) args are the same as for HTTPError.


        """
        headers = kwargs.setdefault('headers', {})
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
コード例 #21
0
ファイル: exceptions.py プロジェクト: B-Rich/falcon
    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        if kwargs:
            title = 'Method not allowed'
        else:
            # NOTE(kgriffs): Trigger an empty body in the response; 405
            # responses don't usually have bodies, so we only send one
            # if the caller indicates they want one, by way of specifying
            # a description, href, and/or other details.
            title = None

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title, **kwargs)
コード例 #22
0
ファイル: exceptions.py プロジェクト: perigee/falcon
    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        # NOTE(kgriffs): Trigger an empty body in the response; 405
        # responses don't usually have bodies, so we only send one
        # if the caller indicates they want one by providing some
        # details in the kwargs.
        if kwargs:
            title = 'Method not allowed'
            self._has_representation = True
        else:
            title = None
            self._has_representation = False

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title=title, **kwargs)
コード例 #23
0
def update_user(raw_data,session):
    user_name = raw_data['user_name']
    userObj = session.query(User).filter_by(user_name=user_name).first()
    if userObj is None:
        raise HTTPError(status=status_codes.HTTP_404, errors="User Details does not exist")
    
    userObj.description = raw_data['description']
    userObj.phone_number1 = raw_data['phone_number1']
    userObj.phone_number2 = raw_data['phone_number2']
    userObj.email = raw_data['email']
    userObj.password = raw_data['password']
    userObj.user_type = raw_data['user_type']
    userObj.effective_from = raw_data['effective_from']
    userObj.effective_to = raw_data['effective_to']
    userObj.last_updated_by = raw_data['last_updated_by']
    userObj.employee_id = raw_data['employee_id']
    userObj.password_life_span = raw_data['password_life_span'] 
コード例 #24
0
ファイル: rest.py プロジェクト: zzart/awaymo_test
def check_types(req, resp, params):
    """
    Checks for well-formatted dates.
    :param req: request object
    :param resp: response object
    :param params: dict of query params
    :return: HTTP Error **400** or pass through upon successful validation
    """
    types = (('earliest_departure_time', format_time),
             ('earliest_return_time', format_time), ('max_price', Decimal),
             ('min_price', Decimal), ('star_rating', int))

    try:
        for item in types:
            if req.get_param(item[0]):
                item[1](req.get_param(item[0]))
    except (ValueError, decimal.InvalidOperation) as e:
        logger.error(e)
        raise HTTPError(HTTP_400, f"{item[0]} could not be parsed.")
コード例 #25
0
ファイル: rest.py プロジェクト: zzart/awaymo_test
    def on_get(self, req, resp, **params):
        """
        :param req: request object
        :param resp: response object
        :param params: additional params passed upon request
        :returns: 200 with json obj or 400
        """

        args = {
            'earliest_departure_time':
            format_time(req.get_param('earliest_departure_time'), TIME_FORMAT)
            if req.get_param('earliest_departure_time') else None,
            'earliest_return_time':
            format_time(req.get_param('earliest_return_time'), TIME_FORMAT)
            if req.get_param('earliest_return_time') else None,
            'max_price':
            Decimal(req.get_param('max_price'))
            if req.get_param('max_price') else None,
            'min_price':
            Decimal(req.get_param('min_price'))
            if req.get_param('min_price') else None,
            'star_rating':
            req.get_param_as_int('star_rating') or None,
        }
        # get rid of empty keys
        args = {k: v for k, v in args.items() if v}
        if not args:
            raise HTTPError(HTTP_400,
                            'Please supply at least one search criteria.')

        search_results = search_listings(listings=XmlParser.get_listings(),
                                         search_criteria=args)
        resp.body = simplejson.dumps(prepare_search_results(search_results),
                                     indent=2,
                                     default=json_handler)
        resp.status = HTTP_200
コード例 #26
0
ファイル: errors.py プロジェクト: eerwitt/falcon
 def __init__(self, resource_length):
     headers = {'Content-Range': 'bytes */' + str(resource_length)}
     HTTPError.__init__(self, status.HTTP_416, headers=headers)
コード例 #27
0
ファイル: errors.py プロジェクト: eerwitt/falcon
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_406, 'Media type not acceptable',
                        description, **kwargs)
コード例 #28
0
ファイル: exceptions.py プロジェクト: abg/falcon
 def __init__(self):
     HTTPError.__init__(self, HTTP_404, None, None)
コード例 #29
0
ファイル: errors.py プロジェクト: ealogar/falcon
 def __init__(self, allowed_methods):
     headers = {"Allow": ", ".join(allowed_methods)}
     HTTPError.__init__(self, status.HTTP_405, headers=headers)
コード例 #30
0
ファイル: http.py プロジェクト: wizeline/falcon-commons
 def has_representation(self):
     return HTTPError(OptionalRepresentation, self).code is not None
コード例 #31
0
ファイル: exceptions.py プロジェクト: abg/falcon
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, HTTP_415, 'Unsupported Media Type',
                        description, **kwargs)
コード例 #32
0
ファイル: exceptions.py プロジェクト: julosaure/falcon
    def __init__(self, resource_length, media_type=None):
        headers = {'Content-Range': 'bytes */' + str(resource_length)}
        if media_type is not None:
            headers['Content-Type'] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
コード例 #33
0
ファイル: exceptions.py プロジェクト: julosaure/falcon
    def __init__(self, allowed_methods, **kwargs):
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
コード例 #34
0
ファイル: exceptions.py プロジェクト: marchon/falcon
 def __init__(self, title, description, retry_after, **kwargs):
     headers = kwargs.setdefault("headers", {})
     headers["Retry-After"] = str(retry_after)
     HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
コード例 #35
0
ファイル: exceptions.py プロジェクト: marchon/falcon
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_426, "Upgrade Required", description, **kwargs)
コード例 #36
0
ファイル: exceptions.py プロジェクト: marchon/falcon
    def __init__(self, resource_length, media_type=None):
        headers = {"Content-Range": "bytes */" + str(resource_length)}
        if media_type is not None:
            headers["Content-Type"] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
コード例 #37
0
ファイル: exceptions.py プロジェクト: marchon/falcon
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, "Unsupported Media Type", description, **kwargs)
コード例 #38
0
ファイル: errors.py プロジェクト: eerwitt/falcon
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_403, title, description, **kwargs)
コード例 #39
0
ファイル: errors.py プロジェクト: willingc/falcon
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                        description, **kwargs)
コード例 #40
0
ファイル: exceptions.py プロジェクト: julosaure/falcon
 def __init__(self):
     HTTPError.__init__(self, status.HTTP_404, None, None)
コード例 #41
0
ファイル: exceptions.py プロジェクト: marchon/falcon
    def __init__(self, allowed_methods, **kwargs):
        headers = kwargs.setdefault("headers", {})
        headers["Allow"] = ", ".join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
コード例 #42
0
ファイル: exceptions.py プロジェクト: jgrassler/monasca-api
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '422 Unprocessable Entity', title, description, **kwargs)
コード例 #43
0
ファイル: exceptions.py プロジェクト: rafaelmartins/falcon
    def __init__(self):
        """Initialize"""

        HTTPError.__init__(self, status.HTTP_404, None, None)
コード例 #44
0
ファイル: exceptions.py プロジェクト: jgrassler/monasca-api
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '400 Bad Request', title, description, **kwargs)
コード例 #45
0
def update_customer(raw_data, session):
    customer_code = raw_data['customer_code']

    customerMasterHeader = session.query(CustomerMasterHeader).filter_by(
        customer_code=customer_code).first()
    if customerMasterHeader is None:
        raise HTTPError(status=status_codes.HTTP_404,
                        errors="Customer does not exist")

    if 'customer_name' in raw_data.keys():
        customerMasterHeader.customer_name = raw_data['customer_name']
    if 'description' in raw_data.keys():
        customerMasterHeader.description = raw_data['description']
    if 'customer_type' in raw_data.keys():
        customerMasterHeader.customer_type = raw_data['customer_type']
    if 'remarks' in raw_data.keys():
        customerMasterHeader.remarks = raw_data['remarks']
    if 'enabled_flag' in raw_data.keys():
        customerMasterHeader.enabled_flag = raw_data['enabled_flag']
    if 'effective_from' in raw_data.keys():
        customerMasterHeader.effective_from = raw_data['effective_from']
    if 'effective_to' in raw_data.keys():
        customerMasterHeader.effective_to = raw_data['effective_to']
    if 'last_updated_by' in raw_data.keys():
        customerMasterHeader.last_updated_by = raw_data['last_updated_by']

    new_customer_sites = []

    for customer_master_site in raw_data['customer_master_sites']:
        for customer_site in customerMasterHeader.sites:
            if 'customer_site_id' in customer_master_site.keys():
                if customer_master_site[
                        "customer_site_id"] == customer_site.customer_site_id:
                    if 'customer_site_code' in customer_master_site.keys():
                        customer_site.customer_site_code = customer_master_site[
                            'customer_site_code']
                    if 'customer_address' in customer_master_site.keys():
                        customer_site.customer_address = customer_master_site[
                            'customer_address']
                    if 'phone_number1' in customer_master_site.keys():
                        customer_site.phone_number1 = customer_master_site[
                            'phone_number1']
                    if 'phone_number2' in customer_master_site.keys():
                        customer_site.phone_number2 = customer_master_site[
                            'phone_number2']
                    if 'email' in customer_master_site.keys():
                        customer_site.email = customer_master_site['email']
                    if 'effective_from' in customer_master_site.keys():
                        customer_site.effective_from = customer_master_site[
                            'effective_from']
                    if 'effective_to' in customer_master_site.keys():
                        customer_site.effective_to = customer_master_site[
                            'effective_to']
                    if 'last_updated_by' in customer_master_site.keys():
                        customer_site.last_updated_by = customer_master_site[
                            'last_updated_by']
                    break
            else:
                new_customer_site = CustomerMasterSites()
                if 'customer_site_code' in customer_master_site.keys():
                    new_customer_site.customer_site_code = customer_master_site[
                        'customer_site_code']
                if 'customer_address' in customer_master_site.keys():
                    new_customer_site.customer_address = customer_master_site[
                        'customer_address']
                if 'phone_number1' in customer_master_site.keys():
                    new_customer_site.phone_number1 = customer_master_site[
                        'phone_number1']
                if 'phone_number2' in customer_master_site.keys():
                    new_customer_site.phone_number2 = customer_master_site[
                        'phone_number2']
                if 'email' in customer_master_site.keys():
                    new_customer_site.email = customer_master_site['email']
                if 'effective_from' in customer_master_site.keys():
                    new_customer_site.effective_from = customer_master_site[
                        'effective_from']
                if 'effective_to' in customer_master_site.keys():
                    new_customer_site.effective_to = customer_master_site[
                        'effective_to']
                if 'created_by' in customer_master_site.keys():
                    new_customer_site.created_by = customer_master_site[
                        'created_by']
                if 'last_updated_by' in customer_master_site.keys():
                    new_customer_site.last_updated_by = customer_master_site[
                        'last_updated_by']
                new_customer_sites.append(new_customer_site)
                break

    if len(new_customer_sites) > 0:
        customerMasterHeader.sites.extend(new_customer_sites)
コード例 #46
0
 def method_wrapper(*args, **kwargs):
     try:
         method(*args, **kwargs)
     except Exception as error:
         raise HTTPError(description=str(error))
コード例 #47
0
def update_receipt_data(raw_data, session):
    challan_number = raw_data['challan_number']
    challanheader = session.query(ReceiptHeader).filter_by(
        challan_number=challan_number).first()
    if challanheader is None:
        raise HTTPError(status=status_codes.HTTP_404,
                        errors="Challan number does not exist")
    if 'vehicle_number' in raw_data.keys():
        challanheader.vehicle_number = raw_data['vehicle_number']
    if 'bata' in raw_data.keys():
        challanheader.bata = raw_data['bata']
    if 'receipt_header_status' in raw_data.keys():
        challanheader.receipt_header_status = raw_data['receipt_header_status']
    if 'net_weight' in raw_data.keys():
        challanheader.net_weight = raw_data['net_weight']
    if 'average_weight' in raw_data.keys():
        challanheader.average_weight = raw_data['average_weight']
    if 'unit_of_measure' in raw_data.keys():
        challanheader.unit_of_measure = raw_data['unit_of_measure']
    if 'total_bags' in raw_data.keys():
        challanheader.total_bags = raw_data['total_bags']
    challanheader.last_updated_by = get_user_id_by_user_name(
        raw_data['last_updated_by'])

    challanLines = []
    is_receipt_complete = False
    if 'receipt_lines' in raw_data.keys():
        for challan_line in raw_data['receipt_lines']:
            if 'receipt_line_id' in challan_line.keys():
                for challanLine in challanheader.receipt_lines:
                    if challan_line[
                            "receipt_line_id"] == challanLine.receipt_line_id:
                        if 'item_id' in challan_line.keys():
                            challanLine.item_id = challan_line['item_id']
                        if 'description' in challan_line.keys():
                            challanLine.description = challan_line[
                                'description']
                        if 'line_number' in challan_line.keys():
                            challanLine.line_number = challan_line[
                                'line_number']
                        if 'load_unload_number' in challan_line.keys():
                            challanLine.load_unload_number = challan_line[
                                'load_unload_number']
                        if 'load_unload_area' in challan_line.keys():
                            challanLine.load_unload_area = challan_line[
                                'load_unload_area']
                        if 'weighing_number' in challan_line.keys():
                            challanLine.weighing_number = challan_line[
                                'weighing_number']
                        if 'receipt_line_status' in challan_line.keys():
                            challanLine.receipt_line_status = challan_line[
                                'receipt_line_status']
                        if 'quantity' in challan_line.keys():
                            challanLine.quantity = challan_line['quantity']
                        if 'number_of_bags' in challan_line.keys():
                            challanLine.number_of_bags = challan_line[
                                'number_of_bags']
                        if 'unit_price' in challan_line.keys():
                            challanLine.unit_price = challan_line['unit_price']
                        if 'unit_of_measure' in challan_line.keys():
                            challanLine.unit_of_measure = challan_line[
                                'unit_of_measure']
                        if 'discount' in challan_line.keys():
                            challanLine.discount = challan_line['discount']
                        if 'last_updated_by' in challan_line.keys():
                            challanLine.last_updated_by = get_user_id_by_user_name(
                                challan_line['last_updated_by'])
                        if challan_line['receipt_line_status'] == 'COMPLETE':
                            is_receipt_complete = is_receipt_complete or True
                        else:
                            is_receipt_complete = is_receipt_complete and False

                        break
            else:
                challanLine = ReceiptLines()
                if 'item_id' in challan_line.keys():
                    challanLine.item_id = challan_line['item_id']
                if 'description' in challan_line.keys():
                    challanLine.description = challan_line['description']
                if 'line_number' in challan_line.keys():
                    challanLine.line_number = challan_line['line_number']
                if 'load_unload_number' in challan_line.keys():
                    challanLine.load_unload_number = challan_line[
                        'load_unload_number']
                if 'load_unload_area' in challan_line.keys():
                    challanLine.load_unload_area = challan_line[
                        'load_unload_area']
                if 'weighing_number' in challan_line.keys():
                    challanLine.weighing_number = challan_line[
                        'weighing_number']
                if 'receipt_line_status' in challan_line.keys():
                    challanLine.receipt_line_status = challan_line[
                        'receipt_line_status']
                if 'quantity' in challan_line.keys():
                    challanLine.quantity = challan_line['quantity']
                if 'number_of_bags' in challan_line.keys():
                    challanLine.number_of_bags = challan_line['number_of_bags']
                if 'unit_price' in challan_line.keys():
                    challanLine.unit_price = challan_line['unit_price']
                if 'unit_of_measure' in challan_line.keys():
                    challanLine.unit_of_measure = challan_line[
                        'unit_of_measure']
                if 'discount' in challan_line.keys():
                    challanLine.discount = challan_line['discount']
                if 'last_updated_by' in challan_line.keys():
                    challanLine.last_updated_by = get_user_id_by_user_name(
                        challan_line['last_updated_by'])
                    challanLine.created_by = get_user_id_by_user_name(
                        challan_line['last_updated_by'])
                challanLines.append(challanLine)
                is_receipt_complete = is_receipt_complete and False

        if len(challanLines) > 0:
            challanheader.receipt_lines.extend(challanLines)
        else:
            if is_receipt_complete:
                challanheader.receipt_header_status = 'COMPLETE'
                challanheader.receipt_date = datetime.datetime.utcnow()
コード例 #48
0
ファイル: exceptions.py プロジェクト: Bengt/falcon
    def __init__(self):
        """Initialize"""

        HTTPError.__init__(self, status.HTTP_404, None, None)
コード例 #49
0
ファイル: exceptions.py プロジェクト: abg/falcon
    def __init__(self, title, description, scheme=None, **kwargs):
        headers = kwargs.setdefault('headers', {})
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, HTTP_401, title, description, **kwargs)
コード例 #50
0
def update_sales_trx(raw_data, session):
    sales_trx_number = raw_data['sales_trx_number']
    salestrxheader = session.query(SalesTrxHeader).filter_by(
        sales_trx_number=sales_trx_number).first()
    if salestrxheader is None:
        raise HTTPError(status=status_codes.HTTP_404,
                        errors="Sales Transaction number does not exist")
    if 'transaction_date' in raw_data.keys():
        salestrxheader.transaction_date = raw_data['transaction_date']
    if 'order_status' in raw_data.keys():
        salestrxheader.order_status = raw_data['order_status']
    if 'sales_rep_id' in raw_data.keys():
        salestrxheader.sales_rep_id = raw_data['sales_rep_id']
    if 'customer_id' in raw_data.keys():
        salestrxheader.customer_id = raw_data['customer_id']
    if 'last_updated_by' in raw_data.keys():
        salestrxheader.last_updated_by = get_user_id_by_user_name(
            raw_data['last_updated_by'])

    salestrxLines = []

    if 'sales_trx_lines' in raw_data.keys():
        for sales_trx_line in raw_data['sales_trx_lines']:
            if 'transaction_line_id' in sales_trx_line.keys():
                for trx_line in salestrxheader.sales_trx_lines:
                    if sales_trx_line[
                            "transaction_line_id"] == trx_line.transaction_line_id:
                        if 'item_id' in sales_trx_line:
                            trx_line.item_id = sales_trx_line['item_id']
                        #trx_line.line_number = sales_trx_line['line_number']
                        if 'booking_unit_price' in sales_trx_line:
                            trx_line.booking_unit_price = sales_trx_line[
                                'booking_unit_price']
                        if 'booking_quantity' in sales_trx_line:
                            trx_line.booking_quantity = sales_trx_line[
                                'booking_quantity']
                        if 'unit_of_measure' in sales_trx_line:
                            trx_line.unit_of_measure = sales_trx_line[
                                'unit_of_measure']
                        #trx_line.created_by = sales_trx_line['created_by']
                        trx_line.last_updated_by = get_user_id_by_user_name(
                            sales_trx_line['last_updated_by'])
                        break
            else:
                salestrxLine = SalesTrxLines()
                if 'item_id' in sales_trx_line:
                    salestrxLine.item_id = sales_trx_line['item_id']
                if 'line_number' in sales_trx_line:
                    salestrxLine.line_number = sales_trx_line['line_number']
                if 'booking_unit_price' in sales_trx_line:
                    salestrxLine.booking_unit_price = sales_trx_line[
                        'booking_unit_price']
                if 'booking_quantity' in sales_trx_line:
                    salestrxLine.booking_quantity = sales_trx_line[
                        'booking_quantity']
                if 'unit_of_measure' in sales_trx_line:
                    salestrxLine.unit_of_measure = sales_trx_line[
                        'unit_of_measure']
                salestrxLine.created_by = get_user_id_by_user_name(
                    sales_trx_line['created_by'])
                salestrxLine.last_updated_by = get_user_id_by_user_name(
                    sales_trx_line['last_updated_by'])
                salestrxLines.append(salestrxLine)

    if len(salestrxLines) > 0:
        salestrxheader.sales_trx_lines.extend(salestrxLines)
コード例 #51
0
ファイル: errors.py プロジェクト: eerwitt/falcon
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                        description, **kwargs)
コード例 #52
0
ファイル: exceptions.py プロジェクト: TinBane/falcon
    def __init__(self, allowed_methods, **kwargs):
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
コード例 #53
0
ファイル: exceptions.py プロジェクト: abg/falcon
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, HTTP_400, title, description, **kwargs)
コード例 #54
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '400 Bad Request', title, description,
                        **kwargs)
コード例 #55
0
ファイル: errors.py プロジェクト: willingc/falcon
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_406, 'Media type not acceptable',
                        description, **kwargs)
コード例 #56
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '422 Unprocessable Entity', title,
                        description, **kwargs)
コード例 #57
0
ファイル: errors.py プロジェクト: willingc/falcon
 def __init__(self, resource_length):
     headers = {'Content-Range': 'bytes */' + str(resource_length)}
     HTTPError.__init__(self, status.HTTP_416, headers=headers)
コード例 #58
0
 def __init__(self, allowed_methods):
     headers = {'Allow': ', '.join(allowed_methods)}
     HTTPError.__init__(self, status.HTTP_405, headers=headers)
コード例 #59
0
ファイル: errors.py プロジェクト: willingc/falcon
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_403, title, description, **kwargs)
コード例 #60
0
ファイル: exceptions.py プロジェクト: marchon/falcon
 def __init__(self):
     HTTPError.__init__(self, status.HTTP_404, None, None)