diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-10-27 17:32:40 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-10-27 17:32:40 +0200 |
commit | 17d335a49f92b8eb45cf366aa235536aeefb5014 (patch) | |
tree | 11f2fe7cf6bd609e511fbdffd4deeb363945c6e9 /scripts | |
parent | 4106d0c2c778926e86829a7bf86c83830b38b69e (diff) |
Add support for pickles to trace viewer
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/trace_viewer.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/trace_viewer.py b/scripts/trace_viewer.py index ebf75b7..6d5e1f4 100644 --- a/scripts/trace_viewer.py +++ b/scripts/trace_viewer.py @@ -15,13 +15,19 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import curses +import pickle import sys from monkey.action import parse, expand from db.models import Problem, Solution if len(sys.argv) > 1: - pid = int(sys.argv[1]) + if sys.argv[1].endswith('.pickle'): + with open(sys.argv[1], 'rb') as f: + attempts = pickle.load(f) + else: + pid = int(sys.argv[1]) + attempts = sorted(Solution.filter(problem_id=pid), key=lambda s: s.codeq_user_id) else: # print all problem ids print('problems:') @@ -29,7 +35,7 @@ else: print(' {}\t{}'.format(problem.id, problem.identifier)) print() pid = int(input('enter problem id: ')) -attempts = sorted(Solution.filter(problem_id=pid), key=lambda s: s.codeq_user_id) + attempts = sorted(Solution.filter(problem_id=pid), key=lambda s: s.codeq_user_id) def get_actions(trace): try: |