(*args, **kwargs)
| 25 | |
| 26 | @wraps(f) |
| 27 | def wrap(*args, **kwargs): |
| 28 | # Here args[0] will hold self & kwargs will hold gid,sid,did |
| 29 | |
| 30 | g.manager = get_driver( |
| 31 | PG_DEFAULT_DRIVER).connection_manager( |
| 32 | kwargs['sid'] |
| 33 | ) |
| 34 | |
| 35 | def get_error(i_node_type): |
| 36 | stats_type = ('activity', 'prepared', 'locks', 'config') |
| 37 | if f.__name__ in stats_type: |
| 38 | return precondition_required( |
| 39 | gettext("Please connect to the selected {0}" |
| 40 | " to view the table.".format(i_node_type)) |
| 41 | ) |
| 42 | else: |
| 43 | return precondition_required( |
| 44 | gettext("Please connect to the selected {0}" |
| 45 | " to view the graph.".format(i_node_type)) |
| 46 | ) |
| 47 | |
| 48 | # Below check handle the case where existing server is deleted |
| 49 | # by user and python server will raise exception if this check |
| 50 | # is not introduce. |
| 51 | if g.manager is None: |
| 52 | return get_error('server') |
| 53 | |
| 54 | if 'did' in kwargs: |
| 55 | g.conn = g.manager.connection(did=kwargs['did']) |
| 56 | node_type = 'database' |
| 57 | else: |
| 58 | g.conn = g.manager.connection() |
| 59 | node_type = 'server' |
| 60 | |
| 61 | # If not connected then return error to browser |
| 62 | if not g.conn.connected(): |
| 63 | return get_error(node_type) |
| 64 | |
| 65 | # Set template path for sql scripts |
| 66 | g.server_type = g.manager.server_type |
| 67 | g.version = g.manager.version |
| 68 | |
| 69 | # Include server_type in template_path |
| 70 | g.template_path = 'dashboard/sql/' + ( |
| 71 | '#{0}#'.format(g.version) |
| 72 | ) |
| 73 | |
| 74 | return f(*args, **kwargs) |
| 75 | |
| 76 | return wrap |
nothing calls this directly
no test coverage detected