Python 2.6 Decompile --- I lost my views.py but have the views.pyc

866 views
Skip to first unread message

Andrew

unread,
Dec 17, 2009, 2:19:08 PM12/17/09
to Django users
Hi guys,
Ok...firstly me bad ... I didn't check into my source control which
was stupid. So if I can close that book ;-)

I am looking for a decompiler for my views.pyc ... Im using django
1.1.1 and python 2.6.2 ... I have tried UnPyc but fails.

Has anyone successfully found a 2.6 decompiler ?

Thanks
Andrew
( desperate to get my ...eeek...days back )

Bill Freeman

unread,
Dec 17, 2009, 2:28:35 PM12/17/09
to django...@googlegroups.com
I saw a demo of a byte code disassembler once. It won't get you the
source code back, but you could conceivably construct equivalent from
it. You can, for example, see what it's calling, and sketch out the
contiditionals and any loops. You could google for it, or ask on the
python tutor mailing list.

> --
>
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>
>

Shawn Milochik

unread,
Dec 17, 2009, 2:45:47 PM12/17/09
to django...@googlegroups.com
This won't help you unless there's something you forgot about, but it could help you in the future. In addition to git, I also use JungleDisk. It backs up my entire projects folder every hour. Perhaps you have Carbonite, JungleDisk, Mozy, or one of those services and you might be able to recover it there? Do you use a Mac with Time Machine? Is your computer a company-owned machine which may be imaged or backed up automatically?

Does your editor create an automatic hidden backup, like vim or emacs does?

I hope you recover the work.

Shawn


Bill Freeman

unread,
Dec 17, 2009, 2:51:39 PM12/17/09
to django...@googlegroups.com
The name of the byte code disassembler is dis, and it's part of the
standard python install in 2.4, 2.5, 2.6, and 3.0 (the ones I have
handy to test with) and will be documented in the default docs. You
can confirm that you have it by trying "import dis".

Andrew

unread,
Dec 17, 2009, 6:41:25 PM12/17/09
to Django users
Thanks guys for all the comments....Im on ubuntu on eclipse and there
was no local history alas....

Thems the breaks when you omit to submit ;-) ... to source control...

I used UnPyc to disassemble the .pyc and I am now rewriting the python
using the assembly as a guide. Good think I did mainframe ibm system
390 all those years ago...

Haven't been this hardcore in years.... ;-)

Fabian Ezequiel Gallina

unread,
Dec 17, 2009, 6:48:58 PM12/17/09
to django...@googlegroups.com
2009/12/17 Andrew <andrew....@gmail.com>:

> Thanks guys for all the comments....Im on ubuntu on eclipse and there
> was no local history alas....
>
> Thems the breaks when you omit to submit ;-) ... to source control...
>
> I used UnPyc to disassemble the .pyc and I am now rewriting the python
> using the assembly as a guide. Good think I did mainframe ibm system
> 390 all those years ago...
>
> Haven't been this hardcore in years.... ;-)
>

Did you tried photorec[0] of testdisk's[1] suite?

It can actually recover deleted files from your filesystem. The good
news is that it is free software and AFAIK is in the Ubuntu
repository.

sudo aptitude install testdisk.

[0] http://www.cgsecurity.org/wiki/PhotoRec
[1] http://www.cgsecurity.org/wiki/TestDisk


I recovered an emacs lisp file I was working on not much time ago. I'd
recommend you to filter the files to recover to .txt files only.

The bad news is that it dont recover file names, but that's nothing a
'grep -R -i "some_view_name" .' cannot solve.


Regards,
--
Fabián E. Gallina
http://www.from-the-cloud.com

Reply all
Reply to author
Forward
0 new messages