Skip to content

Instantly share code, notes, and snippets.

@Urth
Urth / recover_source_code.md
Created March 15, 2017 12:40 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
OpenGL version 4.5.0 NVIDIA 361.28
GLSL version 4.50 NVIDIA
Framebuffer ID: 1
Renderbuffer ID: 1 size 1024x1024
New gamepad attached:
Description: Microsoft X-Box 360 pad
Vendor ID: 10462
Product ID: 4604
Number of axes: 8
Number of buttons: 11

Keybase proof

I hereby claim:

  • I am urth on github.
  • I am hgeerts (https://keybase.io/hgeerts) on keybase.
  • I have a public key whose fingerprint is B545 47D1 8103 8F37 9A30 4B43 48B7 F805 6D07 83D1

To claim this, I am signing this object: