def get_fonts(session_id=None): """ Validates that the fonts to output the SVG models are properly set up :param session_id: The session ID provided by the user :return: The font name, font size and AP font name :rtype : str,str,str :raise CairisHTTPError: Raises a CairisHTTPError when the database could not be properly set up """ if session_id is not None: b = Borg() settings = b.get_settings(session_id) fontName = settings.get('fontName', None) fontSize = settings.get('fontSize', None) apFontName = settings.get('apFontSize', None) if fontName is None or fontSize is None or apFontName is None: raise CairisHTTPError( status_code=httplib.BAD_REQUEST, message='The method is not callable without setting up the project settings.' ) elif isinstance(fontName, str) and isinstance(fontSize, str) and isinstance(apFontName, str): return fontName, fontSize, apFontName else: raise CairisHTTPError( status_code=httplib.BAD_REQUEST, message='The database connection was not properly set up. Please try to reset the connection.' ) else: raise CairisHTTPError( status_code=httplib.BAD_REQUEST, message='The method is not callable without setting up the project settings.' )
def json_serialize(obj, pretty_printing=False, session_id=None): """ Serializes the Python object to a JSON serialized string. :param obj: The object to be serialized :type obj: object :param pretty_printing: Defines if the string needs to be pretty printed :type pretty_printing: bool :param session_id: The user's session ID :type session_id: int :return: Returns a JSON serialized string of the object """ b = Borg() if session_id is None: session_id = session.get('session_id', None) s = b.get_settings(session_id) if s is not None: pretty_printing = s.get('jsonPrettyPrint', False) if pretty_printing: json_string = dumps(loads(serialize(obj)), indent=4) else: json_string = serialize(obj) for key in conv_terms: json_string = json_string.replace(key, conv_terms[key]) return json_string
def get_fonts(session_id=None): """ Validates that the fonts to output the SVG models are properly set up :param session_id: The session ID provided by the user :return: The font name, font size and AP font name :rtype : str,str,str :raise CairisHTTPError: Raises a CairisHTTPError when the database could not be properly set up """ if session_id is not None: b = Borg() settings = b.get_settings(session_id) fontName = settings.get('fontName', None) fontSize = settings.get('fontSize', None) apFontName = settings.get('apFontSize', None) if fontName is None or fontSize is None or apFontName is None: raise CairisHTTPError( status_code=httplib.BAD_REQUEST, message= 'The method is not callable without setting up the project settings.' ) elif isinstance(fontName, str) and isinstance( fontSize, str) and isinstance(apFontName, str): return fontName, fontSize, apFontName else: raise CairisHTTPError( status_code=httplib.BAD_REQUEST, message= 'The database connection was not properly set up. Please try to reset the connection.' ) else: raise CairisHTTPError( status_code=httplib.BAD_REQUEST, message= 'The method is not callable without setting up the project settings.' )