Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix-up the graph scripts #13013

Merged
merged 9 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions contrib/graph/graph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import argparse
import cgi
import datetime
import json

import pydot
import urllib2

# Copyright 2014-2016 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,12 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import cgi
import datetime
import json

import pydot
import urllib2


def make_name(pdu_id, origin):
return "%s@%s" % (pdu_id, origin)


def make_graph(pdus, room, filename_prefix):
"""
Generate a dot and SVG file for a graph of events in the room based on the
topological ordering by querying a homeserver.
"""
pdu_map = {}
node_map = {}

Expand Down
6 changes: 5 additions & 1 deletion contrib/graph/graph2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@


def make_graph(db_name, room_id, file_prefix, limit):
"""
Generate a dot and SVG file for a graph of events in the room based on the
topological ordering by reading from a Synapse SQLite database.
"""
conn = sqlite3.connect(db_name)

sql = (
Expand Down Expand Up @@ -126,7 +130,7 @@ def make_graph(db_name, room_id, file_prefix, limit):
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Generate a PDU graph for a given room by talking "
"to the given homeserver to get the list of PDUs. \n"
"to the given a Synapse SQLite file to get the list of PDUs. \n"
clokep marked this conversation as resolved.
Show resolved Hide resolved
"Requires pydot."
)
parser.add_argument(
Expand Down
24 changes: 14 additions & 10 deletions contrib/graph/graph3.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import argparse
import cgi
import datetime

import pydot
import simplejson as json

from synapse.events import FrozenEvent
from synapse.util.frozenutils import unfreeze

# Copyright 2016 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,8 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import cgi
import datetime

import pydot
import simplejson as json

from synapse.events import FrozenEvent
from synapse.util.frozenutils import unfreeze


def make_graph(file_name, room_id, file_prefix, limit):
"""
Generate a dot and SVG file for a graph of events in the room based on the
topological ordering by reading line-delimited JSON from a file.
"""
print("Reading lines")
with open(file_name) as f:
lines = f.readlines()
Expand Down